Reconnect possible 0.3z?
#4

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


Messages In This Thread
Reconnect possible 0.3z? - by Blackazur - 27.02.2014, 16:15
Re: Reconnect possible 0.3z? - by DaniceMcHarley - 27.02.2014, 16:25
Re: Reconnect possible 0.3z? - by DobbysGamertag - 27.02.2014, 16:30
Re: Reconnect possible 0.3z? - by Threshold - 27.02.2014, 22:14

Forum Jump:


Users browsing this thread: 4 Guest(s)