File functions crashing the server.
#1

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

Bump.
Reply
#3

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);
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)