05.09.2014, 17:17
(
Последний раз редактировалось [WSF]ThA_Devil; 05.09.2014 в 18:06.
)
Gonna fail terribly after death...
As well, I'd suggest you using hooks, so it is like plug and play. No need to edit your script.
And, it will fail using gun shops!
That's nothing.... 20 arrays check 5 times a second is close to nothing in performance, unless you're running 32Mb ram module (alone)
The thing you shouldn't do under OnPlayerUpdate is doing player sided stuff, like SetPlayerPos'ing, or anything that sends packets to client, that is what makes it lag.
Or more difficult calculations, but there is nothing like that in it.
You can have 5 line script that lags server with single comparison, or 50 line OnPlayerUpdate script that doesn't lag at all. How you use it is what matters.
Example:
Textdraws and Set* functions are bound to create problems.
but
Get are not.
Since player updates it to server by it self, and server fetches it from server memory.
There are so many stuff hidden in memory, just like AttachPlayerObjectToPlayer ( YSF) and Police car siren states.
My own *OnPlayerUpdate* is 109 lines long, by following these terms:
In line counter included public function, each bracket in new line, and few comments.
Clean length would be about 50 - 70 lines.
And it does not cause any lag what so ever.
As well, I'd suggest you using hooks, so it is like plug and play. No need to edit your script.
And, it will fail using gun shops!
Quote:
Don't use CheckWeapons under OnPlayerUpdate, it will be very bad and laggy. Imagine checking more than 20 arrays like 5 times a second. You should use a timer that works every 1 - 3 seconds.
|
The thing you shouldn't do under OnPlayerUpdate is doing player sided stuff, like SetPlayerPos'ing, or anything that sends packets to client, that is what makes it lag.
Or more difficult calculations, but there is nothing like that in it.
You can have 5 line script that lags server with single comparison, or 50 line OnPlayerUpdate script that doesn't lag at all. How you use it is what matters.
Example:
Textdraws and Set* functions are bound to create problems.
but
Get are not.
Since player updates it to server by it self, and server fetches it from server memory.
There are so many stuff hidden in memory, just like AttachPlayerObjectToPlayer ( YSF) and Police car siren states.
My own *OnPlayerUpdate* is 109 lines long, by following these terms:
In line counter included public function, each bracket in new line, and few comments.
Clean length would be about 50 - 70 lines.
And it does not cause any lag what so ever.