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

Quote:
Originally Posted by Stefhan
Посмотреть сообщение
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?
No it doesn't kill it, it just stops it from repeating.

Quote:
Originally Posted by Stefhan
Посмотреть сообщение
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.
Код:
new Text3D:PlayerSpawnLabel[MAX_PLAYERS] = {Text3D:INVALID_3DTEXT_ID, ...};
new SpawnLabelDespawnTimer[MAX_PLAYERS];

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

public OnPlayerDisconnect(playerid, reason)
{
    if (IsValid3DTextLabel(PlayerSpawnLabel[playerid]))
    {
        Delete3DTextLabel(PlayerSpawnLabel[playerid]); 
        PlayerSpawnLabel[playerid] = Text3D:INVALID_3DTEXT_ID;
        KillTimer(SpawnLabelDespawnTimer[playerid]);
    }
    return 1;
}

public OnPlayerDeath(playerid)
{
    if (IsValid3DTextLabel(PlayerSpawnLabel[playerid]))
    {
        Delete3DTextLabel(PlayerSpawnLabel[playerid]); 
        PlayerSpawnLabel[playerid] = Text3D:INVALID_3DTEXT_ID;
        KillTimer(SpawnLabelDespawnTimer[playerid]);
    }
    return 1;
}

forward SpawnLabelTimer(playerid);

public SpawnLabelTimer(playerid) 
{ 
    Delete3DTextLabel(PlayerSpawnLabel[playerid]); 
    PlayerSpawnLabel[playerid] = Text3D:INVALID_3DTEXT_ID; 
    KillTimer(SpawnLabelDespawnTimer[playerid]);
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)