SA-MP Forums Archive
No timers are working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: No timers are working (/showthread.php?tid=242023)



No timers are working - Flyfishes - 19.03.2011

Hey!

This morning I fixed a system so if you're a donator you could buy a parrot and then use /parrot to get it attached to your body. When I loaded the GM on my server no timer were working so I removed that system. When I uploaded the new GM they were not working either. Are there a solution for this?

Sorry if I wrote with incorrect grammar etc. I'm so damn tired, still!


Re: No timers are working - Biesmen - 19.03.2011

You mean
SetTimer
SetTimerEx ?


Re: No timers are working - PinkFloydLover - 19.03.2011

To create a working timer:
At the top:
pawn Код:
forward YourTimer();
Set the Timer:
pawn Код:
SetTimer("YourTimer",time,repeating);
The effect of the timer:
pawn Код:
public YourTimer()
{
// do something here
return 1;
}



Re: No timers are working - Flyfishes - 19.03.2011

@Biesman, Yes I'm using SetTimer and SetTimerEx.
@Cale, Exactly what I've done but they're not like being runned or they're failing while starting the timer.


Re: No timers are working - PinkFloydLover - 19.03.2011

Care to show us your script?


Re: No timers are working - Flyfishes - 19.03.2011

I've got this simple:
pawn Код:
forward AirBreakTimer();

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

public AirBreakTimer()
{
    for(new i = 0; i < MAX_PLAYERSEX; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(!IsPlayerInAnyVehicle(i))
            {
                new Float:pVelocity[3], speedst[150];
                GetPlayerVelocity(i, pVelocity[0], pVelocity[1], pVelocity[2]);
                new Float:pSpeed = floatsqroot(floatpower(pVelocity[0], 2) + floatpower(pVelocity[1], 2) + floatpower(pVelocity[2], 2)) * 199;
                if(pSpeed >= 100)
                {
                    if(GetPlayerWeapon(i) != 46)
                    {
                        if(airbreak[i] >= 10)
                        {
                            format(speedst, sizeof(speedst), "[Alert:] %s (ID: %d) might be surfing with %0.0f KM/H", GetNameEx(i), i, pSpeed);
                            AdministratorMessage(COLOR_RED, speedst, 1);
                            airbreak[i] = -1;
                        }
                        airbreak[i]++;
                    }
                }
            }
        }
    }
    return 1;
}
I've got 19 timers starting under OnGameModeInit


Re: No timers are working - [L3th4l] - 19.03.2011

In the past I've also experienced problems with timers. But it was a BAD code mistake.

Here is the first problem I've had:
pawn Код:
new String[50];
format(String, 60, "bablablbal%s%i", blabla, blabl);
The code will not run at all, because you are trying to allocate more cells into the string.
The other problem was to return a 0 in one of my timer functions, that disabled all the bottom ( following ) timers.

Hope this helps, can't really tell your problem.


Re: No timers are working - Flyfishes - 19.03.2011

Thanks for the help Lethal, but it didn't solve anything. I really can't find out the problem. It just didn't working this morning, but worked successfully yesterday. I've tried to use an old backup from my GM but that didn't solve it either. So it's not the script doing anything.


Re: No timers are working - Biesmen - 20.03.2011

pawn Код:
for(new i = 0; i < MAX_PLAYERSEX; i++)
Try to change this into:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)



Re: No timers are working - Zh3r0 - 20.03.2011

Put prints in all timers and check 'em all!

Also, 19 TIMERS? YOU INSANE?