concommand/Add

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added link)
Line 22: Line 22:
 
|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>
 
This only properly works on the client since it is '''not''' networked.<br>
 +
[[Autocomplete Tutorial|Autocompletion Tutorial]]
 
Args: ( {{FuncArg|string|cmd}}, {{FuncArg|string|args}} )
 
Args: ( {{FuncArg|string|cmd}}, {{FuncArg|string|args}} )
 
|default=nil
 
|default=nil

Revision as of 12:51, 26 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.
Autocompletion Tutorial

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