SA-MP Forums Archive
I Can't delete 3DTextLabel to player - 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)
+--- Thread: I Can't delete 3DTextLabel to player (/showthread.php?tid=611331)



I Can't delete 3DTextLabel to player - SamBum - 05.07.2016

I have written a simple mask system, and It's have a 3dText above head when use command /mask, but when I retype that command, It's not delete 3DTextLabel. Some one help me please ^_^
My Script
Код:
new Text3D:masknamelabel[MAX_PLAYERS];
CMD:mask(playerid, params[])
{
    new string[128];
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_LIGHTRED, "Lenh dang duoc hoan thien.");
    if(IsPlayerConnected(playerid))
    {
    	if(GetPVarInt(playerid, "dangdeomask") == 0)
   	 	{
		   	for(new i; i < MAX_PLAYERS; i++)
		    {
	    	    if(IsPlayerConnected(i))
	    	    {
	   			    ShowPlayerNameTagForPlayer(i, playerid, 0);
	   			    Dadeomatna[playerid] = 1;
	   			    masknamelabel[playerid] = Create3DTextLabel(" ",0x9ACD32AA,30.0,40.0,50.0,15.0,0);
		  			format(string,sizeof(string),"Nguoi la mat #%d", GetPlayerSQLId(playerid));
		  			Update3DTextLabelText(masknamelabel[playerid], 0x9ACD32AA, string);
		  			Attach3DTextLabelToPlayer(masknamelabel[playerid], playerid, 0.0, 0.0, 0.4);
			    }
		    }
		    SetPVarInt(playerid, "dangdeomask", 1);
  		    format(string, sizeof(string), "* %s lay ra mot chiec mat na va deo len tren mat.", GetPlayerNameEx(playerid));
  		    ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  		}
  		else if(GetPVarInt(playerid, "dangdeomask") == 1)
   	 	{
   	 	    for(new i; i < MAX_PLAYERS; i++)
		    {
	    	    if(IsPlayerConnected(i))
	    	    {
	   			    ShowPlayerNameTagForPlayer(i, playerid, 1);
	   			    Dadeomatna[playerid] = 0;
	   			    Delete3DTextLabel(masknamelabel[playerid]);
			    }
		    }
		    SetPVarInt(playerid, "dangdeomask", 0);
  		    format(string, sizeof(string), "* Nguoi la mat #%d da thao chiec mat na xuong.", GetPlayerSQLId(playerid));
  		    ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
   	 	}
	}
	return 1;
}



Re: I Can't delete 3DTextLabel to player - luke49 - 05.07.2016

Move everything out of the loop and leave only ShowPlayerNameTagForPlayer(i, playerid, 0/1); inside it.


Re: I Can't delete 3DTextLabel to player - SamBum - 05.07.2016

#Luke49 Thank you, I will test and give the feedback later.


Re: I Can't delete 3DTextLabel to player - SamBum - 07.07.2016

#Luke49 It's work, thank you so much !
I have an idea about Mask system, this will destroy old 3d text label, and update new 3d text label with new health, armor when player take damage. but sometime it's hide the 3dtextlabel. If someone has another plan please tell me .
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
   	Delete3DTextLabel(masknamelabel[playerid]);
        new string[128], Float:health, Float:armour;
	if(PlayerInfo[playerid][pDangdeomask] == 1)
	{
		GetPlayerHealth(playerid, health);
		GetPlayerArmour(playerid, armour);
		masknamelabel[playerid] = Create3DTextLabel(" ",0x9ACD32AA,30.0,40.0,50.0,15.0,0);
		format(string,sizeof(string),"Stranger #%d\nHealth: %d, Armour: %d", GetPlayerSQLId(playerid), floatround(health), floatround(armour));
		Update3DTextLabelText(masknamelabel[playerid], 0x9ACD32AA, string);
		Attach3DTextLabelToPlayer(masknamelabel[playerid], playerid, 0.0, 0.0, 0.4);
	}
	//bumbum-mask
	return 1;
}