Page 1 of 1

An infinite mag script

Posted: Thu Feb 15, 2024 9:25 pm
by STAR_Founder
Any suggestions on how to improve this? I was thinking of making it purchaseable in world mode, but the price would double every time its purchased. The hardest part would be to make it double only for an individual player, requiring a database for how many times each player has bought the infinite mag.

Code: Select all

---@type Plugin
local plugin = ...
plugin.name = 'Infmag'
plugin.author = 'LOL'
plugin.description = 'The holy grail'

function minigun()
	
end
	
plugin.commands["/infmag"] = {
    info = "practice mode",
    canCall = function(ply) return ply.isAdmin end,
    call = function(ply, man, args)
        assert(man, "Not spawned in.")
        local itm = items.create(itemTypes[3], man.pos, orientations.s)
        if itm then
        man:mountItem(itm,0)
        itm.data.infMag = true
        end
    end,
}

plugin:addHook('Logic', function()
    for _, itm in ipairs(items.getAll()) do
        if itm.data.infMag then
            itm.bullets = 255
		end
	end
end)

Re: An infinite mag script

Posted: Thu Feb 15, 2024 9:40 pm
by olv
You seem to be doing an infinite chamber for the M-16 rather than an infinite mag, but otherwise this is pretty okay.
If you're looking to make it purchaseable in the World mode, you'd need a custom tab menu system if you're going for that, or a command to buy it; either way works.
Making a SQLite database is not hard at all. You can look up guides on the internet. ;)