Attach3DTextLabelToPlayer
#1

I'm trying to show player's ID above their head, but something is terribly wrong. Nothing is appearing so I guess the problem is within those coordinates?

pawn Код:
public OnPlayerConnect(playerid)
{
    new
        string[32],
        name[MAX_PLAYER_NAME],
        Text3D:label = Create3DTextLabel(string, White, 30.0, 40.0, 50.0, 40.0, 0);
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "ID: %i", GetPlayerID(name));
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
    return 1;
}
pawn Код:
stock GetPlayerID(const name[])
{
    new pName[MAX_PLAYER_NAME];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        GetPlayerName(i, pName, MAX_PLAYER_NAME);
        if(!strcmp(pName, name))
            return i;
    }
    return INVALID_PLAYER_ID;
}
Reply
#2

Don't try and do this, attaching 3d labels is very buggy.
Reply
#3

You have the player's ID already, why would you get their name from their ID and then do vice versa?

pawn Код:
public OnPlayerConnect(playerid)
{
    new string[32];
    format(string, sizeof(string), "ID: %i", playerid);
    Attach3DTextLabelToPlayer(Create3DTextLabel(string, White, 30.0, 40.0, 50.0, 40.0, 0), playerid, 0.0, 0.0, 0.7);
    return 1;
}
Reply
#4

Lol you're right. Thanks.

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Don't try and do this, attaching 3d labels is very buggy.
I read that chat bubbles are even worse because they need timers?
Reply
#5

Chat bubbles are built directly into SAMP.

https://sampwiki.blast.hk/wiki/SetPlayerChatBubble
Reply
#6

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Chat bubbles are built directly into SAMP.

https://sampwiki.blast.hk/wiki/SetPlayerChatBubble
Chat bubbles have expire time, I need a permanent one.
Reply
#7

pawn Код:
public OnPlayerSpawn(playerid)
{
    new
        string[32],
        Text3D:label = CreateDynamic3DTextLabel(string, White, 0, 0, 0.1, 10, playerid, INVALID_VEHICLE_ID, -1, -1 ,-1, -1);
    format(string, sizeof(string), "Player's ID: %i", playerid);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.1);
    return 1;
}
Still not appearing. Appears trough a command, but that's not the point.
Reply
#8

Use this at onplayerupdate.

https://sampwiki.blast.hk/wiki/CreatePlayer3DTextLabel

pawn Код:
new PlayerText3D:label;
// check here if the player is near the player that has the label, if not it wont show for him,  else it will.
// if the player is near him:
label = CreatePlayer3DTextLabel(playerid, ....);
// else destroy it.
Reply
#9

I'm using a streamer. I tried placing the code under OnPlayerUpdate and it still won't show up.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)