Help with OnPlayerText -
Ercha - 01.01.2015
Hello guys, I'm having a little problem in OnPlayerText.. The thing is, that when a player types something in the chat, his name should be in Team color. Like for example if he's in USA team, he's nick color must be blue and only the nickname, not also the rest of the text what he types..
Here's the pic how it looks at the moment:
http://i.imgur.com/ozF7NlN.png
And the code:
Код:
new
hours,
minutes,
seconds,
str[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
gettime(hours, minutes, seconds);
format(str,sizeof(str),"[%02d:%02d:%02d] %s [%d]: %s",hours,minutes,seconds,PlayerName(playerid),playerid,text);
SendClientMessageToAll( -1, str); //
return 0; // Returning 0
Please give me a hint what do I have to change or add. I know it's very simple, but I always forget something..
Thanks!
Re: Help with OnPlayerText -
AndySedeyn - 01.01.2015
Use SetPlayerColor:
https://sampwiki.blast.hk/wiki/SetPlayerColor
Re: Help with OnPlayerText -
CalvinC - 01.01.2015
As you can see here, the -1 is color white.
pawn Код:
format(str,sizeof(str),"[%02d:%02d:%02d] %s [%d]: %s",hours,minutes,seconds,PlayerName(playerid),playerid,text);
SendClientMessageToAll( -1, str); //
Therefore it will send the message in white, use GetPlayerColor, and put it instead of -1.
You can always show the rest of the message in white if you want it by putting {FFFFFF} in the string format, whereever you want it to be white.
So replace the above with this.
pawn Код:
format(str,sizeof(str),"[%02d:%02d:%02d] %s [%d]: {FFFFFF}%s",hours,minutes,seconds,PlayerName(playerid),playerid,text);
SendClientMessageToAll(GetPlayerColor, str);
Or ofcourse remove the {FFFFFF} if you do not want white color after the name. This works with other colors too, as long as you put them inside such boxes: { }
Re: Help with OnPlayerText -
ATGOggy - 02.01.2015
This is from my script:
PHP код:
new playername[128], message[128];
GetPlayerName(playerid, playername, sizeof(playername));
format(message, sizeof(message), "{%06x}%s[%d]:{FFFFFF} %s", GetPlayerColor(playerid) >>> 8, playername, playerid, text);
SendClientMessageToAll(COLOR_WHITE, message);
You can edit it.