SA-MP Forums Archive
Help with kick command - 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)
+--- Thread: Help with kick command (/showthread.php?tid=565935)



Help with kick command - Stoyanov - 02.03.2015

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



Re: Help with kick command - ATGOggy - 02.03.2015

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;




Re: Help with kick command - JeaSon - 02.03.2015

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



Re: Help with kick command - ATGOggy - 02.03.2015

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


Re: Help with kick command - CalvinC - 02.03.2015

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.


Re: Help with kick command - Stoyanov - 02.03.2015

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 ++


Re: Help with kick command - Stoyanov - 02.03.2015

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


Re: Help with kick command - ATGOggy - 02.03.2015

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)) 



Re: Help with kick command - CalvinC - 02.03.2015

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?


Re: Help with kick command - Stoyanov - 02.03.2015

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