OnPlayerText
#4

Quote:
Originally Posted by MasterCodez
Посмотреть сообщение
How i can replace word into playername like this example below

ID 0: PlayerName1
ID 1: PlayerName2

PlayerName2: Welcome id 0 to server >> replace to >> Welcome PlayerName1 to server
Try this. This function will replace the ID X in name of player and the message will be send to all players.

Код:
forward ReplaceIDWithName(playerid, text[]);
public ReplaceIDWithName(playerid, text[])
{
       new string[10];
       foreach(new i : Player) //If u use YSI or foreach(Player, i) if not.
       {
              format(string, sizeof(string), "ID %d", playerid);
              if(strfind(text, string, true) != -1)
              {
                     new PlayerName[MAX_PLAYER_NAME];
                     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
                     strreplace(text, string, PlayerName);
                     SendClientMessageToAll(playerid, text);
                     return 1;
              }
       }
       return 1;
}
How to use?

Код:
OnPlayerText(playerid, text[])
{
       ReplaceIDWithName(playerid, text);
       return 1;
}
Also for strreplace u can use https://sampforum.blast.hk/showthread.php?tid=362764 posted by Slice


If u will type in chat "Welcome ID 10 to server", this will convert text to "Welcome PlayerNameID10 to server".
Reply


Messages In This Thread
OnPlayerText - by MasterCodez - 25.10.2017, 04:58
Re: OnPlayerText - by maksicnm - 25.10.2017, 06:08
Re: OnPlayerText - by MasterCodez - 25.10.2017, 06:27
Re: OnPlayerText - by kingmk - 25.10.2017, 08:03
Re: OnPlayerText - by MasterCodez - 25.10.2017, 09:39
Re: OnPlayerText - by Danisoni - 25.10.2017, 10:03

Forum Jump:


Users browsing this thread: 1 Guest(s)