AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Kick/Ban Hook (https://forums.alliedmods.net/showthread.php?t=338394)

AuricYoutube 07-02-2022 04:35

Kick/Ban Hook
 
Code:

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
    HookEvent("player_death", Event_PlayerDeath);
    HookEvent("client_disconnect", Event_PlayerDeath);
    HookEvent("player_team", Event_PlayerDeath);
}

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (AllHumansDead())
    {
        CS_TerminateRound(GetConVarFloat(FindConVar("mp_round_restart_delay")), CSRoundEnd_TerroristWin);
    }
}

bool:AllHumansDead()
{
    new bool:result = true;
   
    for (new i = 1; i <= MaxClients; i++)
    {
        if (IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT)
        {
            result = false;
        }
    }
   
    return result;
}

This plugin works when a player leaves, dies, changes team but it does not work when I kick the remaining alive player or if they get banned (not ending the round), how would I hook that?

Cruze 07-02-2022 10:22

Re: Kick/Ban Hook
 
try player_disconnect instead of client_disconnect


All times are GMT -4. The time now is 03:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.