Help with custom ULX command

So I’m wanting to make a command that gives a player the item_ar2_grenade (This is for Prop Hunt)
I want it so when a player types !buy it will spawn them the grenade. And if they type !buy 3 it will spawn them 3 grenades.
I’ve tried to make a command that works but I suck at that stuff. I even tried taking other commands like ulx give and editing it to work, but still nothing.
I could really use a working code for this or at least some kind of template for me to work off of.
If not that, at least point me in the right direction to getting it made. I’m kinda new at this so I’d appreciate all the help I can get.

well first you’d start with a basic template like this:

function calling_ply, num )
	--put your code here for buying grenades

	ulx.fancyLogAdmin( calling_ply, "#A gaves themself #i grenades." num ) --remove this code to not echo to server


local buy = ulx.command( CATEGORY_NAME, "ulx buy",, "!buy" )
buy:addParam{ type=ULib.cmds.NumArg, min=1, max=3, default=1, hint="Number of nades", ULib.cmds.optional, ULib.cmds.round }
buy:defaultAccess( ULib.ACCESS_USER)
buy:help( "Buys items" )

Notice that the minimum and default are 1, with the maximum buy amount being 3. Set these to what you want.

As for buying, I’ll leave that up to you :slight_smile:
Try looking at these:

remember that while the wiki gives examples of the default code, this is how hooks are added:

hook.Add( "HookNameHere", "YourUniqueNameForThisHook", function( func, args, go, here )

    --what do you want to do when the hook runs

end )