3DPlayerLabel Problem
#1

Heey all,
I made a rank system with labels above head.
I am rank 21 and new players are rank 0.
But when they are in game they have the rank 21 label. I made the label at onplayerupdate.
Code:
Код:
if(ranklvl[playerid]==0)
			{
			new string[50];
			format(string,sizeof(string),"XP:%d/25",GetPlayerScore(playerid));
			TextDrawSetString(ys[playerid],string);
   			ranklabel[playerid] = Create3DTextLabel("Private(0)!", lred, 30.0, 40.0, 50.0, 40.0, 0);
		    Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.5);
			}
if(ranklvl[playerid]==21)
			{
			new string[50];
			format(string,sizeof(string),"XP:%d/25000",GetPlayerScore(playerid));
			TextDrawSetString(ys[playerid],string);
			ranklabel[playerid] = Create3DTextLabel("Commander Of Army(21)!", lred, 30.0, 40.0, 50.0, 40.0, 0);
		    Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.5);
			}
Reply
#2

Why if player is ranklevel 0 he have rank commander of war?
I checked the ini file and i see the player is ranklevel 0.
Reply
#3

Does this works?
pawn Код:
if(ranklvl[playerid]==0)
            {
            new string[50];
            format(string,sizeof(string),"XP:%d/25",GetPlayerScore(playerid));
            TextDrawSetString(ys[playerid],string);
            ranklabel[playerid] = Create3DTextLabel("Private(0)!", lred, 30.0, 40.0, 50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.5);
            }
            else
if(ranklvl[playerid]==21)
            {
            new string[50];
            format(string,sizeof(string),"XP:%d/25000",GetPlayerScore(playerid));
            TextDrawSetString(ys[playerid],string);
            ranklabel[playerid] = Create3DTextLabel("Commander Of Army(21)!", lred, 30.0, 40.0, 50.0, 40.0, 0);
            Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.5);
            }
Reply
#4

I'm pretty sure you got confused with label[playerid] and ranklabel[playerid].
Reply
#5

I need to change to update3dtextlabel?
Reply
#6

delete player 3d text FIRST! and use a timer not OnPlayerUpdate o.o
btw you dont need a timer just create a label on playerconnect and use update3dtextlabel on a kill or whatever and delte the label on death / disconnect
Reply
#7

Try something like this:

pawn Код:
//Global:
new Text3D:scorelabel[MAX_PLAYERS];

//OnPlayerSpawn (Lag-less and better)
    new textstring[64];
    switch(GetPlayerScore(playerid))
    {
        case 0 .. 49: format(textstring, sizeof textstring, "Newbie - XP: %i/50", GetPlayerScore(playerid) );
        case 50 .. 499: format(textstring, sizeof textstring, "Amateur - XP: %i/500", GetPlayerScore(playerid) );
        case 500 .. 999: format(textstring, sizeof textstring, "Pro - XP: %i/1000", GetPlayerScore(playerid) );
    }
    Delete3DTextLabel(scorelabel[playerid]);
    scorelabel[playerid] = Create3DTextLabel( textstring, GetPlayerColor(playerid), 0,0,0, 50, 0, true);
    Attach3DTextLabelToPlayer(scorelabel[playerid], playerid, 0, 0, 0.5);
And Yes, If you wan't to use it on timer or something, use the switch method and format string then Update the 3d label.
Reply
#8

He dont want with score,he wants with rank names.
Reply
#9

Now i dont see labels:S
Reply
#10

This can work?:
onplayerspawn:
Код:
if(GetPlayerScore(playerid)>= 0 && GetPlayerScore(playerid)<24)
{
Update3DTextLabel(ranklabel,lred,"Private(0)");
}
if(GetPlayerScore(playerid)>= 25 && GetPlayerScore(playerid)<49)
{
Update3DTextLabel(ranklabel,lred,"Private First Class(1)");
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)