Stopping spam in 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: Stopping spam in OnPlayerUpdate. (
/showthread.php?tid=348984)
Stopping spam in OnPlayerUpdate. -
cloudysky - 07.06.2012
Hey got a little problem, how do I stop OnPlayerUpdate Spamming. I only want it to do something once, but it keeps spamming.
Re: Stopping spam in OnPlayerUpdate. -
JaTochNietDan - 07.06.2012
That's not possible, the callback is supposed to be called every time a new piece of information is synced by the user, which means it will get called
a lot.
You should consider using a timer instead, using SetTimer or SetTimerEx depending on which one is most appropriate for your situation.
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
With that said, if you literally meant you only want it to do something
once then why are you using it at all? Simply use another callback such as
OnPlayerConnect which is only called once when the player connects, but I don't really know which one is most appropriate for you with so little information.
Re: Stopping spam in OnPlayerUpdate. -
cloudysky - 07.06.2012
Quote:
Originally Posted by JaTochNietDan
With that said, if you literally meant you only want it to do something once then why are you using it at all? Simply use another callback such as OnPlayerConnect which is only called once when the player connects, but I don't really know which one is most appropriate for you with so little information.
|
Thanks for the response,
It's to detect when a player is in range of another player and then gives that player health.
Re: Stopping spam in OnPlayerUpdate. -
milanosie - 07.06.2012
Quote:
Originally Posted by cloudysky
Thanks for the response,
It's to detect when a player is in range of another player and then gives that player health.
|
Use a variable to check if the health is already given.
Like
pawn Код:
if(hashealth[playerid] == 0)
{
//code here
hashealth[playerid] = 1;
}