SA-MP Forums Archive
Reconnect possible 0.3z? - 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: Reconnect possible 0.3z? (/showthread.php?tid=497578)



Reconnect possible 0.3z? - Blackazur - 27.02.2014

Hello, is a reconnect command to reconnect someone, still possible in 0.3z?


Re: Reconnect possible 0.3z? - Beckett - 27.02.2014

Was it even possible in the older versions?


Re: Reconnect possible 0.3z? - DobbysGamertag - 27.02.2014

Yus its in useful functions thread iirc, or use search


Re: Reconnect possible 0.3z? - Threshold - 27.02.2014

pawn Код:
new bool:reconnecting[MAX_PLAYERS];
new playersip[MAX_PLAYERS][16];

public OnPlayerConnect(playerid)
{
    reconnecting[playerid] = false;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/reconnectme", true) == 0)
    {
        if(reconnecting[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You are already being reconnected, please wait.");
        SendClientMessage(playerid, 0xFFFF00FF, "You are now being reconnected. Please wait while the server reconnects you.");
        GetPlayerIp(playerid, playersip[playerid], 16);
        reconnecting[playerid] = true;
        new rconmsg[25];
        format(rconmsg, sizeof(rconmsg), "banip %s", playersip[playerid]);
        SendRconCommand(rconmsg);
        return 1;
    }
    return 0;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(reconnecting[playerid])
    {
        new rconmsg[25];
        format(rconmsg, sizeof(rconmsg), "unbanip %s", playersip[playerid]);
        SendRconCommand(rconmsg);
        SendRconCommand("reloadbans");
    }
    return 1;
}
NOTE: This doesn't work 100% of the time, I don't know of any that actually does. If the player reconnects before the reloadbans command is actually sent (which can occur like 10% of the time), then it will deny him access to the server and he will have to /quit and relog. However, this is one of the only ways to actually reconnect a player as far as I know. Players won't be banned innocently however, the ip ban is removed when they disconnect. So don't worry about having to unban players that haven't been unbanned correctly.