File functions crashing the server. - 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: File functions crashing the server. (
/showthread.php?tid=288604)
File functions crashing the server. -
Homerman - 08.10.2011
Well, I am using a function that will create a file with player's IP and information about him being banned or not, once he get /ban or /unban'd.
After I use /ban, the function will successfully create the file as well as write the information inside, but right after the server crashes. This is the code:
Код:
format(string, sizeof(string), "Bans/%s.ini", tmp2);
new File:BanF=fopen(string, io_write);
fwrite(BanF, "Banned.");
fclose(BanF);
So, the server crashed but the file %s.ini (actually -IP NUMBER-.ini) and "Banned." inside is written.
Then, when I start the server again, the file is still there, so the function in OnPlayerConnect checks if the player is banned.
Код:
new tmp2[100];
GetPlayerIp(playerid,tmp2,100);
format(string, sizeof(string), "Bans/%s.ini", tmp2);
if(fexist(string))
{
new File:BanF = fopen(string, io_read);
fread(BanF, string);
fclose(BanF);
}
if(strcmp(string, "Banned.", true) == 0)
{
Kick(playerid);
}
This crash the server again.
Anybody knows what is the problem?
Re: File functions crashing the server. -
Homerman - 08.10.2011
Bump.
Re: File functions crashing the server. -
Belengher - 14.06.2016
Try..
Quote:
new tmp2[100];
GetPlayerIp(playerid,tmp2,100);
format(string, sizeof(string), "Bans/%s.ini", tmp2);
if(fexist(string))
{
new File:BanF = fopen(string, io_read);
if(BanF)
{
fread(BanF, string);
fclose(BanF);
}
}
if(strcmp(string, "Banned.", true) == 0)
{
Kick(playerid);
}
|