OnPlayerCommandText
From SA-MP Wiki
OnPlayerCommandText
This callback is called when a player enters a command into the client chat window, e.g. /help.
(playerid,cmdtext[])
| playerid | The player who entered the command. |
| cmdtext[] | The complete text entered, including the command and the /. |
| Returns | 0 - Command not processed, pass to another script or display "Unknown command" |
| Returns | 1 - Command processed, does not get passed to other scripts. |
public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp(cmdtext, "/help", true)) { SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: This is the /help command!"); return true; /* Return 'true' OR '1' is used to notify the server that the command has successfully been processed. If you return true here you won't get that 'SERVER: Unknown Command.', and any conflicts will be avoided. */ } return false; /* Return 'false' OR '0' is used to inform the server that the command has not been successfully processed, and passes it to other scripts. If there hasn't been a successful process, then you will get that 'SERVER: Unknown Command.' error. */ }
Related Callbacks
The following callbacks might be useful as well, as they're related to this callback in one way or another.
- OnPlayerText: Called when a player sends a message via the chat.
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.
- OnRconCommand: Called when an RCON command is sent.
