Kick Dialog for the Kicked Player?
#1

Hi guys, here is my /Kick command, I want to do that if Admin kick a player, the player will become a dialog (showplayerdialog)

My kick code:

Код:
	if(strcmp(cmd, "/kick", true) == 0) // Kicks the player from the server
	{
		new reason[128];
		if (AccountInfo[playerid][AdminLevel] >= 3 || IsPlayerAdmin(playerid))
		{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "USAGE: /kick [name/id] [reason]");
				return true;
			}
			new giveplayername[MAX_PLAYER_NAME];
			new playername[MAX_PLAYER_NAME];
			new giveplayerid = ReturnUser(tmp);
			if(giveplayerid != INVALID_PLAYER_ID)
			{
			    GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
				GetPlayerName(playerid, playername, sizeof(playername));
				reason = bigstrtok(cmdtext, idx);
				if(!strlen(reason)) return SendClientMessage(playerid, ORANGE, "USAGE: /kick [name/id] [reason]");
				format(string2, sizeof(string2), "ADMIN: Admin %s has kicked %s. [Grund: %s ]", playername, giveplayername, reason);
				SendClientMessageToAll(ABLAU, string,string2);
				format(string,sizeof(string), "5ADMIN: Admin %s has kicked %s. [Reason: %s ]", playername, giveplayername, reason);
				Kick(giveplayerid);
				KickLog(string);
			}
			else if(giveplayerid == INVALID_PLAYER_ID)
			{
				format(string2, sizeof(string2), "Error: %i isn't an active player.", giveplayerid);
				SendClientMessage(playerid, ROT, string,string2);
			}
		}
		else SendClientMessage(playerid, ROT, "Error: You aren't authorized to use this command!");
		return true;
	}
Reply
#2

Before Kick(giveplayerid); add
pawn Код:
ShowPlayerDialog(giveplayerid,9999,DIALOG_STYLE_MSGBOX,"Notice","You have been kicked, behave yourself!","Dismiss","");
Make sure you use giveplayerid and NOT playerid
Reply
#3

I did but its not showing the Dialog
Reply
#4

If you are running 0.3x than it won't show you the dialog ..

pawn Код:
forward x_DKicked(playerid);
public x_DKicked(playerid) return Kick(playerid);

stock KickEx(playerid){
     SetTimerEx("x_DKicked", 300, false, "i", playerid);
}
And instead of Kick put KickEx
Reply
#5

And how can i do it "Kicked\n %s,reason); ??
With the dialog
Reply
#6

Something like this:
pawn Код:
format(string, sizeof(string), "Kicked\n: %s", reason);
ShowPlayerDialog(giveplayerid, DIALOG_ID, DIALOG_STYLE_MSGBOX, "Kicked from server", "%s", "Okay", "Okay", string);
SHOULD, work. Not tested though.
Reply
#7

In 0.3x, anything before the Kick function will probably not be shown to you, since the 'packets' are instantly stopped, so any Client message/dialogs will not be shown. Hence, you have to set a timer - Show the dialog, then set a timer of say a second of a DelayKick function where you kick the player.
Reply
#8

pawn Код:
//this before the Kick(giveplayerid);, make sure to delete the Kick(giveplayerid)!
new string[128];
format(string,128,"You have been kicked.\nReason: %s",reason);
ShowPlayerDialog(giveplayerid,9999,DIALOG_STYLE_MSGBOX,"Notice",string,"Dismiss","");
SetTimerEx("DelayKick",1200,0,"i",giveplayerid);//delay the kick by 1 second 200


//outside any callback, at the total bottom or your mode for example
forward DelayKick(playerid);
public DelayKick(playerid)
{
Kick(playerid); //kicks the playerid
}
Updated with Rajat_Pawar's suggestion.
Read the comments I wrote with the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)