Player reconnect after Kick() in OnPlayerConnect()
#1

When you kick the player in OnPlayerConnect() then player will reconnect to your server after 4-5 seconds.
Please do something with this.
Thanks!

This is very big problem for those servers, that use own ban system.

Edit: Not in OnPlayerConnect(), after OnPlayerConnect().
( SetTimerEx("KickPlayer", 1000, false, "d", playerid); // in OnPlayerConnect() )
Here the code:

pawn Code:
OnPlayerConnect:
   
    // Autologin
        format(query, sizeof(query), "SELECT * FROM `players` WHERE `name` = '%s' AND `ip` = '%s'", pName(playerid), ip);
        mysql_query_ex(query);
        mysql_store_result();

        //printf("Autologin2");
        if(mysql_num_rows() != 0)
        {
            // print("Try To Login OnPlayerConnect");
            new
                CurrLine[1024];
            mysql_fetch_row(CurrLine);
            mysql_free_result();

            sscanf(CurrLine, "p<|>d{s[24]s[128]s[20]s[20]s[128]s[24]s[24]dddddddddddddddfffddffffddddffdddddd}", PlayerInfo[playerid][pRegID]);

            format(query, sizeof(query), "SELECT * FROM `bans` WHERE `reg_id` = %d OR `ip` = '%s'", PlayerInfo[playerid][pRegID], ip);
            mysql_query_ex(query);
            mysql_store_result();

            if(mysql_num_rows() != 0)
            {
                new
                    ban_time,
                    ban_id,
                    bool:Elfogadva = true;
                mysql_fetch_row(line);
                mysql_free_result();

                sscanf(line, "p<|>ds[24]ds[24]d{s[16]s[128]}s[128]s[24]d", ban_id, name, vID, country, player1, query, tmp, ban_time);
               
                if(ban_time != 0)
                {
                    getdate(year, month, day);
                    gettime(hour, minute, second);
                    datez = mktime(hour, minute, second, day, month, year);
                    if(ban_time < datez)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "Ban ideje letelt! Unbannolva vagy!");
                        Elfogadva = false;
                        format(query, sizeof(query), "DELETE FROM `bans` WHERE `id` = %d", ban_id);
                        mysql_query_ex(query);
                    }
                }
                if(Elfogadva)
                {
                    date(ban_time, day, month, year, hour, minute, second);
                    for(i = 0; i < 10; i++) SendClientMessage(playerid, COLOR_YELLOW, " ");
                    // print("Nem fut le more");
                    SendClientMessage(playerid, COLOR_WHITE, ":: {" #XCOLOR_RED "}BAN {" #XCOLOR_WHITE "}:: Bannolt: {" #XCOLOR_ORANGE "}%s. RegID: %d", country, player1);
                    SendClientMessage(playerid, COLOR_WHITE, ":: {" #XCOLOR_RED "}BAN {" #XCOLOR_WHITE "}:: Indok: %s", query);
                    SendClientMessage(playerid, COLOR_WHITE, ":: {" #XCOLOR_RED "}BAN {" #XCOLOR_WHITE "}:: Időpont: %s", tmp);
                    if(!ban_time)
                    {
                        SendClientMessage(playerid, COLOR_WHITE, ":: {" #XCOLOR_RED "}BAN {" #XCOLOR_WHITE "}:: Ban feloldбsa: SOHA ( Kivйve ha nemkйrsz UnBan-t )");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_WHITE, ":: {" #XCOLOR_RED "}BAN {" #XCOLOR_WHITE "}:: Ban feloldбsa: %02d.%02d.%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
                    }
                    printf("Banned 1");
                    SendClientMessage(playerid, COLOR_WHITE, ":: {" #XCOLOR_RED "}BAN :: UnBan kйrelem: http://www.nm-ss.tarhely.biz -> Unban Kйrelem -> Ide nyitsz egy tйmбt!");
                    SendClientMessageToAll(COLOR_WHITE, ":: {" #XCOLOR_DEFAULT "}BAN :: {" #XCOLOR_YELLOW "}%s(%d) {" #XCOLOR_WHITE "}kickelve lett, mivel bannolva van a szerverről! (BanID: %d)", pName(playerid), playerid, ban_id);
                 
                    SetTimerEx("KickPlayer", 1000, false, "d", playerid);
                    return 1;
                }
            }
            else
            {
                mysql_free_result();
            }

            LoginPlayer(playerid, CurrLine);
            //print("Lefutott, Very nice :)");

            switch(GetPVarInt(playerid, "Level"))
            {
                case 0: country = "~w~Jбtйkos";
                case 1: country = "~b~Moderбtor";
                case 2: country = "~g~Adminisztrбtor";
                case 3: country = "~y~Főadmin";
                case 4: country = "~r~Tulajdonos";
            }
            // print("After InfoTD");


        }
        else
        {
            // print("Else free_result");
            mysql_free_result();
        }

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

Usually only hackers can fast relog after kick.
Reply
#3

Quote:
Originally Posted by BigETI
View Post
Usually only hackers can fast relog after kick.
Not only.

I tested it.
Not immediately, after 4-5 seconds or later. But the client re-connect to the server.
So it's not hack.
Reply
#4

Then it has to be something in this variables not closing the players connection, but reconnecting them.
Reply
#5

Code:
Not immediately, after 4-5 seconds or later. But the client re-connect to the server.
So it's not hack.
All players is reconnect.
I have the same problem - https://sampforum.blast.hk/showthread.php?tid=307920
Reply
#6

Can you recreate a code for us wich will do this?
Reply
#7

robintjeh,
Code:
CMD:kick(playerid, params[])
{
    if(IsPlayerAdmin(playerid) == 0)
        return 0;

	new player,
        powod[64]; //powod == reason
        
    if(sscanf(params, "ds[64]", player, powod))
        return SCM(playerid, 0xFFFFFFFF, "/kick [id] [powуd]");

    if(!IsPlayerConnected(player) || IsPlayerNPC(player))
        return SCM(playerid, 0xEE0000FF, "Ten gracz nie jest podłączony!");

	format(str, sizeof str, "Gracz {D9D9D9}%s{EE0000} zostal wyrzucony przez administratora {D9D9D9}%s{EE0000}.", PlayerName(player),PlayerName(playerid));
    SCM_All(0xEE0000FF, str);
    format(str, sizeof str, "Powуd: {D9D9D9}%s", powod);
    SCM_All(0xEE0000FF, str);
	Kick(player);
    return 1;
}
This can be tested by giving the function Kick () in the loop.
Reply
#8

Tested with
pawn Code:
public OnPlayerConnect(playerid)
{
    Kick(playerid);
    return 1;
}
I can't confirm this..
Reply
#9

Code:
Number of vehicle models: 164
Incoming connection: 192.168.1.3:61711
[join] kurta999 has joined the server (0:192.168.1.3)
OnPlayerConnect(playerid = 0) <END>
SavePlayer(playerid = kurta999(0))
OnPlayerDisconnect(playerid = 0, reason = 2) <END>
[part] kurta999 has left the server (0:2)
Incoming connection: 192.168.1.3:61712
[join] kurta999 has joined the server (0:192.168.1.3)
Banned 1
OnPlayerDisconnect(playerid = 0, reason = 2) <END>
[part] kurta999 has left the server (0:2)
Incoming connection: 192.168.1.3:61713
[join] kurta999 has joined the server (0:192.168.1.3)
Banned 1
OnPlayerDisconnect(playerid = 0, reason = 2) <END>
[part] kurta999 has left the server (0:2)
Incoming connection: 192.168.1.3:61714
[join] kurta999 has joined the server (0:192.168.1.3)
Banned 1
OnPlayerDisconnect(playerid = 0, reason = 2) <END>
[part] kurta999 has left the server (0:2)
Incoming connection: 192.168.1.3:61715
[join] kurta999 has joined the server (0:192.168.1.3)
Banned 1
OnPlayerDisconnect(playerid = 0, reason = 2) <END>
[part] kurta999 has left the server (0:2)
Here the video:
Interesting where the Server Closed the connection message O_o
Reply
#10

I have the same problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)