Raised This Month: $32 Target: $400
 8% 

[L4D2] No Infected Bots


Post New Thread Reply   
 
Thread Tools Display Modes
Squidinator
Junior Member
Join Date: Aug 2013
Old 08-22-2013 , 14:16   Re: [L4D2] No Infected Bots
Reply With Quote #11

I took the liberty of editing this slightly to add filtering capability. This works for me 100% of the time on a Windows server.

Code:
#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION     "0.92"

new bool:bEnabled = true;
new Handle:noSI_allowSmoker;
new Handle:noSI_allowBoomer;
new Handle:noSI_allowHunter;
new Handle:noSI_allowSpitter;
new Handle:noSI_allowJockey;
new Handle:noSI_allowCharger;
new Handle:hEnableCvar;

new noSI_SmokerSpawn;
new noSI_BoomerSpawn;
new noSI_HunterSpawn;
new noSI_SpitterSpawn;
new noSI_JockeySpawn;
new noSI_ChargerSpawn;

public Plugin:myinfo = 
{
    name = "No Infected Bots",
    author = "Mr. Zero",
    description = "Kick special infected bots.",
    version = PLUGIN_VERSION,
    url = "http://forums.alliedmods.net/showthread.php?t=118798"
}

public OnPluginStart()
{
    // Require Left 4 Dead 2
    decl String:game_name[64];
    GetGameFolderName( game_name, sizeof( game_name ) );
    if ( !StrEqual( game_name, "left4dead2", false ) )
    {
        SetFailState("Plugin supports Left 4 Dead 2 only.");
    }

    CreateConVar( "l4d2_noinfectedbots_version", PLUGIN_VERSION, "NoInfectedBots Version", FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD );
    hEnableCvar = CreateConVar( "noSI_enabled", "1", "Blocks infected bots from joining the game", FCVAR_PLUGIN, true, 0.0, true, 1.0 );

    noSI_allowSmoker = CreateConVar( "noSI_allowSmoker", "0", "Allow Smokers to spawn?", FCVAR_PLUGIN, true, 0.0, true, 1.0 );
    noSI_allowBoomer = CreateConVar( "noSI_allowBoomer", "0", "Allow Boomers to spawn?", FCVAR_PLUGIN, true, 0.0, true, 1.0 );
    noSI_allowHunter = CreateConVar( "noSI_allowHunter", "0", "Allow Hunters to spawn?", FCVAR_PLUGIN, true, 0.0, true, 1.0 );
    noSI_allowSpitter = CreateConVar( "noSI_allowSpitter", "0", "Allow Spitters to spawn?", FCVAR_PLUGIN, true, 0.0, true, 1.0 );
    noSI_allowJockey = CreateConVar( "noSI_allowJockey", "0", "Allow Jockeys to spawn?", FCVAR_PLUGIN, true, 0.0, true, 1.0 );
    noSI_allowCharger = CreateConVar( "noSI_allowCharger", "0", "Allow Chargers to spawn?", FCVAR_PLUGIN, true, 0.0, true, 1.0 );

    HookConVarChange( hEnableCvar, ConVarChange );
    HookConVarChange( noSI_allowSmoker, ConVarChange );
    HookConVarChange( noSI_allowBoomer, ConVarChange );
    HookConVarChange( noSI_allowHunter, ConVarChange );
    HookConVarChange( noSI_allowSpitter, ConVarChange );
    HookConVarChange( noSI_allowJockey, ConVarChange );
    HookConVarChange( noSI_allowCharger, ConVarChange );

    AutoExecConfig( true, "NoInfectedBots" );
    RegAdminCmd( "sm_infbots", ToogleInfectedBots_Command,ADMFLAG_BAN, "Toggles infected bots", _, FCVAR_PLUGIN );
}

public Action:ToogleInfectedBots_Command(client,args)
{
    if ( bEnabled )
    {
        SetConVarInt(hEnableCvar,0);
        ReplyToCommand(client,"[SM] Infected bots are now managed");
    }
    else
    {
        SetConVarInt(hEnableCvar,1);
        ReplyToCommand(client,"[SM] Infected bots are now managed");
    }
    return Plugin_Handled;
}

public ConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    bEnabled = GetConVarBool(hEnableCvar);
    if ( bEnabled )
    {
        UnsetCheatVar( FindConVar( "z_smoker_limit" ) );
        UnsetCheatVar( FindConVar( "z_boomer_limit" ) );
        UnsetCheatVar( FindConVar( "z_hunter_limit" ) );
        UnsetCheatVar( FindConVar( "z_spitter_limit" ) );
        UnsetCheatVar( FindConVar( "z_jockey_limit" ) );
        UnsetCheatVar( FindConVar( "z_charger_limit" ) );

        noSI_SmokerSpawn = GetConVarInt( noSI_allowSmoker );
        noSI_BoomerSpawn = GetConVarInt( noSI_allowBoomer );
        noSI_HunterSpawn = GetConVarInt( noSI_allowHunter );
        noSI_SpitterSpawn = GetConVarInt( noSI_allowSpitter );
        noSI_JockeySpawn = GetConVarInt( noSI_allowJockey );
        noSI_ChargerSpawn = GetConVarInt( noSI_allowCharger );

        SetConVarInt( FindConVar( "z_smoker_limit" ), noSI_SmokerSpawn );
        SetConVarInt( FindConVar( "z_boomer_limit" ), noSI_BoomerSpawn );
        SetConVarInt( FindConVar( "z_hunter_limit" ), noSI_HunterSpawn );
        SetConVarInt( FindConVar( "z_spitter_limit" ), noSI_SpitterSpawn );
        SetConVarInt( FindConVar( "z_jockey_limit" ), noSI_JockeySpawn );
        SetConVarInt( FindConVar( "z_charger_limit" ), noSI_ChargerSpawn );
    }
    else
    {
        ResetConVar( FindConVar( "z_smoker_limit" ) );
        ResetConVar( FindConVar( "z_boomer_limit" ) );
        ResetConVar( FindConVar( "z_hunter_limit" ) );
        ResetConVar( FindConVar( "z_spitter_limit" ) );
        ResetConVar( FindConVar( "z_jockey_limit" ) );
        ResetConVar( FindConVar( "z_charger_limit" ) );

        noSI_SmokerSpawn = 1;
        noSI_BoomerSpawn = 1;
        noSI_HunterSpawn = 1;
        noSI_SpitterSpawn = 1;
        noSI_JockeySpawn = 1;
        noSI_ChargerSpawn = 1;

        SetCheatVar( FindConVar( "z_smoker_limit" ) );
        SetCheatVar( FindConVar( "z_boomer_limit" ) );
        SetCheatVar( FindConVar( "z_hunter_limit" ) );
        SetCheatVar( FindConVar( "z_spitter_limit" ) );
        SetCheatVar( FindConVar( "z_jockey_limit" ) );
        SetCheatVar( FindConVar( "z_charger_limit" ) );
    }
}

public bool:OnClientConnect(client, String:rejectmsg[],maxlen)
{
    // If it's a human avatar stop right here.
    if ( !IsFakeClient( client ) || !bEnabled )
    {
        return true;
    }

    decl String:name[10];
    GetClientName(client, name, sizeof(name));

    // If it isn't one of these AI stop right here.
    if(StrContains(name, "smoker", false) == -1 && 
        StrContains(name, "boomer", false) == -1 && 
        StrContains(name, "hunter", false) == -1 && 
        StrContains(name, "spitter", false) == -1 && 
        StrContains(name, "jockey", false) == -1 && 
        StrContains(name, "charger", false) == -1)
    {
        return true;
    }

    if ( StrContains( name, "smoker", false ) != -1 && noSI_SmokerSpawn > 0 )
    {
        return true;
    }
    else if ( StrContains( name, "boomer", false ) != -1 && noSI_BoomerSpawn > 0 )
    {
        return true;
    }
    else if ( StrContains( name, "hunter", false ) != -1 && noSI_HunterSpawn > 0 )
    {
        return true;
    }
    else if ( StrContains( name, "spitter", false ) != -1 && noSI_SpitterSpawn > 0 )
    {
        return true;
    }
    else if ( StrContains( name, "jockey", false ) != -1 && noSI_JockeySpawn > 0 )
    {
        return true;
    }
    else if ( StrContains( name, "charger", false ) != -1 && noSI_ChargerSpawn > 0 )
    {
        return true;
    }

    KickClient(client,"[NoInfectedBots] Kicking infected bot...");
    
    return false;
}

UnsetCheatVar(Handle:hndl)
{
    new flags = GetConVarFlags(hndl);
    flags &= ~FCVAR_CHEAT;
    SetConVarFlags(hndl, flags);
}
 
SetCheatVar(Handle:hndl)
{
    new flags = GetConVarFlags(hndl);
    flags |= FCVAR_CHEAT;
    SetConVarFlags(hndl, flags);
}
Squidinator is offline
chatyak
Senior Member
Join Date: Aug 2011
Old 12-16-2014 , 12:49   Re: [L4D2] No Infected Bots
Reply With Quote #12

Having some trouble.... I USED to have this plugin active but no longer have it running... yet there are still no AI infected spawning during games.

Is there another cvar that can do this? I've gone through server.cfg and plugins numerous times now.

EDIT: I found the setting in the zcs plugin.

Last edited by chatyak; 12-16-2014 at 13:02.
chatyak is offline
hoanganh81097
Senior Member
Join Date: Apr 2016
Old 07-13-2018 , 15:43   Re: [L4D2] No Infected Bots
Reply With Quote #13

Anybody can make when tank spawn, can change type infected spawn ?
hoanganh81097 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:53.


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