Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sam.command.set_category("any_nameee") -- any new command will be in that category unless the command uses :SetCategory function
- sam.command.new("command_name")
- :SetPermission("hp", "admin") -- OR "superadmin" OR "user" OR remove the second argument for no default access OR just remove that line to make it for everyone!
- :DisallowConsole() -- disallow the console from running this command!
- :SetCategory("Fun") -- set the category for the command, or you can use sam.command.set_category function to set the category for any upcoming commands
- :Help("This is helpful!")
- :GetRestArgs(true) -- allows to get the rest of text, something like !ban he is a really bad boi, by default you have to do !ban "he is a really bad boi"
- :MenuHide(true) -- hide this command from the menu
- :DisableNotify(true) -- hide <PLAYER(PLAYER_STEAMID)> ran command stuff in server console, useful for something like !menu command
- :AddArg("player", {
- optional = true, -- makes it target the player who is calling if there is no input, like !god (MAKE SURE TO MAKE IT THE ONLY ARGUMENT)
- single_target = true, -- only targets one player
- cant_target_self = true, -- disallow the player who is calling to target himself
- allow_higher_target = true, -- allow the player who is calling to target anyone, admin -> superadmin, useful for commands like !goto
- })
- :AddArg("text", {
- optional = true, -- makes it optional!
- default = 50, -- add a default amount if there was no input!
- hint = "name", -- ummmm?
- check = function(input, ply)
- if not is_good_input(input) then
- return false
- end
- end, -- this gets called to see if the input of this argument is valid
- })
- :AddArg("number", {
- optional = true, -- makes it optional!
- default = 50, -- add a default amount if there was no input!
- hint = "amount", -- ummmm?
- min = 100, -- input < 100 then the input gonna be 100
- max = 200, -- input > 200 then the input gonna be 200
- round = true, -- numbers like 1.5, 1.4, 1.2 gets rounded
- })
- :AddArg("length")
- -- arrays https://www.lua.org/pil/11.1.html
- :OnExecute(function(calling_ply --[[the player who called this command]], targets --[[this will always be an array (https://www.lua.org/pil/11.1.html) ]], name, amount, length)
- for i = 1, #targets do
- local target = targets[i]
- -- do something with him --
- end
- sam.player.send_message(nil --[[this is like player.GetAll(), you can use an array of players or a player]], "Admin {A} targeted {T} with amount {V}, name {V_2} and length {V_3}", {
- A = calling_ply, T = targets, V = amount, V_2 = name, V_3 = length
- })
- end)
- :End()
- sam.command.new("do_something_with_steamid")
- :AddArg("steamid") -- passes a promise
- :AddArg("steamid", {allow_higher_target = true}) -- passes steamid
- :OnExecute(calling_ply, function(promise, steamid_2)
- -- if you set "allow_higher_target" to true then the argument will be a promise otherwise it will be a steamid
- -- it needs to be done this way because I need to check if the player can target the steamid, so admins can't ban superadmins (eg. !banid "<steamid_with_higher_immunity>"
- promise:done(function(data)
- local steamid, target = data[1], data[2] -- target will be "nil" if player is not online
- end)
- end)
- :End()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement