Kick/Ban Don't appear
#1

Hello guys, I am facing that problem since the begging of the 0.3x Releasing :l

Ok, when i /kick Mario
He don't see that he's kicked ... he just get's Server Closed Connection.
Even in /ban... he don't know why he got banned

I am using "LuxAdmin"


Код:
dcmd_kick(playerid,params[])
{
	if(AccInfo[playerid][LoggedIn] == 1)

	{
	    if(AccInfo[playerid][Level] >= 3)
		{
      		new Index;
		    new tmp[256];  tmp  = strtok(params,Index);
			new tmp2[256]; tmp2 = strtok(params,Index);
		    if(!strlen(params)) return
			SendClientMessage(playerid, LIGHTBLUE2, "Usage: /kick [PlayerID] [Reason]") &&
			SendClientMessage(playerid, orange, "Function: Will Kick the specified player");
	    	new player1;
	    	new string[128];
			new playername[MAX_PLAYER_NAME];
		 	new adminname [MAX_PLAYER_NAME];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
			 {
				GetPlayerName(player1, playername, sizeof(playername));
				GetPlayerName(playerid, adminname, sizeof(adminname));
				SendCommandToAdmins(playerid,"Kick");
				if(!strlen(tmp2))
				{
				format(string,sizeof(string),"|- %u has been kicked by Administrator %u | Reason: Not Specified -|",playername,adminname);
				SendClientMessageToAll(grey,string);
				SaveIn("KickLog",string);
				print(string);
				return Kick(player1);
				}
				else
				{
				format(string,sizeof(string),"|- %u has been kicked by Administrator %u | Reason: %s -|",playername,adminname,params[2]);
				SendClientMessageToAll(grey,string);
				SaveIn("KickLog",string); print(string);
				return Kick(player1);
				}
			}
			else return ErrorMessages(playerid, 3);
		}
		else return ErrorMessages(playerid, 1);
	}
	else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
//==============================================================================
dcmd_ban(playerid,params[])
{
	if(AccInfo[playerid][LoggedIn] == 1)
	{
		if(AccInfo[playerid][Level] >= 4)
		{
			new Index;
		    new tmp[256];  tmp  = strtok(params,Index);
			new tmp2[256]; tmp2 = strtok(params,Index);
			
		    if(!strlen(params)) return
			SendClientMessage(playerid, LIGHTBLUE2, "Usage: /ban [PlayerID] [Reason]") &&
			SendClientMessage(playerid, orange, "Function: Will Ban the specified player");
			if(!strlen(tmp2))
			return SendClientMessage(playerid, red, "ERROR: Reason unspecified!");
			new player1;
	    	new string[128];
			new playername[MAX_PLAYER_NAME];
		 	new adminname [MAX_PLAYER_NAME];
			player1 = strval(tmp);

		 	if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID && player1 != playerid && (AccInfo[player1][Level] != ServerInfo[MaxAdminLevel]))
			{
				GetPlayerName(player1, playername, sizeof(playername));
				GetPlayerName(playerid, adminname, sizeof(adminname));
				new year,month,day; getdate(year, month, day);
				new hour,minuite,second; gettime(hour,minuite,second);
				SendCommandToAdmins(playerid,"Ban");
				format(string,sizeof(string),"|- %s has been Banned by Administrator %s | Reason: %s [Date: %d/%d/%d] [Time: %d:%d]",playername,adminname,params[2],day,month,year,hour,minuite);
				SendClientMessageToAll(lightred,string);
    			new str[128];
				format(str,sizeof(str),"%s has been Banned by Administrator %s | Reason: %s",playername,adminname,params[2]);
				SaveIn("BanLog",str);
				print(string);
				if(udb_Exists(PlayerName2(player1)) && AccInfo[player1][LoggedIn] == 1)
				dUserSetINT(PlayerName2(player1)).("Banned",1);
				format(string,sizeof(string),"Banned by Administrator %s. | Reason: %s",adminname,params[2]);
				return BanEx(player1, string);
			}
			else return SendClientMessage(playerid, red, "ERRPR: Player is not connected or is yourself or is the highest level admin");
		}
		else return ErrorMessages(playerid, 1);
	}
	else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
+Rep if u helped me
Reply
#2

You'll need to make a timer before kicking/banning them so they can see the message. There's a basic include on the forums for it.
Reply
#3

You need to set a timer before kicking,as Kick command has more priority than others,so it will ignore a message if you have it before the Kick();
For example
pawn Код:
forward KickMsg(playerid);
public KickMsg(playerid)
{
  Kick(playerid);
  return 1;
}
//THen set a timer after sending a msg
//Sending some msg here when kicking
SetTimerEx("KickMsg", 1000, false, "i", playerid);//kicking him after the msg- 1 second delay to show the msg
Reply
#4

From samp wiki:

Quote:

Important Note: As of SA-MP 0.3x, any action taken before Kick() (such as sending a message with SendClientMessage) will not work. A timer must be used to delay the kick.

Код:
//In order to display a message (eg. reason) for the player before the connection is closed
you have to use a timer to create a delay. This delay needs only to be a few milliseconds long,
but this example uses a full second just to be on the safe side.
 
forward KickPublic(playerid);
public KickPublic(playerid) Kick(playerid);
 
stock KickWithMessage(playerid, color, message[])
{
    SendClientMessage(playerid, color, message);
    SetTimerEx("KickPublic", 1000, 0, "d", playerid); 	//Delay of 1 second before kicking the player so he recieves the message
}
 
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/kickme", true) == 0)
    {
        //Kicks the player who the executed this command
        KickWithMessage(playerid, 0xFF0000FF, "You have been kicked.");
        return 1;
    }
    return 0;
}
//by Kye
Reply
#5

You must assign a timer which kicks after 1.0 delay as the wiki says.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)