AddCommand: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|AddCommand(CommandName, LuaFunction)}} {{FuncParameters}} {{FuncParam|CommandName|__EDIT_ME__}} {{..." |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Adds a command that can be executed with the prefix '''/'''.}} | ||
{{FuncSyntax|AddCommand(CommandName, LuaFunction)}} | {{FuncSyntax|AddCommand(CommandName, LuaFunction)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|CommandName| | {{FuncParam|CommandName|The specified command name.}} | ||
{{FuncParam|LuaFunction| | {{FuncParam|LuaFunction|The function name.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|None.}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua> | |||
function cmd_commands(playerid) | |||
AddPlayerChat(playerid, "You just executed a command!") | |||
return | |||
end | |||
AddCommand("commands", cmd_commands) | |||
AddCommand("cmds", cmd_cmds) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
__EDIT_ME__ | __EDIT_ME__ |
Revision as of 14:46, 17 November 2019
Description
Adds a command that can be executed with the prefix /.
Syntax
AddCommand(CommandName, LuaFunction)
Parameters
- CommandName
The specified command name. - LuaFunction
The function name.
Return Value
- None.
Example
function cmd_commands(playerid)
AddPlayerChat(playerid, "You just executed a command!")
return
end
AddCommand("commands", cmd_commands)
AddCommand("cmds", cmd_cmds)
See also
__EDIT_ME__