Quote:
|
Originally Posted by XE_ManUp
Okay...
XAD, if I were to use a timer, would that cause the server to be bogged down with internal lag from the timers for individual players?
My initial idea was for every 10 seconds after being shot in the chest/stomach, the player loses 5 health (and slows down, but that comes later).
The timer end of this is what I am concerned with. I don't want a plugin to lag the server, and am unsure whether timers running on 16+ individual players would do so.
|
Well there are many ways to do it... you can implement it as one generic timer doing a check once per second (checked one time every frame). For each player you can have a health_lost_per_second value which you add to a health_lost var. When health_lost is more than 1 (or 5) you reduce both health and the health_lost var by 1 (or 5). This would also allow you to increase the bleeding for every hit and by different values depending on where the hit was taken. When player dies and at hud reset you set the health_lost_per_second value to zero.
You could also reduce the performance impact when no one is bleeding by having another indicator (someone_is_bleeding) which is set when someone starts to bleed. If this indicator is not set then you can skip the bleeding check totally and make the code overhead almost to nothing. If the flag is set (ie someone has been bleeding), then you unset it and loop through all players. If a player is bleeding then you do the bleeding stuff and also set the flag. This way when noone is bleeding anymore the flag will be unset and you bleeding check will be skipped again...
The overhead of doing the bleeding logic once a second will be very limited...
/X