Timer / Textdraw bug
#2

pawn Код:
JailTimer[targetid] = SetTimerEx("JailTimer", 999, true, "i", targetid);//timer wherever you place it in your gamemode.
pawn Код:
public JailTimer(targetid)
{
    jailtime--;
    if(jailtime > 0 && jailed[targetid] == 1)
    {
        new string[10];
        format(string,sizeof(string), "%i", jailtime);
        TextDrawSetString(JailTime[1], string);
        TextDrawShowForPlayer(targetid, JailTime[0]); //message saying Time Remaining
        TextDrawShowForPlayer(targetid, JailTime[1]); //the actual time being shown
    }
    else if (jailtime == 0)
    {
        TextDrawHideForPlayer(targetid, JailTime[0]);
        TextDrawHideForPlayer(targetid, JailTime[1]);
        KillTimer(JailTimer[targetid]);//killing the timer when the jailtime reaches 0
        jailed[targetid] = 0;//saying that the player has been unjailed
    }
    return 1;
}
You need to give the timer an ID and kill it when the jail time reaches 0 so it stops decrementing. Also you would want to set the "jailed" variable to it's null value (0 I assume) to say that he's out of jail.
Reply


Messages In This Thread
Timer / Textdraw bug - by SnG.Scot_MisCuDI - 04.07.2012, 05:23
Re: Timer / Textdraw bug - by Tee - 04.07.2012, 05:31
Re: Timer / Textdraw bug - by SnG.Scot_MisCuDI - 04.07.2012, 05:37
Re: Timer / Textdraw bug - by MP2 - 04.07.2012, 05:40
Re: Timer / Textdraw bug - by Tee - 04.07.2012, 05:42
Re: Timer / Textdraw bug - by SnG.Scot_MisCuDI - 04.07.2012, 05:44
Re: Timer / Textdraw bug - by [KHK]Khalid - 04.07.2012, 05:46
Re: Timer / Textdraw bug - by Tee - 04.07.2012, 05:48
Re: Timer / Textdraw bug - by SnG.Scot_MisCuDI - 04.07.2012, 05:49
Re: Timer / Textdraw bug - by [KHK]Khalid - 04.07.2012, 05:52

Forum Jump:


Users browsing this thread: 1 Guest(s)