Payday function
#7

You have two global timers you're not even using properly, hell. Most of your timers aren't properly used.

Why are you checking if the player is spectating every 500 ms? That means your server is looping EVERY 500 ms against all players, finds the spectator ID, sets the textdraws (not to mention if they are already set) and so on.

When spectating, don't use a timer. Use OnPlayerInteriorChange callback, so when the player interior is changed, the interior is matched with the spectator. Use OnPlayerStateChange, new state passenger/driver. Set the spectator's view to a vehicle. Player's OnPlayerTakeDamage gets called, update the info with the spectator and so on. Therefore you have no use of your 'Spectator' timer.

Secondly, moving to TimerAntiCheati.

I personally prefer that you check those under OnPlayerTakeDamage, if he takes the damage. Match his armour with the script armour, the HP too. Aren't they equal? Do your thing.

About the 'OtherTimer' I don't really know what it's purpose is, it's just full of statements, loops, checks that are performed every 1000 ms (one second) which is bad, you should consider having 30 players online. That's 30 loops, 30 statements, 30*functions performed.

Speedometer: Do not use a Global for that, it's extremely bad and inefficient. Use a per-player timer (SetTimerEx). When a player enters a vehicle, set a per-player timer every 800 ms (that's more than enough) to update your stuff when a player is driving, sitting in a vehicle, etc. Don't forget to kill the timer (KillTimer when a player exits the vehicle.

Get rid of these timers I've talked about above, and I'll proceed helping you with the main problem.
Reply


Messages In This Thread
Payday function - by PepsiCola23 - 14.08.2015, 19:57
Re: Payday function - by PepsiCola23 - 14.08.2015, 21:00
Re: Payday function - by jlalt - 14.08.2015, 22:12
Re: Payday function - by PepsiCola23 - 14.08.2015, 23:13
Re: Payday function - by PepsiCola23 - 15.08.2015, 12:57
Re: Payday function - by PepsiCola23 - 16.08.2015, 12:08
Re: Payday function - by DaniceMcHarley - 16.08.2015, 15:03

Forum Jump:


Users browsing this thread: 2 Guest(s)