Help with the banning command
#1

This command isn't working properly.. please help me fixing it .
pawn Код:
enum pInfo
{
    pIP[16]
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
{
    new playerb[32], string[256], file[256], cmdstring[44], ipstring[16];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s[32]", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /uban [name]");
    if(RPIDFN(playerb) != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Player is connected to the server.");
    format(file, sizeof(file), "UserDB/%s.ini", playerb);
    if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
    new INI:File = INI_Open(file);
    INI_SetTag(File,"PlayerData");
    INI_WriteString(File, "BanReason", "None");
    INI_WriteString(File, "BannedBy", "None");
    INI_WriteInt(File, "Banned", 0);
    INI_Close(File);
    INI_ParseFile(file, "LoadIP_%s", .bExtra = true , .extra = playerid);
    printf("1) %s", file);
    format(ipstring, sizeof(ipstring), "%s", PlayerInfo[playerid][pIP]);
    new File:ban = fopen("ban.cfg", io_read);
    new idx = 1;
    while(fread(ban, ipstring))
    {
        if(!strcmp(ipstring, string, true, strlen(ipstring)))
        {
            fdeleteline("ban.cfg", idx);
            //done = 1;
        }
        idx++;
    }
    fclose(ban);
    printf("2) %s", ipstring);
    //if(!done) return SendClientMessage(playerid, COLOR_GREY, "IP is not banned.");
    format(cmdstring, sizeof(cmdstring), "unbanip %s", ipstring);
    SendRconCommand(cmdstring);
    printf("3) %s", cmdstring);
    SendRconCommand("reloadbans");
    format(string, sizeof(string), "{F81414}AdmWarn: %s has {DAE368}unbanned{F81414} %s [IP: %s].", RPN(playerid), playerb, ipstring);
    SendClientMessageToAll(COLOR_YELLOW, string);
    //SendAdminMessage(COLOR_DARKRED, 1, string);
    return 1;
}
pawn Код:
forward LoadIP_data(playerid,name[],value[]);
public LoadIP_data(playerid,name[],value[])
{
    INI_String("IP", PlayerInfo[playerid][pIP], 16);
    return 1;
}
Its not unbanning the IP. this is what it prints:
pawn Код:
[14:46:34] 1) UserDB/Ricardo_James.ini
[14:46:34] 2)
[14:46:34] 3) unbanip
2 & 3 doesn't print the ip, when it should..
Reply
#2

And where are you using LoadIP_data?
Reply
#3

Quote:
Originally Posted by Matess
Посмотреть сообщение
And where are you using LoadIP_data?
in the command.
pawn Код:
INI_ParseFile(file, "LoadIP_%s", .bExtra = true , .extra = playerid);
this line.
Reply
#4

Ah my bad I work only with mysql so i can't help you. Well it isn't saving IP to variable but idk why.
Reply
#5

Show me your ban command now, I can do something.
Reply
#6

Quote:
Originally Posted by biker122
Посмотреть сообщение
Show me your ban command now, I can do something.
pawn Код:
CMD:banip(playerid, params[])
{
    new playerb, string[128], IP[50];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");

    if(sscanf(params, "ds[128]", playerb, params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /banip [playerid] [reason]");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(playerb == playerid) return SendClientMessage(playerid, COLOR_GREY, "Why would you want to ban yourself?");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[playerb][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "Player has a higher admin level than you.");
    format(string, sizeof(string), "{F81414}AdmCmd: %s has been {DAE368}ip banned{F81414} by %s, {FFFFFF}reason: %s", RPN(playerb), RPN(playerid), params);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    iEcho(string);
    // Banning
    GetPlayerIp(playerb, IP, sizeof(IP));
    PlayerInfo[playerb][pBanned] = 1;
    // Banreason
    if(fexist(UserDB(playerb)))
    {
        new INI:File = INI_Open(UserDB(playerb));
        INI_SetTag(File,"PlayerData");
        INI_WriteInt(File, "Banned", PlayerInfo[playerb][pBanned]);
        INI_WriteString(File, "BanReason", params);
        INI_WriteString(File, "BannedBy", RPNU(playerb));
        INI_Close(File);
        // BanList
        AddBan(playerb);
        format(string, sizeof(string), "banip %s", IP);
        SendRconCommand(string);
        Kick(playerb);
    }
    else SendClientMessage(playerid, COLOR_WHITE, "Invalid playerid.");
    return 1;
}
pawn Код:
stock AddBan(playerid)
{
    new string[24];
    new File:ban = fopen("ban.cfg", io_append);
    format(string, sizeof(string), "%s\r\n", RPIP(playerid));
    fwrite(ban, string);
    fclose(ban);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)