One question... - 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: One question... (
/showthread.php?tid=220830)
One question... -
Whizion - 04.02.2011
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.
Re: One question... -
alpha500delta - 04.02.2011
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
Re: One question... -
Whizion - 04.02.2011
Anybody else has a theory?
Offtopic: I just left it because im lazy to create my own. xD
AW: One question... -
!Phoenix! - 04.02.2011
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
Re: One question... -
iggy1 - 04.02.2011
You could test it with this,
pawn Код:
#include <a_samp>
forward TEST();
public OnFilterScriptInit()
{
SetTimer("TEST", 1000, true);
return 1;
}
public TEST()
{
for(;;)
{
}
}
Re: One question... -
MadeMan - 04.02.2011
It would start lagging because server will wait for the function to finish before it starts any other function in your script.
AW: One question... -
!Phoenix! - 04.02.2011
Sure?
(So there is always only one function running? (-> no multitasking))
Re: One question... -
MadeMan - 04.02.2011
You can test it with this function
pawn Код:
public TEST()
{
new ticks = GetTickCount();
while((GetTickCount() - ticks) < 2000) { } // takes 2 seconds to finish
}
Re: One question... -
Mean - 04.02.2011
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
Re: One question... -
Whizion - 04.02.2011
Thanks all.