One question...
#1

What would happen if i had a timer that gets called every second that has code in it which has execution time of more than a second?

Thanks.
Reply
#2

Hmm unlikely... most codes take around 10 / 200 ms to complete. But I guess either the code gets cut off or the timer waits till code finishes...

Offtopic: You should change your sig dude its already 60 seconds now
Reply
#3

Anybody else has a theory?

Offtopic: I just left it because im lazy to create my own. xD
Reply
#4

I would say nothing special...
The timer would execute every second even if the function is still running.
I think everything a timer does, is that it starts a function in an fixed interval - the execution itself has nothing to do with that.

If someone knows that exactly I would be interested, too
Reply
#5

You could test it with this,
pawn Код:
#include <a_samp>

forward TEST();

public OnFilterScriptInit()
{
    SetTimer("TEST", 1000, true);
    return 1;
}

public TEST()
{
    for(;;)
    {
    }
}
Reply
#6

It would start lagging because server will wait for the function to finish before it starts any other function in your script.
Reply
#7

Sure?
(So there is always only one function running? (-> no multitasking))
Reply
#8

You can test it with this function

pawn Код:
public TEST()
{
    new ticks = GetTickCount();
    while((GetTickCount() - ticks) < 2000) { }  // takes 2 seconds to finish
}
Reply
#9

It woudn't lag that much, I already got a timer that repeats every 0.5 seconds, and it doesn't make any lag for me. + Make sure if you loop through all players, to use Foreach or redefine MAX_PLAYERS:
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (100) // Change this to your server slots
Reply
#10

Thanks all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)