Timer...
#7

Quote:
Originally Posted by Mionee
Посмотреть сообщение
The following compiles, I've added comments to explain why I do things.

pawn Код:
new reducetimer[MAX_PLAYERS]; // timer variable

public OnPlayerUpdate(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 1)
    {
        reducetimer[playerid] = SetTimerEx("ReduceWantedLevel", 60000, false, "i", playerid);
        // we store it in a variable so we can kill the timer later
    }
   
    return 1;
}

forward ReduceWantedLevel(playerid);
public ReduceWantedLevel(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 1)
    {
        SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) -1);
    }
   
    // if player has no wanted level left, kill the timer
    else if(GetPlayerWantedLevel(playerid) == 0) return KillTimer(reducetimer[playerid]);
    // theres no reason for this timer to keep running if they have no wanted level
   
    return 1;
}
If you have any queries, please do ask. Also, I'm not entirely sure but I think it's very dodgy to use timers under OnPlayerUpdate.
Thanks for the code & for explaining .
I kinda messed it up so thats why i asked .
Thanks once again.
EDIT: Since you're discussing about wrong/right places of putting this timer , where should i put it ?
Reply


Messages In This Thread
Timer... - by Johnson_Brooks - 03.06.2014, 05:25
Re: Timer... - by BroZeus - 03.06.2014, 05:32
Re: Timer... - by Dignity - 03.06.2014, 05:33
Re: Timer... - by kamiliuxliuxliux - 03.06.2014, 05:35
Re: Timer... - by BroZeus - 03.06.2014, 05:36
Re: Timer... - by Dignity - 03.06.2014, 05:41
Re: Timer... - by Johnson_Brooks - 03.06.2014, 05:43

Forum Jump:


Users browsing this thread: 3 Guest(s)