SA-MP Forums Archive
Fastest and best INI files Registration system - 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: Fastest and best INI files Registration system (/showthread.php?tid=145142)



Fastest and best INI files Registration system - leapfish - 01.05.2010

Hello!
I need your help guys!

I'm working on optimizing my code, and I want to know what is the fastest and best INI files reader/writer, please if you know any advice to help me by posting in this topic...

Thank you in advance...


Re: Fastest and best INI files Registration system - Retardedwolf - 01.05.2010

DJson I think.

Search for it.


Re: Fastest and best INI files Registration system - leapfish - 01.05.2010

Are you sure DJson is a INI files reader/writer!?


Re: Fastest and best INI files Registration system - Retardedwolf - 01.05.2010

Yes.

http://forum.sa-mp.com/index.php?topic=71125.0


Re: Fastest and best INI files Registration system - Joe Staff - 01.05.2010

The best method is to just use the raw functions, making sure to save all variables at once.
example:
pawn Код:
stock save(playerid)
{
  new pname[24];
  GetPlayerName(playerid,pname,24);
  new File:file=fopen(pname,io_write);
  new string[128];
  format(string,128,"Score=%d\nCash=%d",GetPlayerScore(playerid,GetPlayerMoney(playerid));
  fwrite(file,string);
}
and NOT like this
pawn Код:
stock save(playerid)
{
  new pname[24];
  GetPlayerName(playerid,pname,24);
  new File:file=fopen(pname,io_write);
  new string[128];
  format(string,128,"Score=%d\n",GetPlayerScore(playerid));
  fwrite(file,string);
  format(string,128,"Cash=%d",GetPlayerMoney(playerid));
  fwrite(file,string);
}
Because the second method uses 'format' and 'fwrite' per variable, it has to run far more functions (assuming you have more than 2 variables to save)


Re: Fastest and best INI files Registration system - maij - 01.05.2010

Second method isn't very efficient either.
It formats for every variable while the above code does the same for multiple variables.
Even though, you will need a big string size if you use the above listed sample, or do it in parts anyways.
If you still want to use that second method by Joe Staff, use append to write it.


Re: Fastest and best INI files Registration system - leapfish - 01.05.2010

Which one is faster, second or DJson?

And also what do you mean "use append to write it" maij...


Re: Fastest and best INI files Registration system - Joe Staff - 01.05.2010

I was implying for him to use the first method, and you don't need to use append for the second.


Re: Fastest and best INI files Registration system - leapfish - 01.05.2010

Quote:
Originally Posted by Joe Staff
I was implying for him to use the first method, and you don't need to use append for the second.
Oh I didn't mean that..

First method = DJson
Second = your one

Which one to use, the question is...


Re: Fastest and best INI files Registration system - maij - 01.05.2010

I was referring to joe's 2 listed methods. My bad for making it wuzzy.