OnPlayerCommandText
From SA-MP Wiki
(Difference between revisions)
Revision as of 20:23, 19 October 2013 Badio12 (Talk | contribs) ← Previous diff |
Revision as of 21:35, 31 January 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 1: | Line 1: | ||
{{Scripting}} | {{Scripting}} | ||
- | {{Title}} | ||
{{Description|This callback is called when a player enters a command into the client chat window, e.g. /help.}} | {{Description|This callback is called when a player enters a command into the client chat window, e.g. /help.}} | ||
Line 35: | Line 34: | ||
[[Category:Scripting Callbacks]] | [[Category:Scripting Callbacks]] | ||
- | [[pt:OnPlayerCommandText]] | ||
[[de:OnPlayerCommandText]] | [[de:OnPlayerCommandText]] | ||
+ | [[fr:OnPlayerCommandText]] | ||
+ | [[pt:OnPlayerCommandText]] | ||
[[ru:OnPlayerCommandText]] | [[ru:OnPlayerCommandText]] | ||
[[pl:OnPlayerCommandText]] | [[pl:OnPlayerCommandText]] |
Revision as of 21:35, 31 January 2014
Description:
This callback is called when a player enters a command into the client chat window, e.g. /help.
(playerid, cmdtext[])
playerid | The ID of the player that executed the command. |
cmdtext[] | The command that was executed (including the slash). |
Return Values:
0 if the command was not processed, otherwise 1.
public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp(cmdtext, "/help", true)) { SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: This is the /help command!"); return 1; // Returning 1 informs the server that the command has been processed. // OnPlayerCommandText won't be called in other scripts. } return 0; // Returning 0 informs the server that the command hasn't been processed by this script. // OnPlayerCommandText will be called in other scripts until one returns 1. // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown. }
Related Callbacks
The following callbacks might be useful as well, as they are related to this callback in one way or another.
- OnPlayerText: Called when a player sends a message via the chat.
- OnRconCommand: Called when an RCON command is sent.
Related Functions
The following functions might be useful, as they're related to this callback in one way or another.
- SendRconCommand: Sends an RCON command via the script.