SA-MP Forums Archive
inquiring about "script optmization" - 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: inquiring about "script optmization" (/showthread.php?tid=211231)



inquiring about "script optmization" - Volks - 14.01.2011

i have some questions that i could not find awnsers anywhere...
someone help me out ,plz,XD

1- whats better one global textdraw or one textdraw for each player , i mean in terms of memory usage & peformance and why?

global text
new Text:board;
board = TextDrawCreate(320,432.5," ")........
or
new Text:board[MAX_PLAYERS];
board [playerid]= TextDrawCreate(320,432.5," ").......
and every player will have his very own textdraw...


2- which one is better from the cases bellow.... and why?
which one is faster to read/store data?

Plevel[MAX_PLAYERS];
Pscore[MAX_PLAYERS];

or

enum info
{
level,
score
}
new Pinfo[MAX_PLAYERS][info];


or

SetPVarInt(playerid, "level",1);

even

#define Player(%1,%2) playerinfo[ %1 ][ %2 ]

Player(playerid,level) etc.........


Re: inquiring about "script optmization" - WillyP - 14.01.2011

If it's things like health, use player variables, but for things like the time, use a whole server loop.


Re: inquiring about "script optmization" - ғαιιοцт - 14.01.2011

It depends on what text you want to place in the textdraw. If te text will always be the same for every player, use a global textdraw. If the text is different for every player, like when it shows the player's score, use one textdraw for every player.


And for the variables I suggest the PvarInts, because they were made for exactly that


Re: inquiring about "script optmization" - Babul - 14.01.2011

agreed: ғαιιοцт's idea to use PVars is good if you intend to extend your server with some filterscripts like an admin system (using serversided money f.ex) which can take advantage and modify them. despite the fact that pvars are a bit slower to process, they are a good choice nevertheless. in a loop processing much of time relevant stuff, an enumerated array will work better, since you can create loops easier. pvariables would nee to format a name for them ach time, or hardcoded ones. using enums will speed up (plenty) calculations (like sorting). one more benefit of using pvars: they will get deleted on playerdisconnect, even if its a unique one like "RaceCheckpoint201TimeEntered", for the DCed player only indeed. you dont need to care for reseting a whole array/enum at onplayerconnect. making things easy to develop ^^


Re: inquiring about "script optmization" - Volks - 16.01.2011

thanks for all anwsers ,

is there some place i can find more tecniqual info about pawno rather than just how to use it in samp....

well u said that it is an advantage that pvars get deleted on player disconnect.... so... does the number of vars that you have running in a server effects its peformance?

and if i get it right, is better use

one enum var:

enum info
{
level,
score
}
new Pinfo[MAX_PLAYERS][info];

than Pinfolevel[MAX_PLAYERS], Pinfoscore[MAX_PLAYERS]... one var for every single thing...


?


Re: inquiring about "script optmization" - Joe Staff - 16.01.2011

It's the same when compiled, in the end it's just assigning information to the same amoint of bits. PVars are actually inefficient and only bring convinience when transfering information from one script to another, PVars also use up more RAM to give the variable a stringed desognation


Re: inquiring about "script optmization" - Leeroy. - 17.01.2011

Check ****** script optimization tutorial and use foreach and sscanf.