concommand.Add

From Garry's Mod
Revision as of 17:51, 13 June 2013 by Robotboy655 (Talk | contribs)
Jump to: navigation, search
 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: ( Entity ply or NULL if console, string cmd, table args, string fullstring )

Arguments

function autoCompleteFunc=nil

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

Args: ( string cmd, string args )

Arguments

string helpText=nil

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

Arguments

number flags=0

Concommand flags from Template:EnumLink. Optional.

Examples

Example

Adds a concommand 'printnick' which will print the user's name to console

concommand.Add("printnick",function(ply,cmd,args,str)
    print("Concommand printnick has been used by: "..ply:Nick())
end)


Examples

Example

Adds a concommand 'killyourself' which will kill the user. --by Devul. 13:47, 13 March 2013 (UTC)

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


Personal tools
Navigation