concommand/Add

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Fixed up. There's no reason to have 3 examples that show the exact same thing.)
m (Removed Optional text)
Line 20: Line 20:
 
|type=function
 
|type=function
 
|name=autoCompleteFunc
 
|name=autoCompleteFunc
|desc=The function to call which should return a table of options for autocompletion. Optional.<br>
+
|desc=The function to call which should return a table of options for autocompletion.<br>
 
Args: ( {{FuncArg|string|cmd}}, {{FuncArg|string|args}} )
 
Args: ( {{FuncArg|string|cmd}}, {{FuncArg|string|args}} )
 
|default=nil
 
|default=nil
Line 27: Line 27:
 
|type=string
 
|type=string
 
|name=helpText
 
|name=helpText
|desc=The text to display should a user run 'help cmdName'. Optional.
+
|desc=The text to display should a user run 'help cmdName'.
 
|default=nil
 
|default=nil
 
}}
 
}}
Line 33: Line 33:
 
|type=number
 
|type=number
 
|name=flags
 
|name=flags
|desc=Concommand flags from {{Enum|FCVAR}}. Optional.
+
|desc=Concommand flags from {{Enum|FCVAR}}.
 
|default=0
 
|default=0
 
}}
 
}}

Revision as of 22:57, 23 February 2014

 concommand.Add( )

Contents

Description

Creates a console command that runs a function in lua with optional autocompletion function and help text.

Arguments

string name

The command name to be used in console.

Arguments

function commandFunc

The function to run when the concommand is executed.

Args: ( Player ply , string cmd , table args , string fullstring )

Arguments

function autoCompleteFunc=nil

The function to call which should return a table of options for autocompletion.

Args: ( string cmd , string args )

Arguments

string helpText=nil

The text to display should a user run 'help cmdName'.

Arguments

number flags=0

Concommand flags from FCVAR_ Enums.

Examples

Example

Adds a concommand 'killyourself' which will kill the user.

concommand.Add("killyourself",function( ply )
    ply:Kill()
    print("You killed yourself!")
end)


Personal tools
Navigation