Help with kick command
#1

Its kicking but it doesn't show message


Код:
CMD:kick(playerid,params[])
{
	if(PInfo[playerid][Level] < 1)
	return SendClientMessage(playerid,-4,"You need to be level 1 to kick players");
	new id;
	if(sscanf(params,"u",id))
	return SendClientMessage(playerid,-1,"USAGE: /kick <id>");
	if(!IsPlayerConnected(id))
	return SendClientMessage(playerid,-4,"That player is not connected!");
	Kick(id);
	new string[64],pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,pName,sizeof(pName));
	format(string,sizeof(string),"%s has kicked %s",pName);
	SendClientMessageToAll(CORAL,string);
	new name[64];
	GetPlayerName(playerid,pName,sizeof(pName));
	format(name,sizeof(name),"%s has kicked you.",name);
	SendClientMessage(playerid,CORAL,name);
	SetTimerEx("DelayedKick", 1000, false, "i", playerid);
	return 1;
}
Reply
#2

"Kick" does not give time to send the message.
Create a timer of about 500 milliseconds which kicks him, and use that instead.
Reply
#3

pawn Код:
forward Kicker(playerid);
public Kicker(playerid)
{
     Kick(playerid);
     return true;
}
And change your Kick(id); to this :
pawn Код:
SetTimerEx("Kicker", 450, false, "i", id);
EDIT: There is a fail in your script. You have to change the "playerid" in the SetTimerEx to id. If you don't do it, the /kick command will kick the administrator and not the player.
Reply
#4

Here is my code,it is still not working,shows server closed connection but no message

Код:
CMD:kick(playerid,params[])
{
	if(PInfo[playerid][Level] < 1)
	return SendClientMessage(playerid,-4,"You need to be level 1 to kick players");
	new id;
	if(sscanf(params,"u",id))
	return SendClientMessage(playerid,-1,"USAGE: /kick <id>");
	if(!IsPlayerConnected(id))
	return SendClientMessage(playerid,-4,"That player is not connected!");
	Kick(id);
	new string[64],pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid,pName,sizeof(pName));
	format(string,sizeof(string),"%s has kicked %s",pName);
	SendClientMessageToAll(CORAL,string);
	new name[64];
	GetPlayerName(playerid,pName,sizeof(pName));
	format(name,sizeof(name),"%s has kicked you.",name);
	SendClientMessage(playerid,CORAL,name);
	SetTimerEx("DelayedKick", 3000, false, "i", id);
	return 1;
}

forward DelayedKick(playerid);
public DelayedKick(playerid)
{
    Kick(playerid);
    return 1;
}
Reply
#5

pawn Код:
Kick(id);
Lol, hide that from the top. After the return of IsPlayerConnected
Reply
#6

ah i get it,ty for help
i used it 2 times
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)