Getting a players name?
#1

Hey, When I use this code to add the players ID to the chat next to their name. No matter what the players color is, it always appears white. How would I make it get the players name color and use it instead of white for all players?

pawn Код:
public OnPlayerText(playerid, text[])
{
    new Name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, Name,sizeof(Name));
    format(string,sizeof(string),"%s(%i): %s",Name,playerid,text);
    SendClientMessageToAll(-1 ,string);
    return 0;
}
Reply
#2

pawn Код:
SendClientMessageToAll(-1 ,string);
SendClientMessagetToAll(color, string[]);
-1 = White.
Reply
#3

Look at the function SendClientMessageToAll - you're using the parameter -1 (default color) that is same as white color.

EDIT: Too late
Reply
#4

I have two teams
each team has a color... HOW DO I GET IT!!! Not how to change the color. I know that.
Reply
#5

Here are two ways of doing this:

pawn Код:
new string[144];
format(string, sizeof(string), "{%06x}TEXT HERE", GetPlayerColor(playerid) >>> 8);
SendClientMessageToAll(-1, string);

SendClientMessageToAll(GetPlayerColor(playerid), "TEXT HERE");
Reply
#6

This is from my script:
PHP код:
new playername[128], message[128];
GetPlayerName(playeridplayernamesizeof(playername));
format(messagesizeof(message), "{%06x}%s[%d]:{FFFFFF} %s"GetPlayerColor(playerid) >>> 8playernameplayeridtext);
SendClientMessageToAll(COLOR_WHITEmessage); 
Reply
#7

Thank you SickAttack, and ATGOggy. You two we're the only ones who could actually understand what the issue was.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)