25.10.2017, 08:03
Quote:
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 |
Код:
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; }
Код:
OnPlayerText(playerid, text[]) { ReplaceIDWithName(playerid, text); return 1; }
If u will type in chat "Welcome ID 10 to server", this will convert text to "Welcome PlayerNameID10 to server".