Getting a players name? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Getting a players name? (
/showthread.php?tid=554304)
Getting a players name? -
Th3UnKnOwN - 03.01.2015
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;
}
Re: Getting a players name? -
Sledgehammer - 03.01.2015
pawn Код:
SendClientMessageToAll(-1 ,string);
SendClientMessagetToAll(color, string[]);
-1 = White.
Re: Getting a players name? -
UploaD - 03.01.2015
Look at the function SendClientMessageToAll - you're using the parameter -1 (default color) that is same as white color.
EDIT: Too late
Re: Getting a players name? -
Th3UnKnOwN - 03.01.2015
I have two teams
each team has a color... HOW DO I GET IT!!! Not how to change the color. I know that.
Re: Getting a players name? -
SickAttack - 03.01.2015
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");
Re: Getting a players name? -
ATGOggy - 03.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);
Re: Getting a players name? -
Th3UnKnOwN - 03.01.2015
Thank you SickAttack, and ATGOggy. You two we're the only ones who could actually understand what the issue was.