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



Help with kick command - Nabster - 14.02.2015

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;
}



Re: Help with kick command - CalvinC - 14.02.2015

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


Re : Help with kick command - streetpeace - 14.02.2015

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.


Re: Help with kick command - Nabster - 14.02.2015

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;
}



Re : Help with kick command - streetpeace - 14.02.2015

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


Re: Help with kick command - Nabster - 14.02.2015

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