Stopping spam in OnPlayerUpdate.
#1

Hey got a little problem, how do I stop OnPlayerUpdate Spamming. I only want it to do something once, but it keeps spamming.
Reply
#2

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.
Reply
#3

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.
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)