kick() function doesn't work in callback, stock, etc
#1

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

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

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

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

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

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

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 ?
Reply
#8

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

Yes, is a sa-mp bug.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)