Player ID in front of Player Name? -
iPoisonxL - 03.07.2013
I'm trying to set a players name as (just as an example)
So, for example, if I was to talk, it'd go like this:
I tried using
but it doesn't work in OnPlayerConnect() callback apparently. Or am I just not using it right?
pawn Код:
new namelogon[100];
new newplayername[100];
public OnPlayerConnect(playerid)
{
new logonmsg[100];
GetPlayerName(playerid, namelogon, sizeof(namelogon));
format(newplayername, sizeof(newplayername), "(%d) %s", playerid, namelogon);
SetPlayerName(playerid, newplayername); //here i try to set the player name
format(logonmsg, sizeof(logonmsg), "(%d) %s has joined the server. Say hi!", playerid, namelogon);
SendClientMessageToAll(GREEN, logonmsg);
return 1;
}
Re: Player ID in front of Player Name? -
shadowdog - 03.07.2013
Samp wiki:
Important Note: If you set the player's name to the same name except different cased letters (i.e. "heLLO" to "hello"), it will not work.
If used in OnPlayerConnect, the new name will not be shown for the connecting player.
Also, names can only be up to 24 characters, defined as MAX_PLAYER_NAME
Re: Player ID in front of Player Name? -
iPoisonxL - 03.07.2013
... I know. I'm asking for a way to script this, not something I've read before.
Re: Player ID in front of Player Name? -
BigGroter - 03.07.2013
Add it under OnPlayerSpawn instead.
Re: Player ID in front of Player Name? -
iPoisonxL - 04.07.2013
That still didn't work. Here's the code in case you're wondering what I'm doing wrong.
pawn Код:
public OnPlayerSpawn(playerid)
{
[B]new newplayername[MAX_PLAYER_NAME+4];
GetPlayerName(playerid, newplayername, sizeof(newplayername));
format(newplayername, sizeof(newplayername), "(%d) %s", playerid, newplayername);
SetPlayerName(playerid, newplayername);[/B]
return 1;
}
Re: Player ID in front of Player Name? -
Vince - 04.07.2013
Then what? It will show up for others like
(id) name (id) above the player's head.
Re: Player ID in front of Player Name? -
iPoisonxL - 04.07.2013
I'm trying to set the number in front of their name in the chat.
Re: Player ID in front of Player Name? -
Vince - 04.07.2013
SetPlayerName also affects the name above their head, in case you didn't know.
Re: Player ID in front of Player Name? -
RedFusion - 04.07.2013
pawn Код:
public OnPlayerText(playerid, text[])
{
new name[MAX_PLAYER_NAME+1], msg[128];
GetPlayerName(playerid, name, sizeof(name));
format(msg, sizeof(msg), "[%02d] %s: {FFFFFF}%s", playerid, name, text);
SendClientMessageToAll(GetPlayerColor(playerid), msg);
return 0;
}
https://sampwiki.blast.hk/wiki/OnPlayerText
Re: Player ID in front of Player Name? -
TheMaxXx - 04.07.2013
From what you've said, you want to show the Player ID in front of the Name when he uses the chat, like this:
If that's what you want, then just use this:
pawn Код:
public OnPlayerText(playerid, text[])
{
new ReturnS[148], HisNameIs[MAX_PLAYER_NAME];
GetPlayerName(playerid, HisNameIs, MAX_PLAYER_NAME);
format(ReturnS, 148, "(ID:%d) %s: %s", playerid, HisNameIs, text);
SendClientMessageToAll(-1, ReturnS);
return 0;
}
// Not Tested, but it should work...