Optimization - 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: Optimization (
/showthread.php?tid=605960)
Optimization -
Micko123 - 27.04.2016
Can anyone explain me optimization of script. What is best way to optimize script?? Sry if this is noobish but i am newbie
Re: Optimization -
CalvinC - 27.04.2016
Optimization includes tweaking and changing things to make them faster or take up less memory.
There's lots of small things you can optimize, the 4 i would encourage most are:
Decrease string sizes as much as possible, or atleast make sure when using SCM that they're not beyond 128.
Use includes like zcmd/ycmd (not dcmd) for faster commands, and foreach for faster player loops.
Redefine "MAX_PLAYERS" to the actual max player slots you have set on your server right after
#include <a_samp>
An example of how to set it to 100 players:
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
Don't save players when they disconnect, save them instantly when their things are changed that needs to be saved.
Otherwise the server hangs when players disconnect.
Re: Optimization -
Micko123 - 27.04.2016
WOW thank you for this
Helped me a lot
Re: Optimization -
Lumanov - 27.04.2016
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100
Better this way:
Код:
#undef MAX_PLAYERS
const MAX_PLAYERS = 100;
Re: Optimization -
Micko123 - 27.04.2016
Why? (sry for asking but i dont want to copy paste i want to learn.) Why const? I don't get it..