SA-MP Forums Archive
sizeof() or direct number in functions and INI saving 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: sizeof() or direct number in functions and INI saving question (/showthread.php?tid=654730)



sizeof() or direct number in functions and INI saving question - ElMaestro123 - 04.06.2018

Hi guys, I was looking for an answer but I sadly couldn't have found it. I was asking if the sizeof(.) function uses CPU while server is on or is it just processed in Precompiling process. Also what about INI saving, can I save certain variable at once without having to save every player's stat which causes way more lag for the server?


Re: sizeof() or direct number in functions and INI saving question - Eoussama - 04.06.2018

sizeof is a compiler directive (not a function, thus you can omit the braces too), it's processed at compile time, whether you use hard-coded numbers or sizeof has no effect on your server's performance, let's just not get crazy with array sizes, okay?


Re: sizeof() or direct number in functions and INI saving question - ElMaestro123 - 04.06.2018

Alright, thanks for answer, what about last question?


Re: sizeof() or direct number in functions and INI saving question - Eoussama - 04.06.2018

Quote:
Originally Posted by ElMaestro123
Посмотреть сообщение
Alright, thanks for answer, what about last question?
Sure, but can you be a little more explicit with your last question?


Re: sizeof() or direct number in functions and INI saving question - ElMaestro123 - 04.06.2018

For example, I have a stock function which contains over 50 INI_Write. Right.
So, I use it many times after a player buys something, etc, so I was wondering if I could use INI_Write for only variables that need to be saved at that moment? Would the files stay the same way they were supposed to be if I used the stock for saving or would it miss many data that was supposed to be saved?


Re: sizeof() or direct number in functions and INI saving question - Eoussama - 04.06.2018

I don't see why you would saving information at specific moments aside from updating password or something that's related to security, it would be fine to save all the data when the player disconnects, or maybe, set a timer that sets all player's stats every X minutes or so.


Re: sizeof() or direct number in functions and INI saving question - Exhibit - 04.06.2018

Quote:
Originally Posted by ElMaestro123
Посмотреть сообщение
For example, I have a stock function which contains over 50 INI_Write. Right.
So, I use it many times after a player buys something, etc, so I was wondering if I could use INI_Write for only variables that need to be saved at that moment? Would the files stay the same way they were supposed to be if I used the stock for saving or would it miss many data that was supposed to be saved?
You can make other stocks for the variables that need to be saved.


Re: sizeof() or direct number in functions and INI saving question - iSpark - 04.06.2018

You can check if the variables were changed and only save those variables.
And FYI sizeof is a special miscellaneous operator. Not a function.


Re: sizeof() or direct number in functions and INI saving question - ElMaestro123 - 05.06.2018

Thanks all. I guess I will stay at this moment with a stock function.


Re: sizeof() or direct number in functions and INI saving question - sniker2020 - 05.06.2018

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
sizeof is a compiler directive (not a function, thus you can omit the braces too), it's processed at compile time, whether you use hard-coded numbers or sizeof has no effect on your server's performance, let's just not get crazy with array sizes, okay?
Thank you for that attention.
You helped me too.