New cider command

Hello, I am coding a cider gamemode and i have decided to make a command but i am having trouble coding it. The command is used to refund players with money if the server crashes or gets restarted.
So I want it working as this:
/refund <name of player> <amount>

I made this code, but it doesn’t work:



-- A command to give money to a player
cider.command.add("refund", "s", 2, function(player, arguments)
	local target = cider.player.get( arguments[1] )
	local amount = cider.player.giveMoney( arguments[2] )
	if (target) then
	target:cider.player.giveMoney(target, amount);
		end;
end, "Super Admin Commands", "<player> <amount>", "Give refund cash to a player.");


Can someone help me with this? Thanks

I recommend just forcing the server to save with a simple timer like:
[lua]
timer.Create( “Weeesavetimer”, 60, 0, function( blargh ) --bleh end )
[/lua]
**[Timer.Create

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Timer.Create)**

Thanks for the code but I want to give with this command the player manually money.

So when I do /refund <name of player> <amount>, a player will get the specified amount of money.

Yes because people wont abuse that

I think you don’t get the point, it’s an admin command to refund people after a server crash. And my admins are not abusers ofcourse. :stuck_out_tongue:

Anyone that can help me?

why do you have a comma at the last “end” ?

Also, why do you just write “Super Admin Commands”, “<player> <amount>”, “Give refund cash to a player.”); in the last line?

Makes no sense to me :confused:

yeah, and why did you put cider.command.add(“refund”, “s”, 2, infront of it and what’s up with the function definition not having a name?
You’re not trying to call a function with an inline function as one of the arguments or something are you???

On topic, your code is not working because cider.player.giveMoney() takes a player and a number as it’s arguments and you’re giving it a string and nothing else on line 4 for no apparent reason.
Along the same seam, line 6 is wrong. I’ve no idea what you thought you were doing, but remove the ‘target:’ from it.

Thank you Lexic, I got it to work now.