SA-MP Forums Archive
Server Optimization Question - 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: Server Optimization Question (/showthread.php?tid=661581)



Server Optimization Question - BrainDamaged - 08.12.2018

Hello,
I have a one gamemode, and I want to optimize this game mode but I don't know where to start.
I know a few things, but I know that it's not enough.
for example: check string values, check timer...

I would be very happy if you could make recommendations in such examples.


Note: Sorry, my bad english.


Re: Server Optimization Question - m4karow - 08.12.2018

You can check for data saving. This can cause a little lag to the players if you save too much data at the same time.
For example: You saving 1000 vehicle's data in a timer


Re: Server Optimization Question - BrainDamaged - 08.12.2018

Quote:
Originally Posted by m4karow
Посмотреть сообщение
You can check for data saving. This can cause a little lag to the players if you save too much data at the same time.
For example: You saving 1000 vehicle's data in a timer
Thanks I got my note!
----------------------------------
I am looking for feedback from other users.


Re: Server Optimization Question - Logic_ - 08.12.2018

Optimization is a very vague term or very broad, it really depends on your script.

Update data where needed, save where needed.
Use lesser number of variables, strings etc.
Re-define constants (MAX_PLAYERS, MAX_VEHICLES etc) if necessary.
Rewrite your code.
Break your single-timer code into multiple-timers.
Combine multiple statements (if, else-ifs) into one or use switch.
Don't abuse switch with large quantities (such as: case 1 ... 10000:) this will just increase the compile time.
Make use of timer instead of OnPlayerUpdate.

Most of these stuff just make difference of a milliseconds or microseconds.


Re: Server Optimization Question - GospodinX - 08.12.2018

You can add Profiler Plugin which will help you in optimization.

https://sampforum.blast.hk/showthread.php?tid=271129


Re: Server Optimization Question - BrainDamaged - 09.12.2018

Thanks!, I am looking for feedback from other users.