Timer or OPU - 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: Timer or OPU (
/showthread.php?tid=293607)
Timer or OPU -
Wesley221 - 29.10.2011
Hey guys,
What should i use to avoid players from getting any weapons through hacks, a timer or OnPlayerUpdate?
I think a timer would be better, since it doesnt gets called like 30+ (rough guess) in a second
What do you guys think?
~Wesley
Re: Timer or OPU -
[MG]Dimi - 29.10.2011
Timer
Re: Timer or OPU -
Scenario - 29.10.2011
OnPlayerUpdate was made for use of an efficient anti-cheat. Just don't put things under there which will take forever to process.
Re: Timer or OPU -
Wesley221 - 29.10.2011
So if i would add 'if( PlayerInfo[playerid][pAdmin] < 3 ) ResetPlayerWeapons(playerid);', then it wouldnt lagg the server that much; right?
Re: Timer or OPU -
rbN. - 29.10.2011
Quote:
Originally Posted by Wesley221
So if i would add 'if( PlayerInfo[playerid][pAdmin] < 3 ) ResetPlayerWeapons(playerid);', then it wouldnt lagg the server that much; right?
|
It won't lagg so much that it's unplayable :P
Re: Timer or OPU -
[HiC]TheKiller - 29.10.2011
Quote:
Originally Posted by Wesley221
So if i would add 'if( PlayerInfo[playerid][pAdmin] < 3 ) ResetPlayerWeapons(playerid);', then it wouldnt lagg the server that much; right?
|
It takes about 100 ms to do a 1 million loop of something like that. I think you will be fine doing that on OnPlayerUpdate.
Re: Timer or OPU -
playbox12 - 29.10.2011
I use schedule code under my OPU, for example make it so certain code only gets called every second, or each 20 updates. That way you still use OPU and the server doesen't have to process another timer.
Re: Timer or OPU -
Wesley221 - 29.10.2011
Alright, thanks all
![Wink](images/smilies/wink.png)
Edit:
Quote:
Originally Posted by playbox12
I use schedule code under my OPU, for example make it so certain code only gets called every second, or each 20 updates. That way you still use OPU and the server doesen't have to process another timer.
|
Can u explain that a lil more?
Re: Timer or OPU -
Scenario - 29.10.2011
Quote:
Originally Posted by Wesley221
Alright, thanks all ![Wink](images/smilies/wink.png)
Edit:
Can u explain that a lil more?
|
Use a variable that updates every time OPU is called. Check to see if that variable has reached (i.e.) 20, this means OPU has been called 20 times. If it has, then reset the variable and perform what you wanted to. This process will keep happening, in an attempt to stop most lag.
Re: Timer or OPU -
Wesley221 - 29.10.2011
Thats actually pretty useful, never thought of that
Thanks!