03.12.2012, 12:03
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
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.
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; }