Invalid IP Adress
#1

I've made this command , but i don't know why this don't works ...

pawn Код:
if(strcmp(cmd, "/banip", true) == 0)
    {
        if(PlayerInfo[playerid][pAdmin] >= 1338)
      {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp))
            {
            SendClientMessage(playerid,COLOR_WHITE,"USAGE: /banip [IP]");
            return 1;
            }
            new INVALID;
            for(new i = 0 , j = strlen(string); i < j; i++)
            {
                if(string[i] == '.')
                INVALID++;
            }
            if(INVALID != 3)
            {
                SendClientMessage(playerid,COLOR_YELLOW,"That is not a valid IP address.");
                return 1;
            }
            if(strlen(string[0]) > 18)
            {
                SendClientMessage(playerid,COLOR_YELLOW,"That is not a valid length for a IP address.");
                return 1;
            }
            new name[24];
            new banipstring[64];
            GetPlayerName(playerid,name,sizeof(name));
            format(banipstring,sizeof(banipstring),"banip %s",string);
            format(string,sizeof(string),"[BAN-IP] Name: %s || IP: %d",name,banipstring);
            SendClientMessage(playerid,COLOR_WHITE,string);
            print(string);
            SendRconCommand(banipstring);
            return 1;
        }
        else
        {
          SendClientMessage(playerid,COLOR_WHITE,ADMIN_TEXT);
          return 1;
        }
    }
/banip 5.555.555.555 => This is not a valid ip adress
Reply
#2

pawn Код:
if(strlen(string[0]) > 21)
  return SendClientMessage(playerid,COLOR_YELLOW,"That is not a valid length for a IP address.");
Reply
#3

http://dl.fisier.ro/files/ir7anki7bff8lkr/sa-mp-009.png

http://dl.fisier.ro/files/ec74ogb7lag81o8/sa-mp-010.png
Reply
#4

I was wrong in the first code.
pawn Код:
if(strlen(string[0]) < 21)
  return SendClientMessage(playerid,COLOR_YELLOW,"That is not a valid length for a IP address.");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)