06.05.2011, 17:51
RECONNECT CMD
I've received some request to send some people the reconnect code. So I decided to put it up here.
So about this script,
Normally if a player is pausing you want to kick him, and let him reconnect when he comes back, this is how it works:
----------------------------------------------------------------------------------------------------
1.) I've received some request to send some people the reconnect code. So I decided to put it up here.
So about this script,
Normally if a player is pausing you want to kick him, and let him reconnect when he comes back, this is how it works:
----------------------------------------------------------------------------------------------------
Rcon ban the ip with a code, but DON'T KICK the player.
2.) The player will then timeout, at OnPlayerDisconnect unban the ip that you've just banned -
remember that GetPlayerIP doesn't work in OnPlayerDisconnect, so store the value elsewhere.
3.) remember that GetPlayerIP doesn't work in OnPlayerDisconnect, so store the value elsewhere.
Player's Client will lose connection and attempt to auto-reconnect afterwards.
----------------------------------------------------------------------------------------------------
So here it is:
----------------------------------------------------------------------------------------------------
So here it is:
pawn Код:
#include <zcmd>
#define FILTERSCRIPT
new ireconnect[MAX_PLAYERS];
public OnPlayerDisconnect(playerid, reason)
{
if(ireconnect[playerid] == 1)
{
new unbanningip[16], string[128];
GetPVarString(playerid, "reconnect", unbanningip, 16);// Get the msg string from the PVar
format(string,sizeof(string),"unbanip %s", unbanningip);
SendRconCommand(string);
printf(string);
SendRconCommand("reloadbans");
ireconnect[playerid] = 0;
}
return 1;
}
//==============================================================================
// Reconnect
//==============================================================================
COMMAND:reconnect(playerid, params[])
{
new pid;
if(sscanf(params, "us", pid, params[2])) return SendClientMessage(playerid, 0xFF0000AA, "Command Usage: /reconnect [playerid] [reason]");
if(level[playerid] >= 1 || viplevel[playerid] == 2)//change these to the way you got it in your admin script. this is the way I got it, so..
{
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, red, "ERROR: That player is not online.");
new adminname[MAX_PLAYER_NAME], paramname[MAX_PLAYER_NAME], string[180];
new ip[16];
GetPlayerIp(pid, ip, sizeof(ip));
GetPlayerName(pid, paramname, sizeof(paramname));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string, sizeof(string), "Administrator %s has forced %s to reconnect. [Reason: %s]", adminname, paramname, params[2]);
SendClientMessageToAll(red, string);
print(string);
format(string, sizeof(string), "banip %s", ip);
SetPVarString(pid,"reconnect",ip);
ireconnect[pid] = 1;
SendRconCommand(string);
}
else SendClientMessage(playerid, red, "Error: You must be a higher level administrator to use that command.");
return 1;
}