Lag prevention - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Lag prevention (
/showthread.php?tid=143197)
Lag prevention -
ruckfules99 - 21.04.2010
What are some ways you know of to prevent a laggy script?
I'm making a stunt server and want it to be as clean as possible in terms of lag.
Re: Lag prevention -
Goobiiify - 21.04.2010
Overused string size, Godfather edits, many timers or anything else that could be taking some server resources...
Re: Lag prevention -
Backwardsman97 - 21.04.2010
Take a good look at the post ****** made about code optimizations. It has everything you need to know (and then some) about having a very efficient script.
Re: Lag prevention -
ruckfules99 - 21.04.2010
Quote:
Originally Posted by Baked-Banana
Take a good look at the post ****** made about code optimizations. It has everything you need to know (and then some) about having a very efficient script.
|
Oh ok, I will take a look at that.
Quote:
Originally Posted by Al Fathead
Overused string size, Godfather edits, many timers or anything else that could be taking some server resources...
|
Can you explain to me about overused string size? Like give me an example.
Re: Lag prevention -
Goobiiify - 21.04.2010
like: new String[256]; when max string in Sa-mp is 128. It's unnecessary storage.
And sometimes like when you want to store the players name in a string you just need 24 as 24 is the maximum of SA-MP players name(new pName[24]

.
Re: Lag prevention -
IamNotKoolllll - 21.04.2010
Quote:
Originally Posted by Al Fathead
like: new String[256]; when max string in Sa-mp is 128. It's unnecessary storage.
And sometimes like when you want to store the players name in a string you just need 24 as 24 is the maximum of SA-MP players name(new pName[24]  .
|
44 = name 256 = whole chat line
Re: Lag prevention -
RyDeR` - 21.04.2010
for name; just use MAX_PLAYER_NAME.
Edit: also if you use a loop trough all players always check for connected players; otherwise it will do more then it's not needed.
Re: Lag prevention -
Eazy_Efolife - 21.04.2010
Quote:
Originally Posted by IamNotKoolllll
Quote:
Originally Posted by Al Fathead
like: new String[256]; when max string in Sa-mp is 128. It's unnecessary storage.
And sometimes like when you want to store the players name in a string you just need 24 as 24 is the maximum of SA-MP players name(new pName[24]  .
|
44 = name 256 = whole chat line
|
No.
Re: Lag prevention -
Grim_ - 21.04.2010
Quote:
Originally Posted by Al Fathead
when max string in Sa-mp is 128
|
Actually, no. For example a dialog/textdraw string can be much larger than 128.
Re: Lag prevention -
ruckfules99 - 21.04.2010
For my Anti jet pack ban, I have
Код:
new pname[30];
new string[250];
Is that bad? what should it be changed too, and how do you know how you should set the string?
Thanks guys for the great answers.