Removing 3D label from player -
Mattakil - 17.12.2013
How do you remove a 3DLabel from a player (Attach3DTextLabelToPlayer), I tried deleting it and that doesn't work, I also tried updating the text for something else, and it don't work
Re: Removing 3D label from player -
BlackWolf120 - 17.12.2013
use this function to delete:
https://sampwiki.blast.hk/wiki/Delete3DTextLabel
But i myself just delete the label by updating it to "nothing".
pawn Код:
Update3DTextLabelText(labelID, 0xFFFFFFFF, " ");
I would recommend you to create the labels for every player under OnGameModeInit and then simply use the update
function in order to edit/delete them.
I also have had simillar issues in the past trying simply delete them. (Somehow the label IDs got messed up i suppose).
Re: Removing 3D label from player -
Mattakil - 17.12.2013
Quote:
Originally Posted by BlackWolf120
use this function to delete: https://sampwiki.blast.hk/wiki/Delete3DTextLabel
But i myself just delete the label by updating it to "nothing".
pawn Код:
Update3DTextLabelText(labelID, 0xFFFFFFFF, " ");
I would recommend you to create the labels for every player under OnGameModeInit and then simply use the update
function in order to edit/delete them.
I also have had simillar issues in the past trying simply delete them. (Somehow the label IDs got messed up i suppose).
|
I did this:
pawn Код:
Update3DTextLabelText(PlayerInfo[pid][pPlayername], COLGREEN, "ADMIN: NOT HERE IN CHARACTER (OOC)");
And basically, what it did was create ANOTHER label on top of the current one
Re: Removing 3D label from player -
BlackWolf120 - 17.12.2013
please show me also the code part where you create the labels and how you assign the labelIDs to them.
Re: Removing 3D label from player -
Mattakil - 17.12.2013
pawn Код:
public OnPlayerSpawn(playerid)
{
new namestring[MAX_PLAYER_NAME];
format(namestring, sizeof(namestring), "%s", GetName(playerid));
PlayerInfo[playerid][pPlayername] = Create3DTextLabel(namestring, -1, 0, 0, 0, 10.0, 0, 0);
Attach3DTextLabelToPlayer(PlayerInfo[pid][pPlayername], playerid, 0, 0, 0.3);
}
Re: Removing 3D label from player -
BlackWolf120 - 17.12.2013
pawn Код:
//may i ask: Why "pid" and not "playerid"?
Attach3DTextLabelToPlayer(PlayerInfo[pid][pPlayername], playerid, 0, 0, 0.3);
//Also you have to update the label...
As i already said, i would create a label for every player in advance.
pawn Код:
new Text3D:label[MAX_PLAYERS],
namestring[MAX_PLAYER_NAME];
public OnGameModeInit()//just create it here, we update it later
{
foreach(Player,i)
{
label[i] = Create3DTextLabel("", -1, 0, 0, 0, 10.0, 0, 0);
}
return 1;
}
public OnPlayerSpawn(playerid)//we update it on spawn and attach it to the player
{
format(namestring, sizeof(namestring), "%s", GetName(playerid));
Update3DTextLabelText(label[playerid],-1,namestring);
Attach3DTextLabelToPlayer(label[playerid], playerid, 0, 0, 0.3);
return 1;
}
//In case you want to "delete" the label, just empty it using:
Update3DTextLabelText(label[playerid], -1, " ");
Just change the "label[playerid]" to your labelID.
This is a very simpel method and will work for sure!
Hope this helps
Re: Removing 3D label from player -
Mattakil - 18.12.2013
Ill try that out, and I used pid because im too lazy to use playerid every time.
Re: Removing 3D label from player -
Mattakil - 18.12.2013
Yeah erm..that didn't work.
Re: Removing 3D label from player -
Hansrutger - 18.12.2013
Quote:
Originally Posted by BlackWolf120
pawn Код:
//may i ask: Why "pid" and not "playerid"? Attach3DTextLabelToPlayer(PlayerInfo[pid][pPlayername], playerid, 0, 0, 0.3); //Also you have to update the label...
As i already said, i would create a label for every player in advance.
pawn Код:
new Text3D:label[MAX_PLAYERS], namestring[MAX_PLAYER_NAME];
public OnGameModeInit()//just create it here, we update it later { foreach(Player,i) { label[i] = Create3DTextLabel("", -1, 0, 0, 0, 10.0, 0, 0); } return 1; }
public OnPlayerSpawn(playerid)//we update it on spawn and attach it to the player { format(namestring, sizeof(namestring), "%s", GetName(playerid)); Update3DTextLabelText(label[playerid],-1,namestring); Attach3DTextLabelToPlayer(label[playerid], playerid, 0, 0, 0.3); return 1; }
//In case you want to "delete" the label, just empty it using: Update3DTextLabelText(label[playerid], -1, " ");
Just change the "label[playerid]" to your labelID.
This is a very simpel method and will work for sure!
Hope this helps 
|
Noob question here: How would it know what "Player" is on OnGameModeInit?
Re: Removing 3D label from player -
BlackWolf120 - 18.12.2013
Its not a required parameter that has to be defined for this callback.
foreach is a loop and that loop defines the "Player" by default.
regards, wolf.