SA-MP Forums Archive
Update Player label Problem? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Update Player label Problem? (/showthread.php?tid=230532)



Update Player label Problem? - [MWR]Blood - 23.02.2011

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!


Re: Update Player label Problem? - MadeMan - 23.02.2011

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;
}



Re: Update Player label Problem? - [MWR]Blood - 24.02.2011

Still the same thing...


Re: Update Player label Problem? - deather - 24.02.2011

Код:
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.