concommand/Add

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Removed Optional text)
Line 21: Line 21:
 
|name=autoCompleteFunc
 
|name=autoCompleteFunc
 
|desc=The function to call which should return a table of options for autocompletion.<br>
 
|desc=The function to call which should return a table of options for autocompletion.<br>
 +
This only properly works on the client since it is '''not''' networked.<br>
 
Args: ( {{FuncArg|string|cmd}}, {{FuncArg|string|args}} )
 
Args: ( {{FuncArg|string|cmd}}, {{FuncArg|string|args}} )
 
|default=nil
 
|default=nil

Revision as of 22:59, 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.
This only properly works on the client since it is not networked.

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