SA-MP Forums Archive
Is this kind of reading possible? - 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: Is this kind of reading possible? (/showthread.php?tid=360884)



Is this kind of reading possible? - liinor - 19.07.2012

Text in Ban.ini
192.168.0.10 liinor lol
OnPlayerConnect
pawn Code:
new ConnIP[50];
new server_IP[50];
GetPlayerIp(playerid,ConnIP,50);
    format(server_IP, 50, "%d",ConnIP);
    new banreason[256];
    new string2[64]; // Create the string to store the read text in
   

    new lol[100];
    new named[100];
    new fileip[100];

    new File:example = fopen("Bans.Ini", io_read); // Open the file
    while(fread(example, string2)) //reads the file line-by-line
    {
    format(string2, sizeof(string2), "%d %s %d",fileip,named,banreason);
   

    if(strcmp(string2, ConnIP, true) == 0) //if any of the lines in the file say "Ban" the system will ban the player
    {

 
   
    format(lol,sizeof(lol),"%s who got ban on that ip %s",banreason,named);
    SendClientMessage(playerid,COLOR_RED,lol);
    SendClientMessage(playerid,COLOR_ORANGE,"You are banned from the server!");
    //Kick(playerid);
    break;
    }
   
    }
    fclose(example);
please i need help.