Pause label bug.
#1

Trying to make a 3d text label attatched to a player that is paused.
But the labels gets bugged, there is no warnings or errors on compile, so i dont understand what is wrong.

Here is the code
http://pastebin.com/FmQ8jwfL

Here is the result:
/imageshack/f/samp033i.png/

Random pause labels gets attached to players that are not paused.
ANyone that can see whats wrong with it?
Reply
#2

Well, for one thing, there is a far easier way to see if someone is paused using OnPlayerUpdate and a Timer, for example:

pawn Код:
new bool:bPaused[MAX_PLAYERS];

public OnGameModeInit()
{
    SetTimer("pauseCheck", 1000, true);
    return 1;
}

public pauseCheck()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(bPaused[i]) SetPlayerChatBubble(playerid, "Paused", 0xFF0000FF, 100.0, 1000);
            bPaused[i] = true;
        }
    }
    return 1;
}

public OnPlayerUpdate(playerid)
{
    bPaused[playerid] = false;
    return 1;
}
This works because OnPlayerUpdate is no longer called when the player is paused, however the timer is still being called, which means that the variable isn't being set to false, but it will be set to true, so within 2 runs of the timer, the player will be recognized as paused.

Note that this is only an example.

Also if I were you, I'd forget about the 3D Text Labels and just use SetPlayerChatBubble for the pause message
Reply
#3

Thanks JaTochNietDan. I will try that.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)