SA-MP Forums Archive
File not reading correctly - 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 not reading correctly (/showthread.php?tid=418309)



File not reading correctly - Infinity90 - 24.02.2013

pawn Код:
while(fread(example, string2212))
    {
        if(!strcmp(playerip, string2212, true, 16)) {
            format(str123,sizeof(str123),"{00FF40}Your IP has been banned from this server\nOutput: %s\n{FF8000}To request a unban, visit http://www.gta-zombies.net and take a screen shot of this!",string2212);
            ShowPlayerDialog(playerid,9781,DIALOG_STYLE_MSGBOX,"{FF0000}You're banned from this server.",str123,"Okay","");
            SetTimerEx("KickPlayer",1000,0,"i",playerid);
        }
        fclose(example);
        return 0;
    }
The output in the file that it's meant to read is
EXAMPLE:
123.222.22.2 \r\n - Reads
127.0.0.1 \r\n - Doesn't read
123.123.123.2 \r\n - Doesn't read
----------------
It's only reading the first line, ones below that don't get read.


Re: File not reading correctly - Infinity90 - 24.02.2013

Anyone? I need help asap. Thanks in advance.


Re: File not reading correctly - Misiur - 24.02.2013

Reread your code step by step. Look what do you see. Now do it again. And again. And one more time to be sure. Now you know that loop is fired up once. But why doesn't it work further?

pawn Код:
while(fread(example, string2212))
{
    if(!strcmp(playerip, string2212, true, 16)) {
        format(str123,sizeof(str123),"{00FF40}Your IP has been banned from this server\nOutput: %s\n{FF8000}To request a unban, visit http://www.gta-zombies.net and take a screen shot of this!",string2212);
        ShowPlayerDialog(playerid,9781,DIALOG_STYLE_MSGBOX,"{FF0000}You're banned from this server.",str123,"Okay","");
        SetTimerEx("KickPlayer",1000,0,"i",playerid);
    }
    fclose(example); //This line
    return 0; //This line
}
What does fclose do? What does return do? You should know that by now.

pawn Код:
while(fread(example, string2212))
{
    if(!strcmp(playerip, string2212, true, 16)) {
        format(str123,sizeof(str123),"{00FF40}Your IP has been banned from this server\nOutput: %s\n{FF8000}To request a unban, visit http://www.gta-zombies.net and take a screen shot of this!",string2212);
        ShowPlayerDialog(playerid,9781,DIALOG_STYLE_MSGBOX,"{FF0000}You're banned from this server.",str123,"Okay","");
        SetTimerEx("KickPlayer",1000,0,"i",playerid);
        break;
    }
}
fclose(example);
return 0;
Have fun