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


Messages In This Thread
fwrite problem - by kacklappen2012 - 03.12.2012, 12:03
Re: fwrite problem - by Azazelo - 03.12.2012, 12:11
Re: fwrite problem - by Konstantinos - 03.12.2012, 12:14
Re: fwrite problem - by LarzI - 03.12.2012, 12:33
Re: fwrite problem - by kacklappen2012 - 03.12.2012, 13:27
Re: fwrite problem - by Gh05t_ - 03.12.2012, 14:16

Forum Jump:


Users browsing this thread: 2 Guest(s)