Unbanning an IP
#1

pawn Код:
CMD:unban(playerid, params[])
{
    new plrIP[16], string[128];
   
    if(PVar[playerid][pLevel] >= 4)
    {
   
        if(sscanf(params, "s[16]", plrIP))
        {
            format(string, sizeof(string), "unbanip %s", plrIP);
            SendRconCommand(string);

            format(string, sizeof(string), "[UNBAN] Admin %s has unbanned %s", pName(playerid), plrIP);
            SendMessageToAdmins(COLOR_LIGHTBLUE, string);
        }
        else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /Unban < IP Address >");
    }
    else return AdminCMD(playerid, 4);
    return 1;
}
What are IP addresses read as in sscanf? They're not a string, which confuses the hell out of me.
Reply
#2

pawn Код:
CMD:unban(playerid, params[])
{
    new plrIP[16], string[128];

    if(PVar[playerid][pLevel] >= 4)
    {

        if(sscanf(params, "s[30]", plrIP))// 16 for IP and other for unbanip
        {
            format(string, sizeof(string), "unbanip %s", plrIP);
            SendRconCommand(string);

            format(string, sizeof(string), "[UNBAN] Admin %s has unbanned %s", pName(playerid), plrIP);
            SendMessageToAdmins(COLOR_LIGHTBLUE, string);
        }
        else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /Unban < IP Address >");
    }
    else return AdminCMD(playerid, 4);
    return 1;
}
Reply
#3

Quote:
Originally Posted by TheGarfield
Посмотреть сообщение
pawn Код:
CMD:unban(playerid, params[])
{
    new plrIP[16], string[128];

    if(PVar[playerid][pLevel] >= 4)
    {

        if(sscanf(params, "s[30]", plrIP))// 16 for IP and other for unbanip
        {
            format(string, sizeof(string), "unbanip %s", plrIP);
            SendRconCommand(string);

            format(string, sizeof(string), "[UNBAN] Admin %s has unbanned %s", pName(playerid), plrIP);
            SendMessageToAdmins(COLOR_LIGHTBLUE, string);
        }
        else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /Unban < IP Address >");
    }
    else return AdminCMD(playerid, 4);
    return 1;
}
Actually, that wasn't the problem at all. I forgot an "!" infront of sscanf, so it didn't work properly. Here's the fixed command if you were curious:

pawn Код:
CMD:unban(playerid, params[])
{
    new plrIP[16], string[128];
   
    if(PVar[playerid][pLevel] >= 4)
    {
   
        if(!sscanf(params, "s[16]", plrIP))
        {
            //if(strlen(plrIP) < 16) return SendClientMessage(playerid, COLOR_RED, "Enter a valid IP Address!");
           
            format(string, sizeof(string), "unbanip %s", plrIP);
            SendRconCommand(string);
           
            SendRconCommand("reloadbans");

            format(string, sizeof(string), "[UNBAN] Admin %s has unbanned %s", pName(playerid), plrIP);
            SendMessageToAdmins(COLOR_LIGHTBLUE, string);
           
            printf(string);
        }
        else return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /Unban < IP Address >");
    }
    else return AdminCMD(playerid, 4);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)