Server closes connection on everyone after banning someone
#1

The title may not be as specific as I wanted it to be but it partly describes my problem.

I recently developed a script to ban players. Once I ban a player (for debug purposes, myself) the server kicks me showing me a dialog, up on this point everything is working correctly. The same player (for debug purposes, myself) reconnects to the server and gets kicked immediately after connecting (Not wrong) but it shows no dialog. I then reconnect using another name and the same thing happens. The only thing that fixes the problem is by removing my kick function but that's not an option for obvious reasons.

NOTE: after banning someone, nobody is able to connect (same issue).

So, I think the problem lays with my Kick function:
pawn Код:
public KickEx(playerid)
{
    if(Session[playerid][Kicked])
        return false;

    Session[playerid][Kicked] = true;
    SetTimerEx("Delay_Kick", false, 1000, "i", playerid);
    return true;
}

public Delay_Kick(playerid)
{
    if(Session[playerid][Kicked])
    {
        return Kick(playerid);
    }
    return false;
}
I've tried to remove the IF statement. I've tried removing the whole kick function and only use a SetTimerEx on the places where a player had to be kicked, that didn't work either. I tried raising the timer count, that didn't work. I ran out of possible solutions and therefor requesting help on the forum.


Thanks in advance.
Reply
#2

Can you show us the code where you're using the kick function?
Reply
#3

Of course.

This code is executed after a player connected and when his IP or Name is in the ban table.
pawn Код:
cache_get_data(rows, fields, mysql);
    if(rows)
    {
        cache_get_field_content(0, "IP", playerip, 16);
        cache_get_field_content(0, "Admin", banner, 24);
        cache_get_field_content(0, "Date", Date, 36);
        cache_get_field_content(0, "Reason", bReason, 50);

        format(temp, sizeof(temp), "You are banned from the server.\n\nUsername:\t%s\nIP:\t%s\nBanned by:\t%s\nDate:\t%s\nReason:\t%s", GetName(playerid), playerip, banner, Date, bReason);
        ShowPlayerDialog(playerid, dBanned, Dialog_Message, "-", temp, "Close", "");
        KickEx(playerid);
    }
Reply
#4

Works fine for me when I use this:

Код:
public OnPlayerConnect(playerid)
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "-", "Testing 123", "Close", "");
    SetTimerEx("KickPlayer", 250, false, "i", playerid);
    return 1;
}

forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
}
Reply
#5

Quote:
Originally Posted by Tamy
Посмотреть сообщение
Works fine for me when I use this:

Код:
public OnPlayerConnect(playerid)
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "-", "Testing 123", "Close", "");
    SetTimerEx("KickPlayer", 250, false, "i", playerid);
    return 1;
}

forward KickPlayer(playerid);
public KickPlayer(playerid)
{
    Kick(playerid);
    return 1;
}
When I reset the server after banning a player, everything works the way it should. Everything goes horribly wrong when a banned player connects a second time after the server reset.

Server_Log shows nothing unusual other than 'incoming connection' sometimes followed by no message at all.
Everyone who tries to connect after the banned player connected twice gets kicked immediately after connecting.
Reply
#6

Pretty weird. Make sure there isn't any variable left which doesn't reset under OnPlayerDisconnect and is used again during the ban-check.
Reply
#7

Quote:
Originally Posted by Tamy
Посмотреть сообщение
Pretty weird. Make sure there isn't any variable left which doesn't reset under OnPlayerDisconnect and is used again during the ban-check.
I double checked and it seemed all the be alright.
Reply
#8

Well, in that case, I would create a debug script which would show all my callbacks/functions which are called and it should show where and what is causing it.
Reply
#9

Quote:
Originally Posted by Tamy
Посмотреть сообщение
Well, in that case, I would create a debug script which would show all my callbacks/functions which are called and it should show where and what is causing it.
I'm on it. I'll post the results once it's done.

EDIT: I see what happens, the kick function gets stuck in an infinite loop. I'm fixing it now.
EDIT2: Fixed. Apparently I can't return Kick in the Delay_Kick function.
Reply
#10

Glad I could help you, thanks for the rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)