Silentkick
#1

Hi. When I use /kick on someone, instead of showing him the reason, he gets server closed without showing the reason but rest of the server can see it.
PHP код:
CMD:kick(playerid,params[])
{
    if(
pInfo[playerid][pAdminLevel] >= 1)
    {
        new 
targetid,reason[105],string[180];
        if(
sscanf(params"us[105]"targetid,reason)) return SendClientMessage(playerid,-1,""COL_RED"AdmCmds: /kick [PlayerID] [Reason]");
        if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""COL_RED"Error!");
        if(!
IsPlayerNPC(targetid))
        {
            
format(stringsizeof(string), ""COL_RED"AdmCmds: %s %s has kicked %s"COL_WHITE" [Reason: %s]",GetAdminName(playerid),PlayerName(playerid),PlayerName(targetid),reason);
            
SendClientMessageToAll(-1,string);
            
format(jQueryMAX_QUERY_LENGTH"INSERT INTO `"#sanctionlog"` (Username, Targetname, Comanda, Motivul, Data) VALUES ('%s', '%s', 'KICK', '%s', CURRENT_TIMESTAMP)",PlayerName(playerid), PlayerName(targetid), reason);
            
mysql_tquery(handlejQuery"""");
            
Kick(targetid);
        }
        else return 
SendClientMessage(playerid,-1,""COL_RED"ENPCe!");
    }
    else {
        
SendClientMessage(playerid,-1,""COL_RED"Error: Notadmin!");
    }
    return 
1;

Reply
#2

As I can understand you want silently kick the player, so Instead of SendClientMessageToAll you should use SendClientMessage
Reply
#3

Loop through all online players and if targetid does not equal to i then send the message. You may want to consider using strlib's sprintf function for formatting your SendClientMessage. I have purposefully put an error or two into either of the methods. You've just got to spot them, to hopefully get your brain thinking

Non-Foreach Method:
Код:
for (new i; i <= GetPlayerPoolSize(); i++)
{
	if(IsPlayerConnected(playerid))
	{
		if(i != targetid)
		{
			SendClientMessage(i, -1, sprintf("AdmCmds: %s was kicked by %s, reason: %s", name, adminname, reason));
		}
	}
}
Foreach Method:
Код:
foreach (new i : Player)
{
	if(i != targetid)
	{
		SendClientMessage(i, -1, sprintf("AdmCmds: %s was kicked by %s, reason: %s", name, adminname, reason));
	}
}
Reply
#4

Quote:
Originally Posted by NoSkillz
Посмотреть сообщение
As I can understand you want silently kick the player, so Instead of SendClientMessageToAll you should use SendClientMessage
No. I want to remove the silent kick.

If I kick myself, I just get the "Server Closed" text.

If a player gets kicked by me, he gets 'server closed" text, the kicked player doesn't get the reason of kicking or that he was kicked.
Reply
#5

Create a timer (for example one second) before realy kicking him.

And at least read the wiki next time, god damn...
https://sampwiki.blast.hk/wiki/Kick
Reply
#6

Thanks Sunny
Reply
#7

Quote:
Originally Posted by GangstaSunny.
Посмотреть сообщение
Create a timer (for example one second) before realy kicking him.

And at least read the wiki next time, god damn...
https://sampwiki.blast.hk/wiki/Kick
Or use kickbanfix.inc.
Reply
#8

pawn Код:
forward _KickPlayerDelayed(playerid)
public _KickPlayerDelayed(playerid)
{
    Kick(playerid);
    return 1;
}

DelayedKick(playerid, time = 500)
{
    SetTimerEx("_KickPlayerDelayed", time, false, "d", playerid);
    return 1;
}
In your kick command:

pawn Код:
DelayedKick(playerid);
Reply
#9

I suggest using kickbanfix personally as you won't have to modify any of your code since it uses ALS hooking and not any custom functions as the above solutions have. You just #include <kickbanfix> and you're ready to rock!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)