concommand.Add

From Garry's Mod
Revision as of 13:53, 13 March 2013 by Devul (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, passed the args (ply or NULL if console, name of cmd, args table, fullstring)

Arguments

function autoCompleteFunc

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

Arguments

string helpText

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

Arguments

number flags

Concommand flags from Template:EnumLink

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