Issue with 3DTextLabel that's ment to vanish with a timer.
#7

Quote:
Originally Posted by BeckzyBoi
Посмотреть сообщение
What's your define of COLOR_YELLOW? What alpha are you using? E.G. 0xFFFF00FF . Also add KillTimer(LoginLabelDespawnTimer[playerid]); at the end of the timer.
I added it, but I want to know why it's important. Isn't the fact that the timer is on "false" enough to kill it?

Anyways, my current issue is that it only works for the first player that gets the label. The other players, all have the label above their head until they logout instead of after 20 seconds.

The code right now:

Код:
new 
    Text3D:PlayerSpawnLabel[MAX_PLAYERS] = { Text3D:INVALID_3DTEXT_ID, ... }, // So each player has it's own 3DTextLabel. 
    SpawnLabelDespawnTimer[MAX_PLAYERS]; // A timer for each label to despawn. (Although technically, unless you specifically need to use the timer ids somewhere else in your code; you don't even need a variable to store all the timer ids.)

public OnPlayerSpawn(playerid)
{
         if(!IsValid3DTextLabel(PlayerSpawnLabel[playerid]))
	    	{ 
	        PlayerSpawnLabel[playerid] = Create3DTextLabel("I just spawned.", COLOR_YELLOW, 0, 0, 0, 20, 0);
	        Attach3DTextLabelToPlayer(PlayerSpawnLabel[playerid], playerid, 0.0, 0.0, 0.27);
	        SpawnLabelDespawnTimer[playerid] = SetTimerEx("SpawnLabelTimer", 20000, false, "i", playerid); 
	        }
	return 1;
}

forward SpawnLabelTimer(playerid); 
public SpawnLabelTimer(playerid) 
{ 
    if(IsValid3DTextLabel(PlayerSpawnLabel[playerid])) 
    { 
        Delete3DTextLabel(PlayerSpawnLabel[playerid]); 
        PlayerSpawnLabel[playerid] = Text3D:INVALID_3DTEXT_ID; 
        KillTimer(SpawnLabelDespawnTimer[playerid]);
    } 
}
Thanks a lot for your help so far.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)