Thread: [L4D] Boss Rush
View Single Post
Author Message
Beatles
Senior Member
Join Date: Feb 2014
Old 07-27-2021 , 02:23   [L4D] Boss Rush
Reply With Quote #1

This plugin was written for L4D2, and although I have tried to do this same function in L4D1, I have not been successful, I would like to know if someone can help me with the equivalents of these 2 values in L4D1:

L4D_GetVersusMaxCompletionScore
L4D_SetVersusMaxCompletionScore

Or some way to be able to do this same function in L4D1.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <left4dhooks>

new iDistance;
new 
witchIndex;

new 
bool:bTankPointsFrozen;
new 
bool:bWitchPointsFrozen;

public 
Plugin:myinfo 
{
    
name "L4D2 No Boss Rush",
    
author "Visor; originally by Jahze, vintik",
    
version "2.1",
    
description "Stops distance points accumulating whilst the Tank or Witch are alive",
    
url "https://github.com/Attano/Equilibrium"
};

public 
OnPluginStart()
{
    
HookEvent("round_start"EventHook:OnRoundStartEventHookMode_PostNoCopy);
    
HookEvent("tank_spawn"EventHook:OnTankSpawnEventHookMode_PostNoCopy);
    
HookEvent("player_death"OnPlayerDeath);
    
HookEvent("witch_spawn"OnWitchSpawn);
    
HookEvent("witch_killed"EventHook:OnWitchKilledEventHookMode_PostNoCopy);
}

public 
OnRoundStart()
{
    if (
InSecondHalfOfRound())
    {
        
UnFreezePoints();
    }
}

/* Tank */

public OnTankSpawn()
{
    if (!
bTankPointsFrozen && !bWitchPointsFrozen)
    {
        
PrintToChatAll("\x01[\x04NoBossRush\x01] Tank spawned. Freezing distance points!");
        
bTankPointsFrozen true;
        
FreezePoints();
    }
}

public 
Action:OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
IsTank(client))
    {
        
CreateTimer(0.1CheckForTanksDelayTIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
OnClientDisconnect(client
{
    if (
IsTank(client))
    {
        
CreateTimer(0.1CheckForTanksDelayTIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action:CheckForTanksDelay(Handle:timer
{
    if (
FindTank() == -1)
    {
        if (
bTankPointsFrozen
        {
            
PrintToChatAll("\x01[\x04NoBossRush\x01] Tank is dead. Unfreezing distance points!");
            
bTankPointsFrozen false;
            
UnFreezePoints();
        }
    }
}

/* Witch */

public Action:OnWitchSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
bTankPointsFrozen && !bWitchPointsFrozen)
    {
        
witchIndex GetEventInt(event"witchid");
        
PrintToChatAll("\x01[\x04NoBossRush\x01] Witch spawned. Freezing distance points!");
        
bWitchPointsFrozen true;
        
FreezePoints();
    }
}

public 
OnWitchKilled()
{
    if (
bWitchPointsFrozen)
    {
        
PrintToChatAll("\x01[\x04NoBossRush\x01] Witch is dead. Unfreezing distance points!");
        
bWitchPointsFrozen false;
        
UnFreezePoints();
        
witchIndex = -1;
    }
}

public 
OnEntityDestroyed(entity)
{
    if (
entity == witchIndex)
    {
        
OnWitchKilled();
    }
}

/* Shared */

FreezePoints() 
{
    
iDistance L4D_GetVersusMaxCompletionScore();
    
L4D_SetVersusMaxCompletionScore(0);
}

UnFreezePoints() 
{
    
L4D_SetVersusMaxCompletionScore(iDistance);
}

FindTank() 
{
    for (new 
1<= MaxClientsi++) 
    {
        if (
IsTank(i) && IsPlayerAlive(i)) 
        {
            return 
i;
        }
    }
    return -
1;
}

bool:IsTank(client)
{
    if (
client <= || !IsClientInGame(client) || GetClientTeam(client) != 3)
        return 
false;

    if (
GetEntProp(clientProp_Send"m_zombieClass") != 8)
        return 
false;

    return 
true;
}

InSecondHalfOfRound()
{
    return 
GameRules_GetProp("m_bInSecondHalfOfRound");


Last edited by Beatles; 07-27-2021 at 02:30.
Beatles is offline