concommand/Add

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
Line 15: Line 15:
 
|name=commandFunc
 
|name=commandFunc
 
|desc=The function to run when the concommand is executed.<br>
 
|desc=The function to run when the concommand is executed.<br>
Args: ( {{FuncArg|Entity|ply}}, {{FuncArg|string|cmd}}, {{FuncArg|table|args}}, {{FuncArg|string|fullstring}} )
+
Args: ( {{FuncArg|Player|ply}}, {{FuncArg|string|cmd}}, {{FuncArg|table|args}}, {{FuncArg|string|fullstring}} )
 
}}
 
}}
 
{{Arg
 
{{Arg

Revision as of 18:02, 4 December 2013

 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. 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 FCVAR_ Enums. 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)



Examples

Example

Adds a concommand 'to give yourself 200 hp.' --by PropGamer.

concommand.Add("get200hp",function( Player )
    Player:SetHealth( 200 )
    print("You have been given 200 hp!")
end)


Personal tools
Navigation