SA-MP Forums Archive
Unbanning an IP - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Unbanning an IP (/showthread.php?tid=265843)



Unbanning an IP - Skylar Paul - 02.07.2011

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.


Re: Unbanning an IP - TheGarfield - 02.07.2011

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;
}



Re: Unbanning an IP - Skylar Paul - 02.07.2011

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;
}