Having a problem with Kicking with message -
LeXuZ - 25.11.2014
Hello, so I've made a ban command and with the ban it just bans and shows a message to the players, but not the banned player, for the banned player it shows Server closed connection, i wanted it to show why he has been banned.
I've also got the same problem onplayerconnect where if it reads the ban it just kicks the player not gives him a message.
Code:
Код:
ACMD:ban(playerid, params[])
{
if (pInfo[playerid][Adminlevel] < 2)return 0;
new reason[128], string[250];
if(sscanf(params, "us[128]",ID, reason))
return SCM(playerid, orange, "--- /ban <ID> <Reason> ---");
if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
pInfo[ID][Banned]=1;
GetPlayerName(ID,pname,MAX_PLAYER_NAME);
GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
SetTimerEx("KickTimer", 10, false, "i", playerid);
format(string, sizeof(string), "%s %s has banned %s for %s", AdminLevelName(playerid),Nam, pname, reason);
SCMToAll(red, string);
Kick(ID);
return 1;
}
and
Код:
public OnPlayerConnect(playerid)
{
if(pInfo[playerid][Banned]==1)
{
SCM(playerid, red, "You are banned from the server");
SetTimerEx("DelayedKick", 1000, false, "d", playerid);
Kick(playerid);
}
If you can help me that would be great! thank you
Re: Having a problem with Kicking with message -
DRCharlie - 25.11.2014
What does that KickTimer do? Can you also show us that timer?
Re: Having a problem with Kicking with message -
AnthonyTimmers - 25.11.2014
Please show us the timer, the problem is likely there.
EDIT: Put the Kick(playerid) in the timer, you start a timer and immediately kick the player. Send a message, THEN start a timer that kicks the player after x seconds.
Re: Having a problem with Kicking with message -
DRCharlie - 26.11.2014
Yeah I was thinking the same thing, lets hope he reads the thread and fixes it
Re: Having a problem with Kicking with message -
Banana_Ghost - 26.11.2014
pawn Код:
forward KickTimer(playerid);
ACMD:ban(playerid, params[])
{
if (pInfo[playerid][Adminlevel] < 2)return 0;
new reason[128], string[250];
if(sscanf(params, "us[128]",ID, reason))
return SCM(playerid, orange, "--- /ban <ID> <Reason> ---");
if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
pInfo[ID][Banned]=1;
GetPlayerName(ID,pname,MAX_PLAYER_NAME);
GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s %s has banned %s for %s", AdminLevelName(playerid),Nam, pname, reason);
SCMToAll(red, string);
//Kick(ID); Remove This, this is causing the timer to fail as it is closing the connection immediately
SetTimerEx("KickTimer", 1000, false, "i", playerid); 10ms isn't long enough to show the message, so i changed this to 100
return 1;
}
public OnPlayerConnect(playerid)
{
if(pInfo[playerid][Banned]==1)
{
SCM(playerid, red, "You are banned from the server");
SetTimerEx("KickTimer", 1000, false, "i", playerid);//You can use the same timer for this.
}
return 1;
}
public KickTimer(playerid)
{
Kick(playerid);
return 1;
}
Re: Having a problem with Kicking with message -
LeXuZ - 26.11.2014
Ah. this is great, thank you for the help! very much appreciated