fwrite problem - 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: fwrite problem (
/showthread.php?tid=397111)
fwrite problem -
kacklappen2012 - 03.12.2012
hello,
i started scripting a few days ago and i wanted to try to make a first simple reallife gamemode. everything works pretty well except one thing i just can't store variables in a file and read them out. after a while i came up with this solution
Код:
#include <a_samp>
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Testing Filter ");
print("--------------------------------------\n");
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/buylicense", cmdtext, true, 10) == 0)
{
new File:stats = fopen("/stats.txt", io_write);
if(stats)
{
fwrite(stats, "license = 1");
fclose(stats);
}
return 1;
}
if (strcmp("/check", cmdtext, true, 10) == 0)
{
new string[64];
new File:stats = fopen("stats.txt", io_read);
while(fread(stats, string))
{
if(strcmp(string,"license",true) ==0)
{
SendClientMessage(playerid,0xFF0000FF,"You bought a license.");
}
if(strcmp(string,"license",false) ==0)
{
SendClientMessage(playerid,0xFF0000FF,"You didn't bought a license.");
}
}
fclose(stats);
return 1;
}
return 0;
}
but i can still not read the variables and use them. it creates a text file and stores the variable in it but that's it. i hope somebody can help me because i really need this.
Re: fwrite problem -
Azazelo - 03.12.2012
You may use Dini , Y_ini and i will suggest you to use Database is faster.
If you just start to make game mode.
Re: fwrite problem -
Konstantinos - 03.12.2012
Quote:
Originally Posted by Azazelo
You may use Dini , Y_ini and i will suggest you to use Database is faster.
If you just start to make game mode.
|
This.
Saving players' data by using functions from file.inc is outdated.
Re: fwrite problem -
LarzI - 03.12.2012
Quote:
Originally Posted by Dwane
This.
Saving players' data by using functions from file.inc is outdated.
|
Not to mention inefficient
Re: fwrite problem -
kacklappen2012 - 03.12.2012
Quote:
Originally Posted by Azazelo
You may use Dini , Y_ini and i will suggest you to use Database is faster.
If you just start to make game mode.
|
thanks a lot now everything works
Re: fwrite problem -
Gh05t_ - 03.12.2012
Quote:
Originally Posted by Dwane
This.
Saving players' data by using functions from file.inc is outdated.
|
Quote:
Originally Posted by LarzI
Not to mention inefficient
|
Not to mention inefficient
What are you lads on about? These file systems USE the native file functions. High level library uses seemingly low level I/O therefore control is still passed to those functions making these systems SLOWER. With the right workaround (something I believe ****** has done
) (use of macros etc) there is but any difference in speed or efficiency.