SA-MP Forums Archive
kick() function doesn't work in callback, stock, etc - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: kick() function doesn't work in callback, stock, etc (/showthread.php?tid=398864)



kick() function doesn't work in callback, stock, etc - Falcon. - 11.12.2012

Hello,

I thought it was something with my script, but i compile new.pwn and resulted in same.

when kick(playerid) is called, the server restart (like gmx), but only for me.


compiled code:
pawn Код:
#include <a_samp>

main()
{
    print("SA-MP Forums");
}

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

Falcon(playerid)
{
    Kick(playerid);
    return 0x01;
}

server_log.txt show this:
Код:
----------------------------------
[17:00:09]  Blank Gamemode by your name here
[17:00:09] ----------------------------------

[17:00:09] Number of vehicle models: 0
[17:00:43] Incoming connection: 127.0.0.1:55154
[17:00:44] [join] Falcon has joined the server (0:127.0.0.1)
[17:00:44] [part] Falcon has left the server (0:2)
[17:00:59] Incoming connection: 127.0.0.1:55155
[17:00:59] [join] Falcon has joined the server (0:127.0.0.1)
[17:00:59] [part] Falcon has left the server (0:2)
[17:01:11] Incoming connection: 127.0.0.1:55156



Re: kick() function doesn't work in callback, stock, etc - ReVo_ - 11.12.2012

if you use Kick in OnPlayerConnect this could happen, use a timer or OnPlayerRequestClass (?)


Re: kick() function doesn't work in callback, stock, etc - -Shifty- - 11.12.2012

I guess it's just timing out the player, I'm not sure about this.


Re: kick() function doesn't work in callback, stock, etc - Falcon. - 11.12.2012

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
if you use Kick in OnPlayerConnect this could happen, use a timer or OnPlayerRequestClass (?)
would be boring, the code actually does this:
pawn Код:
public OnPlayerConnect(playerid)
{
    //select status from contas where nickname = Falcon
    //  /\ return the value em Result(playerid);
    return 1;
}

Result(playerid)
{
    //if (status == 1) -> kick
    Kick(playerid);
    return 0x01;
}
but the player aren't kicked.



chatlog.txt
Код:
[17:00:40] {FFFFFF}SA-MP {B9B9BF}0.3e {FFFFFF}Started

[17:00:43] Connecting to 127.0.0.1:7777...

[17:00:44] Connected. Joining the game...

[17:00:59] Lost connection to the server. Reconnecting..

[17:00:59] The server is restarting..

[17:00:59] Connecting to 127.0.0.1:7777...

[17:00:59] Connected. Joining the game...

[17:01:11] Lost connection to the server. Reconnecting..

[17:01:11] The server is restarting..

[17:01:11] Connecting to 127.0.0.1:7777...

[17:01:21] The server didn't respond. Retrying..

[17:01:21] Connecting to 127.0.0.1:7777...

[17:01:21] You are banned from this server.



Re: kick() function doesn't work in callback, stock, etc - ReVo_ - 11.12.2012

Instead of use Kick:

SetTimerEx("KickEx", 500 (500 ms should be enough, increase if not), false, "i", playerid);

forward KickEx(playerid);
public KickEx(playerid)
{
Kick(playerid);
return 0;
}

As i already said, use of Kick in OnPlayerConnect can cause this problem


Re: kick() function doesn't work in callback, stock, etc - CrazyChoco - 11.12.2012

May i ask, why do you guys forward it? You could although use it like:

SetTimerEx("KickEx", 500 (500 ms should be enough, increase if not), false, "i", playerid);


KickEx(playerid)
{
Kick(playerid);
return 0;
}

I'm not sure, but il'll think it will work in the same way. I don't use this but i just have a thought


Re: kick() function doesn't work in callback, stock, etc - Falcon. - 11.12.2012

weird, before in another script i used without settime and worked fine.

o.х now is working, thanks for help

edit: this is a sa-mp server bug ?


Re: kick() function doesn't work in callback, stock, etc - ReVo_ - 11.12.2012

SetTimer/SetTimerEx calls a callback, and all callbacks needs a forward and public

Yes, is a sa-mp bug.