NPC:OnPlayerText

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 05:51, 2 February 2014
1234567890 (Talk | contribs)
(removed title template)
← Previous diff
Current revision
Ikkentim (Talk | contribs)
(Added return value)
Line 10: Line 10:
{{Param|playerid|The player who has written something in the chat.}} {{Param|playerid|The player who has written something in the chat.}}
{{Param|text[]|The text written by ''playerid''.}} {{Param|text[]|The text written by ''playerid''.}}
 +
 +{{NoReturnCallback}}
<pawn> <pawn>

Current revision



NPC:OnPlayerText was added in SA-MP 0.3a This NPC callback was added in SA-MP 0.3a and will not work in earlier versions!


Image:32px-Circle-style-warning.png

Important
Note

For the player version of this callback, check OnPlayerText.


Description:

Opposed to the player version of this callback, this callback is called everytime anyone says anything in the chat. This includes any player, any other NPC, or the same NPC himself.


Parameters:
(playerid, text[])
playeridThe player who has written something in the chat.
text[]The text written by playerid.


Return Values:

This callback does not handle returns.


public OnPlayerText(playerid, text[])
{
    if (strfind(text, "stupid bot") != -1)
    {
        new string[80], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "Hey %s! Don't say those things! We, bots, are cool!", name);
        SendChat(string);
    }
    return 1;
}

Related Callbacks

The following callbacks might be useful as well, as they are related to this callback in one way or another.

In other languages