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



Help with /kick - nicholasramdhan - 24.03.2015

Okay so, I got this kick command, BUT, when I kick the player, it just tells them 'Server Closed the Connection.', but they don't get the reason for me kicking them. How can I make it to where they see the reason?


Код:
CMD:kick(playerid, params[])
{
	if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
    new giveplayerid, string[128], Reason;
	if(!sscanf(params, "us[128]", giveplayerid, Reason))
	{
		if(IsPlayerConnected(giveplayerid))
		{
			format(string, sizeof(string), "AdmCmd: %s has been kicked by %s. Reason: %s", PlayerName(giveplayerid), PlayerName(playerid), Reason);
			SendClientMessageToAll(COLOR_ORANGE, string);
			format(string, sizeof(string), "KICK: %s has been kicked by %s (%s). Reason: %s", PlayerName(giveplayerid), PlayerName(playerid), GetPlayerIpEx(playerid), Reason);
			Log("Logs/Kick.log", string);
			Kick(giveplayerid);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "Invalid Player Specified.");
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Kick [Player Id] [Reason]");
	}
	return 1;
}



Re: Help with /kick - SickAttack - 24.03.2015

Make a timer:
pawn Код:
stock KickPlayer(playerid) return SetTimerEx("KickPlayerEx", 100, false, "i", playerid);

function KickPlayerEx(playerid) return Kick(playerid);
And replace "Kick(...);" with "KickPlayer(...);".


Re: Help with /kick - JaydenJason - 24.03.2015

a 100ms timer is needed for the Player to see, as you can see above


Re: Help with /kick - nicholasramdhan - 24.03.2015

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Make a timer:
pawn Код:
stock KickPlayer(playerid) return SetTimerEx("KickPlayerEx", 100, false, "i", playerid);

function KickPlayerEx(playerid) return Kick(playerid);
And replace "Kick(...);" with "KickPlayer(...);".
I don't really know how to do that, can you add it to the current code that I gave please?


Re: Help with /kick - nicholasramdhan - 24.03.2015

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
a 100ms timer is needed for the Player to see, as you can see above
Can you show me how to add it to my code? I tried adding it but I got errors about Undefined Symbols..


Re: Help with /kick - X337 - 24.03.2015

Use this complete code
Код:
CMD:kick(playerid, params[])
{
	if(!IsLoggedEx(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login before using any commands.");
    new giveplayerid, string[128], Reason[128];
	if(!sscanf(params, "us[128]", giveplayerid, Reason))
	{
		if(IsPlayerConnected(giveplayerid))
		{
			format(string, sizeof(string), "AdmCmd: %s has been kicked by %s. Reason: %s", PlayerName(giveplayerid), PlayerName(playerid), Reason);
			SendClientMessageToAll(COLOR_ORANGE, string);
			format(string, sizeof(string), "KICK: %s has been kicked by %s (%s). Reason: %s", PlayerName(giveplayerid), PlayerName(playerid), GetPlayerIpEx(playerid), Reason);
			Log("Logs/Kick.log", string);
			format(string, sizeof(string), "You have been kicked with reason: %s", Reason);
			KickWithReason(giveplayerid, string);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "Invalid Player Specified.");
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Kick [Player Id] [Reason]");
	}
	return 1;
}

stock KickWithReason(playerid, msg[])
{
	SendClientMessage(playerid, COLOR_WHITE, msg);
	SetTimerEx("Kick_Ex", 1000, false, "d", playerid);
	return 1;
}

forward Kick_Ex(playerid);
public Kick_Ex(playerid)
{
	return Kick(playerid);
}
You need to use KickWithReason(playerid, reason[]); to kick players


Re: Help with /kick - nicholasramdhan - 24.03.2015

Thanks man! I'm gonna +REP you tomorrow when I can rep again.