Having a problem with Kicking with message
#1

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
Reply
#2

What does that KickTimer do? Can you also show us that timer?
Reply
#3

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.
Reply
#4

Yeah I was thinking the same thing, lets hope he reads the thread and fixes it
Reply
#5

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;
}
Reply
#6

Ah. this is great, thank you for the help! very much appreciated
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)