View Single Post
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-06-2018 , 21:41   Re: Auto 1 day ban to Sourcebans on leaving server
Reply With Quote #5

Quote:
Originally Posted by Markiez View Post
Why not just?
Code:
#include <sourcemod>

#pragma semicolon 1

bool Ready;

public void OnPluginStart()
{
	HookEvent( "player_disconnect", Event_Disconnect, EventHookMode_Pre);
	RegConsoleCmd("sm_ready", Cmd_Ready);
}

public Action Cmd_Ready(int client, int args)
{
	Ready = true;
}

public Action Event_Disconnect(Event event, const char[] name, bool dbc)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if (Ready)
	{
		Ready = false;
		return;
	}
	
	BanClient(client, 1440, BANFLAG_AUTO, "some shit here");
}
You need to make an array for the Boolean for each client on the server to have its own value.

EDIT: You should also add return Plugin_Handled to the command's callback to register the command in the game's engine.

Last edited by ThatKidWhoGames; 05-07-2018 at 05:38.
ThatKidWhoGames is offline