🟪Command:add_arg

Command Command:add_arg( string argument_name, (optional) table data = {} )

Description

Adds argument to be used with the command.

Aguments

  1. string argument_name

  2. (optional) table data = {}

    data table is used for arguments to know how it should work, check examples.

Returns

Example

local kick_command = sam.Command.get("kick")
kick_command:add_arg("text", {
    -- optional field is used by core to know if this command is optional or not
    optional = true,
    
    -- text argument has these options:
    -- hint : string : defaut = "text"
    -- check : bool function(input: string, player: Player)
    hint = "meow meoew hint",
    check = function(ply_input, ply)
        return ply_input == "true"
    end
})

Last updated