How to read from a list from a text file?
#1

I understand kinda how file reading works, but I can't get my script to work.

If someone joins the server with a listed IP, they will be opped, simple as that. I dont know how to read for each IP, etc.

pawn Код:
public OnPlayerConnect(playerid)
{
    GameTextForPlayer(playerid,"~r~Destruction Derby",5000,5);
    RemoveBuildingForPlayer(playerid, 11394, -2048.1641, 168.3125, 31.7344, 0.25); //Class Select
    IsPlayerJoined[playerid] = false;
   
    new File:oplist = fopen("oplist.txt");
    if(oplist)
    {
        new str[128];
        while(fread(oplist, str))
        {
            new playerIP[16];
            GetPlayerIp(playerid, playerIP, 16);
            if(strcmp(playerIP, str) == 0)
            {
                IsOp[playerid] = true;
                SendClientMessage(playerid, -1, "Use /ophelp to see the op guide.");
            }
        }
        fclose(oplist);
    }
    else
    {
        print("The file \"oplist.txt\" does not exists, or can't be opened.");
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)