SA-MP Forums Archive
/kick - 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: /kick (/showthread.php?tid=285109)



/kick - Max_Coldheart - 22.09.2011

Well, I've made a kick command that looks like this:
Код:
CMD:kick(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] >= 1)
	{
	    new kicked[MAX_PLAYER_NAME], kicker[MAX_PLAYER_NAME], reason[24], id;
	    if(sscanf(params, "us[24]", kicked, reason)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: /kick [ID/PartOfName] [Reaosn]");
	    else
	    {
	        new string[128];
			GetPlayerName(id, kicked, sizeof(kicked));
			GetPlayerName(playerid, kicker, sizeof(kicker));
			format(string, sizeof(string), "[ADMIN]: %s has been kicked by %s. Reason: %s.", kicked, kicker, reason);
			Kick(id);
		}
	}
	else return SendClientMessage(playerid, COLOR_GREY, "   You aren't authorized to use this command !");
	return 1;
}
It should work perfectly, but when I type /kick, I get "/kick : You are not an admin"
But such message isn't in my whole script!
What to do?


Re: /kick - Vince - 22.09.2011

Filterscripts?


Re: /kick - Max_Coldheart - 22.09.2011

Whoops, damn gl_actions


Re: /kick - IstuntmanI - 22.09.2011

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
Whoops, damn gl_actions
That's what I call a big fail xD

This looks better:
Код:
CMD:kick(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] == 1)
		return SendClientMessage(playerid, COLOR_GREY, "   You aren't authorized to use this command !");

	new kicked[MAX_PLAYER_NAME], kicker[MAX_PLAYER_NAME], reason[24], id;
	if(sscanf(params, "us[24]", kicked, reason)) 
		return SendClientMessage(playerid, COLOR_RED, "[SERVER]: /kick [ID/PartOfName] [Reaosn]");

	new string[128];
	GetPlayerName(id, kicked, sizeof(kicked));
	GetPlayerName(playerid, kicker, sizeof(kicker));
	format(string, sizeof(string), "[ADMIN]: %s has been kicked by %s. Reason: %s.", kicked, kicker, reason);
	Kick(id);
	return 1;
}



Re: /kick - Kingunit - 22.09.2011

The problem is fixed?


Re: /kick - Zh3r0 - 22.09.2011

Quote:
Originally Posted by costel_nistor96
Посмотреть сообщение
That's what I call a big fail xD

This looks better:
Код:
CMD:kick(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] == 1)
		return SendClientMessage(playerid, COLOR_GREY, "   You aren't authorized to use this command !");

	new kicked[MAX_PLAYER_NAME], kicker[MAX_PLAYER_NAME], reason[24], id;
	if(sscanf(params, "us[24]", kicked, reason)) 
		return SendClientMessage(playerid, COLOR_RED, "[SERVER]: /kick [ID/PartOfName] [Reaosn]");

	new string[128];
	GetPlayerName(id, kicked, sizeof(kicked));
	GetPlayerName(playerid, kicker, sizeof(kicker));
	format(string, sizeof(string), "[ADMIN]: %s has been kicked by %s. Reason: %s.", kicked, kicker, reason);
	Kick(id);
	return 1;
}
Don't act cocky. The way he made it is safer.


Re: /kick - Max_Coldheart - 22.09.2011

yes it got fixed, but now I've come across new problem. Every time I type /kick, instead of sending me the Client Message, it's crashing whole server. any ideas?


Re: /kick - PhoenixB - 22.09.2011

try this one
pawn Код:
COMMAND:kick(playerid, params[])
{
    new pid;
    if(PlayerInfo[playerid][Adminlevel] >= 1)
    {
        if(sscanf(params, "us[128]", pid, params[2])) return SendClientMessage(playerid,  0xFFFFFFFF, "/kick [playerid/name] [reason]");
        if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, 0xFFFFFFFF, "This player is not connected");
        new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
        GetPlayerName(pid, paramname, sizeof(paramname));
        GetPlayerName(playerid, adminname, sizeof(adminname));
        format(string, sizeof(string), "%s has been kicked by %s for: %s", paramname, adminname, params[2]);
        SendClientMessageToAll(AdminColor, string);
        Kick(pid);
    } else if(PlayerInfo[playerid][AdminLevel] == 0) return SendClientMessage(playerid, 0xAAAAAAAA, "You are not admin or the required level.");
    return 1;
}



Re: /kick - Zh3r0 - 22.09.2011

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
yes it got fixed, but now I've come across new problem. Every time I type /kick, instead of sending me the Client Message, it's crashing whole server. any ideas?
If you're using 0.3d then switch back to 0.3c since sscanf is not working properly, the 'u' specifier is bugged.


Or. You are using kicked to get player's id, but you use 'id' to kick the player.

pawn Код:
if(sscanf(params, "us[24]", kicked, reason))
but you kick the player wrongly
pawn Код:
Kick(id);
Should be
pawn Код:
Kick(kicked);
As, the variable kicked has the correct player id value.


Re: /kick - Max_Coldheart - 22.09.2011

When I change it to Kick(kicked);, my result is:
Код:
C:\Users\Max\Downloads\GTA San Andreas\samp03csvr_R2-2_win32\gamemodes\All_Admin_GM.pwn(710) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Current code:
Код:
CMD:kick(playerid, params[])
{
	if(PlayerInfo[playerid][AdminLevel] >= 1)
	{
	    new kicked[MAX_PLAYER_NAME], kicker[MAX_PLAYER_NAME], reason[24], id;
	    if(sscanf(params, "us[24]", kicked, reason)) return SendClientMessage(playerid, COLOR_RED, "[SERVER]: /kick [ID/PartOfName] [Reaosn]");
	    else
	    {
	        new string[128];
			GetPlayerName(id, kicked, sizeof(kicked));
			GetPlayerName(playerid, kicker, sizeof(kicker));
			format(string, sizeof(string), "[ADMIN]: %s has been kicked by %s. Reason: %s.", kicked, kicker, reason);
			Kick(kicked);
		}
	}
	else return SendClientMessage(playerid, COLOR_GREY, "   You aren't authorized to use this command !");
	return 1;
}