Which is better - 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: Which is better (
/showthread.php?tid=72474)
Which is better -
CBFASI - 08.04.2009
Ok got a gamemode, with a series of filterscripts.
User data is used by each filterscript, and this is saved using the dUser system
Have suspicsion that some lag is caused by mass file access, and also suspect some data errors, caused by same sort of issue.
Two different ways of doing same thing
Quote:
Originally Posted by Method 1
dUserSetINT(PlayerName(playerid)).("Dosh", dUserINT(PlayerName(playerid)).("Dosh") + giveamount);
|
Quote:
Originally Posted by Method 2
playermoney = dUserINT(PlayerName(playerid)).("Dosh2");
dUserSetINT(PlayerName(playerid)).("Dosh", playermoney+ giveamount);
|
Now I have a suspicision that the second might be a little easier on file access as its not double accessing in same command, but am I right in this thought??
Problem is this particular piece of data is critical and is accessed every time a user spends or gains money (yes I know about on screen money, this is all about reducing a chance of a hack as if the screen and file values done match..
Re: Which is better -
Weirdosport - 08.04.2009
They're the same thing in essence, if anything Method 2 is slightly worse as the server has to store and retrieve a variable.
Re: Which is better -
Pyrokid - 08.04.2009
I always use Method 1. No point in creating an extra variable.
Re: Which is better -
CBFASI - 09.04.2009
Here its not the variable but the file access thats the issue, is file access worse in 1 or 2 ?
Re: Which is better -
Weirdosport - 09.04.2009
It shouldn't make a difference as far as file access is concerned, but it will make a difference in terms of lag and extra lines (minuscule amount of lag).
For those reasons method 1 is preferable!