[Tutorial] Player-timers
#3

That's quite a bad way of putting restrictions on players, timers should never be used for such things. Just put the time of their last action you want to block in a variable, then when they try to do it again check if X seconds passed since that timestamp.
pawn Code:
new repairtime[MAX_PLAYERS];

OnPlayerCommandText // or whatever function you're using it in
{
    // ... they try to do it:
    if(repairtime[playerid] < gettime()) // If they've waited long enough
    {
        // Do the repair
        repairtime[playerid] = gettime()+X // X = Amount of seconds you want to block them
    }
}
I would love to have some form of comparison between the CPU usage of the two different methods, but I can't think of any way to benchmark them properly.
Reply


Messages In This Thread
Player-timers - by Lenny the Cup - 12.10.2010, 10:36
Re: Player-timers - by Rachael - 12.10.2010, 11:03
Re: Player-timers - by Lenny the Cup - 12.10.2010, 11:22
Re: Player-timers - by Rachael - 12.10.2010, 11:43
Re: Player-timers - by Lenny the Cup - 12.10.2010, 11:50
Re: Player-timers - by playbox12 - 12.10.2010, 16:18
Re: Player-timers - by Lenny the Cup - 13.10.2010, 11:13
Re: Player-timers - by Lenny the Cup - 13.10.2010, 20:23
Re: Player-timers - by Slice - 13.10.2010, 20:29
Re: Player-timers - by RoBo - 14.10.2010, 17:37

Forum Jump:


Users browsing this thread: 1 Guest(s)