fwrite problem
#1

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.
Reply
#2

You may use Dini , Y_ini and i will suggest you to use Database is faster.
If you just start to make game mode.
Reply
#3

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.
Reply
#4

Quote:
Originally Posted by Dwane
Посмотреть сообщение
This.
Saving players' data by using functions from file.inc is outdated.
Not to mention inefficient
Reply
#5

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
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)