Name tag
#1

Well, I want to do in my script like: if a player is donating player so i want There should "Donating player" on his head. (upto name tag).

Well, How can i?
Reply
#2

When a player connects and his stats are loaded, check if he's a donator and attach a 3D text to his head (get the player's position and add about 0.5 to the player's Z [height] coordinate). Don't forget to delete the created label when the donator disconnects.
Reply
#3

Yeah i know that but i need some codes to understand with explanation. I would be your thankful if you explain with a little bit of codes.
Reply
#4

Here is everything you need
https://sampwiki.blast.hk/wiki/Attach3DTextLabelToPlayer
Reply
#5

Quote:

new Text3D:VIPtag[MAX_PLAYERS]; //somewhere in the script

//under onplayerspawn
if(PlayerAcc[playerid][Vip] >= 1)/// replace this code with your
{
new Text3D:VIPtag = Create3DTextLabel("Donating player", COLOR_ORANGE, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(VIPtag, playerid, 0.0, 0.0, 0.7);
}

you mean like this?
Reply
#6

Well, where to put this?
PHP код:
if(pData[playerid][pDonator] == 1
    {
        new 
Text3D:label Create3DTextLabel("Donating Player"RED30.040.050.040.00);
        
Attach3DTextLabelToPlayer(labelplayerid0.00.00.7);
        return 
1;
    } 
I placed it onplayerconnect but its not showing "donating player" above player's head.
Reply
#7

put it under onplayerspawn
Reply
#8

VIPtag[playerid]? VIPTAG? should i write pdonator[playerid] ?
Reply
#9

aw, put this under onplayerdisconnect
Quote:

Delete3DTextLabel(Label[playerid]);

Reply
#10

It's not showing because you set the coordinates wrong. You must attach it to player's current coordinates with a little boost of Z coordinate:

pawn Код:
new Float: posX, Float: posY, Float: posZ;
       
    GetPlayerPos (playerid, posX, posY, posZ);
               
    new Text3D:label = Create3DTextLabel("Donating Player", RED, posX, posY, posZ + 0.5, 40.0, 0);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
Anyway, doing it this way, you won't be able to delete the text when a donator disconnects. In order to fix this, you need to create a global array:

pawn Код:
new Text3D:donatorText[MAX_PLAYERS];

    <..> when a donator connects

    new Float: posX, Float: posY, Float: posZ;
       
    GetPlayerPos (playerid, posX, posY, posZ);

    donatorText [playerid] = Create3DTextLabel ("Donating Player", RED, posX, posY, posZ + 0.5, 40.0, 0);
    Attach3DTextLabelToPlayer (donatorText [playerid], playerid, 0.0, 0.0, 0.7);

    <...> when a donator disconnects

    Delete3DTextLabel (donatorText [playerid]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)