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



Silentkick - Zeus666 - 24.10.2018

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;




Re: Silentkick - NoSkillz - 24.10.2018

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


Re: Silentkick - Infin1ty - 24.10.2018

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



Re: Silentkick - Zeus666 - 24.10.2018

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.


Re: Silentkick - GangstaSunny. - 24.10.2018

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


Re: Silentkick - Zeus666 - 24.10.2018

Thanks Sunny


Re: Silentkick - Infin1ty - 24.10.2018

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.


Re: Silentkick - KinderClans - 24.10.2018

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



Re: Silentkick - Infin1ty - 24.10.2018

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!