Player ID in front of Player Name?
#1

I'm trying to set a players name as (just as an example)
Quote:

(1) iPoisonxL

So, for example, if I was to talk, it'd go like this:
Quote:

(1) iPoisonxL: hi!

I tried using
Код:
SetPlayerName();
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;
}
Reply
#2

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
Reply
#3

... I know. I'm asking for a way to script this, not something I've read before.
Reply
#4

Add it under OnPlayerSpawn instead.
Reply
#5

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;
}
Reply
#6

Then what? It will show up for others like (id) name (id) above the player's head.
Reply
#7

I'm trying to set the number in front of their name in the chat.
Reply
#8

SetPlayerName also affects the name above their head, in case you didn't know.
Reply
#9

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
Reply
#10

From what you've said, you want to show the Player ID in front of the Name when he uses the chat, like this:

Quote:

(ID:0) MyName: hi all!

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...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)