Quote:
Originally Posted by Chesterfield
Really looking foward this! keep up the good work!
|
Should be out tonight or tomorrow night. I have coded it now. Just need to test it.
PHP Code:
/* BanOn Disconnect */
new bool:g_disconnect[MAXPLAYERS + 1] = false;
new Handle:g_h_ban_on_disconnect = INVALID_HANDLE;
new Handle:sv_kick_ban_duration;
public OnPluginStart()
{
LoadTranslations("basebans.phrases");
/* Ban Convars */
g_h_ban_on_disconnect = CreateConVar("wm_ban_on_disconnect", "0", "Enable or disable players banned on disconnect if match is live", FCVAR_NOTIFY);
sv_kick_ban_duration = FindConVar("sv_kick_ban_duration");
HookEvent("player_disconnect", Event_Player_Disc_Pre, EventHookMode_Pre);
}
public OnClientPutInServer(client)
{
g_disconnect[client] = false;
}
public OnClientDisconnect(client)
{
if (g_live && GetConVarBool(g_h_ban_on_disconnect) && g_disconnect[client] == true)
{
new String:reason[32] = "Disconnected from live match";
new String:authid[32];
GetClientAuthId(client, AuthId_Steam2, authid, sizeof(authid));
ServerCommand("sm_addban %i %s %s", GetConVarInt(sv_kick_ban_duration), authid, reason);
PrintToChatAll("\x01 \x09[\x04%s\x09]\x01 %t", CHAT_PREFIX, "Banned player reason", authid, GetConVarInt(sv_kick_ban_duration), reason);
g_disconnect[client] = false;
}
}
public Event_Player_Disc_Pre(Handle:event, const String:name[], bool:dontBroadcast)
{
if (!IsActive(0, true))
{
return;
}
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new String:reason[128];
GetEventString(event, "reason", reason, sizeof(reason));
if (g_live && StrEqual(reason, "Disconnect"))
{
g_disconnect[client] = true;
}
else
{
g_disconnect[client] = false;
}
}
__________________