OnPlayerCommandText

From SA-MP Wiki

Revision as of 18:03, 5 September 2009; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

OnPlayerCommandText


This callback is called when a player enters a command into the client chat window, e.g. /help.


Parameters:
(playerid,cmdtext[])
playeridThe player who entered the command.
cmdtext[]The complete text entered, including the command and the /.
Returns0 - Command not processed, pass to another script or display "Unknown command"
Returns1 - 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.

Personal tools