SA-MP Forums Archive
Kick(playerid) function bug? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Kick(playerid) function bug? (/showthread.php?tid=571492)



Kick(playerid) function bug? - RaeF - 19.04.2015

It's just me or no?

when i do

Код:
#include <a_samp>

public OnPlayerConnect(playerid)
{
	Kick(playerid);
	return 1;
}

main() {}
im not kicked out but look like this:

[Server log]
Код:
[11:33:29] Incoming connection: 192.168.1.100:55694 id: 0
[11:33:30] [join] RaefaldhiAmartya has joined the server (0:192.168.1.100)
[11:33:30] [part] RaefaldhiAmartya has left the server (0:2)
[11:33:45] Incoming connection: 192.168.1.100:55696 id: 0
[11:33:45] [join] RaefaldhiAmartya has joined the server (0:192.168.1.100)
[11:33:45] [part] RaefaldhiAmartya has left the server (0:2)
[11:33:57] Incoming connection: 192.168.1.100:55698 id: 0
[11:33:57] [join] RaefaldhiAmartya has joined the server (0:192.168.1.100)
[11:33:57] [part] RaefaldhiAmartya has left the server (0:2)
[11:36:10] Incoming connection: 192.168.1.100:50523 id: 0
[11:36:10] [join] RaefaldhiAmartya has joined the server (0:192.168.1.100)
[11:36:10] [part] RaefaldhiAmartya has left the server (0:2)
[Client Log]
Код:
[11:33:25] {FFFFFF}SA-MP {B9C9BF}0.3.7-RC4-1 {FFFFFF}Started

[11:33:28] Connecting to 192.168.1.100:7777...

[11:33:30] Connected. Joining the game...

[11:33:45] Lost connection to the server. Reconnecting..

[11:33:45] The server is restarting..

[11:33:45] Connecting to 192.168.1.100:7777...

[11:33:45] Connected. Joining the game...

[11:33:57] Lost connection to the server. Reconnecting..

[11:33:57] The server is restarting..

[11:33:57] Connecting to 192.168.1.100:7777...

[11:33:57] Connected. Joining the game...

[11:36:10] Lost connection to the server. Reconnecting..

[11:36:10] The server is restarting..

[11:36:10] Connecting to 192.168.1.100:7777...

[11:36:10] Connected. Joining the game...

[11:36:10] Server closed the connection.



Re: Kick(playerid) function bug? - Lordzy - 19.04.2015

Kick function used under OnPlayerConnect has got some issue. I doubt it's because Kick function is called before server accepting the client completely. All you've to do is to delay the kick or the best thing is to use delayed OnPlayerConnect.

pawn Код:
new
     g_PlayerOPCTimer[MAX_PLAYERS] = {-1, ...};

public OnPlayerConnect(playerid) {

    if(g_PlayerOPCTimer[playerid] == -1)
        g_PlayerOPCTimer[playerid] = SetTimerEx("SafeOnPlayerConnect", 300, false, "i", playerid);
    return 1;
}

forward SafeOnPlayerConnect(playerid);

public SafeOnPlayerConnect(playerid) {

    g_PlayerOPCTimer[playerid] = -1;
    if(!IsPlayerConnected(playerid)) return 1; //It has got a 300ms delay, it's possible to loose connection in that delay.
    //codes
    return 1;
}



Re: Kick(playerid) function bug? - RaeF - 19.04.2015

Ok thanks !,