I Can't delete 3DTextLabel to player
#1

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;
}
Reply
#2

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)