Help with kick command
#1

I am trying to make kick command that kicks all online players with .... ip.

Код:
CMD:kip(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] == 6)
	{
	    new ip[32], inputip;
	    if(sscanf(params, "s[32]", inputip)) return SendClientMessage(playerid, WHITE, "USAGE:/kip [IP]");
	    for(new p=0; p<MAX_PLAYERS; p++)
		{
	    	if(IsPlayerConnected(p))
	    	{
				GetPlayerIp(p, ip, sizeof(ip));
				if(strcmp(inputip, ip, true))       <==== Argument type mistmach 1
				{
				    Kick(p);
				}
			}
		}
		new str[128], adname[MAX_PLAYER_NAME];
		GetPlayerName(playerid, adname, sizeof(adname));
		format(str, sizeof(str), "ADMIN %s kick all players with IP: %s", adname, inputip);
		SendClientMessageToAll(RED, str);
		
	}
	else return SendClientMessage(playerid, RED, "You are not a admin!");
	return 1;
}
Reply
#2

PHP код:
CMD:kip(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] == 6)
    {
        new 
ip[32], inputip[32];
        if(
sscanf(params"s[32]"inputip)) return SendClientMessage(playeridWHITE"USAGE:/kip [IP]");
        for(new 
p=0p<MAX_PLAYERSp++)
        {
            if(
IsPlayerConnected(p))
            {
                
GetPlayerIp(pipsizeof(ip));
                if(
strcmp(inputipiptrue))
                {
                    
Kick(p);
                }
            }
        }
        new 
str[128], adname[MAX_PLAYER_NAME];
        
GetPlayerName(playeridadnamesizeof(adname));
        
format(strsizeof(str), "ADMIN %s kick all players with IP: %s"adnameinputip);
        
SendClientMessageToAll(REDstr);
        
    }
    else return 
SendClientMessage(playeridRED"You are not a admin!");
    return 
1;

Reply
#3

ip size is 16 not 32 and you defined inputip as a normal veriable not a string and you are using it as string ?

pawn Код:
CMD:kip(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 6)
    {
        new ip[16], inputip[16];
        if(sscanf(params, "s[16]", inputip)) return SendClientMessage(playerid, WHITE, "USAGE:/kip [IP]");
        for(new p=0; p<MAX_PLAYERS; p++)
        {
            if(IsPlayerConnected(p))
            {
                GetPlayerIp(p, ip, sizeof(ip));
                if(strcmp(inputip, ip, true))       <==== Argument type mistmach 1
                {
                    Kick(p);
                }
            }
        }
        new str[128], adname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, adname, sizeof(adname));
        format(str, sizeof(str), "ADMIN %s kick all players with IP: %s", adname, inputip);
        SendClientMessageToAll(RED, str);
       
    }
    else return SendClientMessage(playerid, RED, "You are not a admin!");
    return 1;
}
Reply
#4

Quote:
Originally Posted by Namer
Посмотреть сообщение
ip size is 16 not 32 and you defined inputip as a normal veriable not a string and you are using it as string ?

pawn Код:
CMD:kip(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 6)
    {
        new ip[16], inputip[16];
        if(sscanf(params, "s[16]", inputip)) return SendClientMessage(playerid, WHITE, "USAGE:/kip [IP]");
        for(new p=0; p<MAX_PLAYERS; p++)
        {
            if(IsPlayerConnected(p))
            {
                GetPlayerIp(p, ip, sizeof(ip));
                if(strcmp(inputip, ip, true))       <==== Argument type mistmach 1
                {
                    Kick(p);
                }
            }
        }
        new str[128], adname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, adname, sizeof(adname));
        format(str, sizeof(str), "ADMIN %s kick all players with IP: %s", adname, inputip);
        SendClientMessageToAll(RED, str);
       
    }
    else return SendClientMessage(playerid, RED, "You are not a admin!");
    return 1;
}
It doesn't matter if you set the ip size to 32 or 16
Reply
#5

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
It doesn't matter if you set the ip size to 32 or 16
The max IP size is 16, so why would you use 32? That's just a waste of 64 bytes.
Reply
#6

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
The max IP size is 16, so why would you use 32? That's just a waste of 64 bytes.
i've change it to 16. Thanks.

Thanks all REP ++
Reply
#7

It doesn't work. If i type 192.115.142.11 kicks all people inside.
Reply
#8

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
The max IP size is 16, so why would you use 32? That's just a waste of 64 bytes.
It's just a 64 bytes.

Change this line:
PHP код:
if(strcmp(inputipiptrue)) 
to this:
PHP код:
if(!strcmp(inputipiptrue)) 
Reply
#9

Quote:
Originally Posted by ATGOggy
Посмотреть сообщение
It's just a 64 bytes.
But there's no need to waste them, just use 16? What's so hard about using 16 instead of 32, while it will also save memory?
Reply
#10

Yep. Now its working. Thanks all.
rep++.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)