Help with /kick
#1

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;
}
Reply
#2

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(...);".
Reply
#3

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

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?
Reply
#5

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..
Reply
#6

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
Reply
#7

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


Forum Jump:


Users browsing this thread: 2 Guest(s)