Checking for arguments

How would i make this take an argument? examble

cash_add in console it would add what i typed after etc, cash_add 5000 i would get 5000? how would i make that?

[editline]30th September 2014[/editline]

i already have money system ( customg amemode)

Read the wiki page
It tells you the callback function is passed these args:

[lua]concommand.Add( “cash_add”, function( ply, _, args )

local cash = args[1] -- First argument would be cash

-- Run code

end )[/lua]

Try this.

[lua]concommand.Add(“cash_add”, function(player, command, arguments)
if (!player:IsSuperAdmin()) then return end

  local cash = tonumber(arguments[1])

  if (cash) then
        -- Use the player and cash variables to give the player the money.


Make sure you’re adding the command serverside and not clientside.

I am putting in init.lua which is server side right?

[editline]30th September 2014[/editline]

I did this:

function DebugGiveMoney( ply, arguments )
local giveamount = tonumber(arguments[1])

	if (giveamount) then

concommand.Add("cash_add", DebugGiveMoney)


No errors when i do cash_add 500 but i dont get any money at all?

You can’t just ignore some arguments. You removed ‘commands’ it needs to be there.

I recommend reading this

Thanks so much! I love facepunch already and i nearly just started using it alot! People will help alot usually :slight_smile: THanks for the link ill look at it tomorrow gotta go now though.

You really should check if they’re superadmin, though. This could easily be abused.