A question about 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: A question about OnPlayerUpdate (
/showthread.php?tid=649877)
A question about OnPlayerUpdate -
ivndosos - 16.02.2018
Hi,
I saw some people said this might cause issues so I want to make sure. I've made an HP Textdraw that updates Its color by the value (40 = red, 100 = green etc.)
That piece of code was OnPlayerDamage callback, but we've encountered problems, I'll explain:
Let's say I have 40 HP which means my TD color is Red, After I use /sethp command let's say I set my HP value to 60 It will stay red UNLESS I damage my self (OnPlayerDamage callback), Only then the callback will read the code and update my health.
So, I thought I'd better put that piece of code on OnPlayerUpdate, but some people said it might cause issues if a lot of players are in-game and it might cause lag or stuff like that.
Is that true or Is it harmless?
Re: A question about OnPlayerUpdate -
Crayder - 16.02.2018
You should update the textdraws in OnPlayerDamage, OnPlayerDeath, and a ~150ms timer to account for any other occurrences. OnPlayerUpdate would be fine for a small thing like this, but things add up so it's best to go with a timer.
Re: A question about OnPlayerUpdate -
ivndosos - 16.02.2018
Alright thanks.