Help with the banning command
#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


Messages In This Thread
Help with the banning command - by maximthepain - 09.08.2014, 11:48
Re: Help with the banning command - by Matess - 09.08.2014, 11:55
Re: Help with the banning command - by maximthepain - 09.08.2014, 11:57
Re: Help with the banning command - by Matess - 09.08.2014, 12:06
Re: Help with the banning command - by biker122 - 09.08.2014, 12:26
Re: Help with the banning command - by maximthepain - 09.08.2014, 12:46

Forum Jump:


Users browsing this thread: 1 Guest(s)