Onplayertext - help
#1

Hi! I wonder, how do I change what the player writes.
Example:

Quote:

SA_MP say: Hi to all!

Change to
Quote:

SA_MP to say: '[anything]'

is only an example,Can someone help me? Thanks!
Reply
#2

return 0 on OnPlayerText, get the players name, format the message in a string, and send it to everyone using SendClientMessageToAll.
Reply
#3

How i format the message in a string?
Reply
#4

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        playerName[MAX_PLAYER_NAME],
        string[128]
    ;
       
    GetPlayerName(playerid, playerName, sizeof(playerName));
   
    format(string, sizeof(string), "%s to say: [anything]", playerName);
    SendClientMessageToAll(0xFFFFFFFF, string);
    return 0;
}
Will make them literally say

PLAYERNAME to say: [anything]
every time they speak, but if I didn't read correctly and you just want them "to say:" then..

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        playerName[MAX_PLAYER_NAME],
        string[128]
    ;
       
    GetPlayerName(playerid, playerName, sizeof(playerName));
   
    format(string, sizeof(string), "%s to say: %s", playerName, text);
    SendClientMessageToAll(0xFFFFFFFF, string);
    return 0;
}
Reply
#5

Okay! Very Thanks +REP (can close the topic)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)