Update Player label Problem?
#1

There goes my code.
pawn Код:
command(setlabel,playerid,params[])
{
new text[32];
if(sscanf(params,"s[32]",text))
return ShowInfo(playerid,"~r~USAGE: ~p~/sml [text]~n~~b~Will set a text above your head!");
new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    format(string,sizeof(string),"%s",text);
label=Create3DTextLabel(string,0xC8C8C8FF,x,y,z,40.0,0,1);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.4);
UpdatePlayer3DTextLabelText(playerid,PlayerText3D:label,0xC8C8C8FF,text);
format(string,sizeof(string),"Label set to ~b~%s~w~!",text);
ShowInfo(playerid,string);
    return 1;
    }
But the label does not update, it mixes with the previous label.
I can't figure out what am I doing wrong, can you?
Any help will be highly appreciated, thank you in advance!
Reply
#2

pawn Код:
new Text3D:PlayerLabel[MAX_PLAYERS];
OnPlayerConnect
pawn Код:
PlayerLabel[playerid] = Create3DTextLabel(" ",0xC8C8C8FF,0,0,0,40.0,0,1);
Attach3DTextLabelToPlayer(PlayerLabel[playerid], playerid, 0.0, 0.0, 0.4);
OnPlayerDisconnect
pawn Код:
Delete3DTextLabel(PlayerLabel[playerid]);
pawn Код:
command(setlabel,playerid,params[])
{
    new text[32];
    if(sscanf(params,"s[32]",text))
        return ShowInfo(playerid,"~r~USAGE: ~p~/sml [text]~n~~b~Will set a text above your head!");
    Update3DTextLabelText(PlayerLabel[playerid],0xC8C8C8FF,text);
    format(string,sizeof(string),"Label set to ~b~%s~w~!",text);
    ShowInfo(playerid,string);
    return 1;
}
Reply
#3

Still the same thing...
Reply
#4

Код:
new Text3D:PlayerLabel[MAX_PLAYERS];
OnPlayerConnect
Код:
PlayerLabel[playerid] = Create3DTextLabel(" ",0xC8C8C8FF,0,0,0,40.0,0,1);
Attach3DTextLabelToPlayer(PlayerLabel[playerid], playerid, 0.0, 0.0, 0.4);
OnPlayerDisconnect
Код:
Delete3DTextLabel(PlayerLabel[playerid]);
Код:
command(setlabel,playerid,params[])
{
    new text[32];
    if(sscanf(params,"s[32]",text))
        return ShowInfo(playerid,"~r~USAGE: ~p~/sml [text]~n~~b~Will set a text above your head!");
    Delete3DTextLabel(PlayerLabel[playerid]);
    PlayerLabel[playerid] = Create3DTextLabel(text,0xC8C8C8FF,0,0,0,40.0,0,1);
    format(string,sizeof(string),"Label set to ~b~%s~w~!",text);
    ShowInfo(playerid,string);
    return 1;
}
Updating the label will overwrite the player's label. To update the label it is better to delete and recreate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)