SA-MP Forums Archive
Using a 1 second timer or OnPlayerUpdate - 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)
+--- Thread: Using a 1 second timer or OnPlayerUpdate (/showthread.php?tid=520359)



Using a 1 second timer or OnPlayerUpdate - Natric - 18.06.2014

Hello there,


I'm wondering, should I use a 1 second timer over OnPlayerUpdate in this following situation:

Well, some guy told me that OnPlayerUpdate is called more than 200 times in a second or something, and I am doing a system that if you're out of a certain range of something a variable will be set, so should I use OnPlayerUpdate or a 1 second timer (a server timer, SetTimer).

Thanks in advance.


Re: Using a 1 second timer or OnPlayerUpdate - Konstantinos - 18.06.2014

If I had to choose between those two, I'd go with a timer than OnPlayerUpdate (200 times is too much but it's called too frequently). However, using streamer's dynamic area would be much better.


Re: Using a 1 second timer or OnPlayerUpdate - Rittik - 18.06.2014

Yes, you can.


Re: Using a 1 second timer or OnPlayerUpdate - Natric - 18.06.2014

Are you talking about using CreateDynamicSphere?


Re: Using a 1 second timer or OnPlayerUpdate - Konstantinos - 18.06.2014

Quote:
Originally Posted by Natric
Посмотреть сообщение
Are you talking about using CreateDynamicSphere?
Depends on the type of the area so it's up to you.


Re: Using a 1 second timer or OnPlayerUpdate - Natric - 18.06.2014

using IsPlayerInRangeOfPoint might be better right?, If I'm using a variable already


Re: Using a 1 second timer or OnPlayerUpdate - Rittik - 18.06.2014

Quote:
Originally Posted by Natric
Посмотреть сообщение
using IsPlayerInRangeOfPoint might be better right?, If I'm using a variable already
In my opinion, yes. That would be better.


Re: Using a 1 second timer or OnPlayerUpdate - Natric - 18.06.2014

for instance,

under the timer:
pawn Код:
if(PlayerSpot[playerid][31])
{
if(IsPlayerInRangeOfPoint(playerid, 30.0, x, y, z))
{

// code here

}
}



Re: Using a 1 second timer or OnPlayerUpdate - Pottus - 18.06.2014

Quote:
Originally Posted by Natric
Посмотреть сообщение
for instance,

under the timer:
pawn Код:
if(PlayerSpot[playerid][31])
{
if(IsPlayerInRangeOfPoint(playerid, 30.0, x, y, z))
{

// code here

}
}
Just use dynamic areas that will work but certainly is not the best way.


Re: Using a 1 second timer or OnPlayerUpdate - Rittik - 18.06.2014

Make sure that you use SetTimeEx and add some parameters to it.