Raised This Month: $12 Target: $400
 3% 

[L4D2] Director Variables


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Plugin ID:
4301
Plugin Version:
2.1.1
Plugin Category:
General Purpose
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Allow plugins and administrators to change director variables, "dvars", without messing with VScripts.
    Old 08-07-2014 , 01:57   [L4D2] Director Variables
    Reply With Quote #1

    Director Variables

    About:
    During lots of my time working with just the Coop game mode for L4D2, I ran into various limitations here and there. Continued frustration with the Director never listening to the cvars I set in my server configuration files, led me wandering for answers as to why. The answer was:

    Director Variables

    Or dvars for short if you want be cool. With dvars, game modes have a lot more freedom regarding the game play and various variables the Director employs to pace the game. Of course that also means Director will be an ass and no longer listen to customized cvars in your server configuration files if the game mode happen to specify otherwise.
    Unacceptable. However thanks to the Left 4 Downtown 2 extension, as always, we can override various "script values" which the Director reads from game mode .nut files.

    Unlimited SI for everyone!

    Just to reiterate. This plugin does nothing other than apply fancy make up to already provided forwards from Left 4 Downtown 2. This plugin also offers a include script for other plugins to easy alter dvars. Neat!

    Lots of love to Sev, as always, for putting up with my rants and various shit.

    Description:
    Allow plugins and administrators to change director variables, "dvars", without messing with VScripts.

    Commands:
    Code:
    sm_dvarlist - Prints a list of all indexed director variables to console
    sm_dvar <dvar> [value] - Show or set value of a director variable
    sm_resetdvar <dvar> - Reset value of a director variable
    sm_dvarbounds <dvar> <upper|lower> [0|1] [value] - Show or set bound value of a director variable
    sm_silentdvar <dvar> [value] - Show or set value of a director variable, without showing activity
    sm_silentresetdvar <dvar> - Reset value of a director variable, without showing activity
    sm_silentdvarbounds <dvar> <upper|lower> [0|1] [value] - Show or set bound value of a director variable, without showing activity

    Cvars:
    No customizable cvars are featured in this plugin.

    Known Problems / Things to Notice:
    • This plugin require the Left 4 Downtown 2 extension.
    • Dvars can only be changed post being indexed by this plugin, which occurs after Director queries the variable for the first time. This means on the first map after server reboot, most dvars are not indexed yet and can not be altered, such as EscapeSpawnTanks. This plugin will silently error out (However it will print a message to the admin issuing command and/or server) if unable to find wanted dvar. There is no problem with placing plugin commands in configuration files for later application (once the wanted variable have been indexed).
    • It goes without saying that dvars the Director never queries is never obeyed. That means TankHitDamageModifierVersus is not used in Coop and ScavengeClusterBonusTime is not used outside scavenge game mode. Furthermore challenge dvars are not used at all if not in a 'challenge' game mode. Challenge dvars are prefixed with "cm_".
    • Use sm_dvarlist to see current indexed director variables and their values.
    • A great community-made list of Director Variables can be found at the Valve Developer Wiki, here.

    Change log:
    Code:
    Version 2.1.1  2014-08-07
    Initial public release.
    Attached Files
    File Type: zip directorvariables_release.zip (43.7 KB, 988 views)

    Last edited by Mr. Zero; 08-09-2014 at 09:40.
    Mr. Zero is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-07-2014 , 01:58   Re: [L4D2] Director Variables
    Reply With Quote #2

    Director Variables include file:

    PHP Code:
    #define DIRECTORVARIABLES_LIBRARY "directorvariables"
    #define DIRECTORVARIABLES_VERSION "2.1.1"

    #define DIRVAR_NAME_MAX_LENGTH 128
    #define DIRVAR_VALUE_MAX_LENGTH 128
    #define INVALID_DIRVAR_INDEX -1

    enum DirVarBounds
    {
        
    DirVarBound_Upper 0,
        
    DirVarBound_Lower
    };

    /**
     * Called when a new director variable is indexed.
     *
     * @param dvaridx        Index of the dirvar that was indexed.
     * @param name            Name of the dirvar that was indexed.
     * @param value            String containing the value of the dirvar upon
     *                indexing.
     * @noreturn
     */
    forward OnDirVarIndexAdded(dvaridx, const String:name[], const String:value[]);

    /**
     * Called when a director variable's value was changed.
     *
     * @param dvaridx        Index of the dirvar that was changed.
     * @param oldValue        String containing the value of the dirvar
     *                before it was changed.
     * @param newValue        String containing the new value of the dirvar.
     * @noreturn
     */
    functag public DirVarChanged(dvaridx, const String:oldValue[], const String:newValue[]);

    /**
     * Creates a hook for when a director variable's value is changed.
     *
     * @param dvaridx        Index of the dirvar.
     * @param callback        An DirVarChanged function pointer.
     * @noreturn
     * @error            Invalid dirvar or invalid callback function
     */
    native HookDirVarChange(dvaridxDirVarChanged:callback);

    /**
     * Removes a hook for when a director variable's value is changed.
     *
     * @param dvaridx        Index of the dirvar.
     * @param callback        An DirVarChanged function pointer.
     * @noreturn
     * @error            Invalid dirvar, invalid callback function, or
     *                no active hook on dirvar.
     */
    native UnhookDirVarChange(dvaridxDirVarChanged:callback);

    /**
     * Searches for a director variable.
     *
     * @param name            Name of dirvar to find.
     * @return            An index to the dirvar if it is found.
     *                INVALID_DIRVAR_INDEX otherwise.
     */
    native FindDirVar(const String:name[]);

    /**
     * Retrieves the total of director variables indexed.
     *
     * @return            Count of dirvar indexed.
     */
    native GetDirVarCount();

    /**
     * Retrieves the name of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param name            Buffer to store the name of the dirvar.
     * @param maxlength        Maximum length of string buffer.
     * @return            Number of cells written.
     * @error            Invalid dirvar index.
     */
    native GetDirVarName(dvaridxString:name[], maxlength);

    /**
     * Retrieves the string value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param value            Buffer to store the value of the dirvar.
     * @param maxlength        Maximum length of string buffer.
     * @return            Number of cells written.
     * @error            Invalid dirvar index.
     */
    native GetDirVarString(dvaridxString:value[], maxlength);

    /**
     * Sets the string value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param value            New string value.
     * @noreturn
     * @error            Invalid dirvar index.
     */
    native SetDirVarString(dvaridx, const String:value[]);

    /**
     * Resets the director variable to its default value.
     *
     * @param dvaridx        Index of the dirvar.
     * @noreturn
     * @error            Invalid dirvar index.
     */
    native ResetDirVar(dvaridx);

    /**
     * Retrieves the default string value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param value            Buffer to store the default value of the dirvar.
     * @param maxlength        Maximum length of string buffer.
     * @return            Number of cells written.
     * @error            Invalid dirvar index.
     */
    native GetDirVarDefault(dvaridxString:value[], maxlength);

    /**
     * Retrieves the specified bound of a director variable.
     *
     * @param convar        Index of the dirvar.
     * @param type            Type of bound to retrieve, DirVarBound_Lower or DirVarBound_Upper.
     * @param value            By-reference cell to store the specified floating point bound value.
     * @return            True if the dirvar has the specified bound set, false otherwise.
     * @error            Invalid dirvar index.
     */
    native bool:GetDirVarBounds(dvaridxDirVarBounds:type, &Float:value);

    /**
     * Sets the specified bound of a director variable.
     *
     * @param convar        Index of the dirvar.
     * @param type            Type of bound to set, DirVarBound_Lower or DirVarBound_Upper
     * @param set            If set to true, dirvar will use specified bound. If false, bound will be removed.
     * @param value            Floating point value to use as the specified bound.
     * @noreturn
     * @error            Invalid dirvar index.
     */
    native SetDirVarBounds(dvaridxDirVarBounds:typebool:setFloat:value 0.0);

    /**
     * Returns whether director variable index is valid.
     *
     * @param dvaridx        Index of the dirvar.
     * @return            True if index is valid, false otherwise.
     */
    stock bool:IsValidDirVarIndex(dvaridx)
    {
        return (
    dvaridx INVALID_DIRVAR_INDEX && dvaridx GetDirVarCount());
    }

    /**
     * Returns the boolean value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @return            The boolean value of the dirvar.
     * @error            Invalid dirvar index.
     */
    stock bool:GetDirVarBool(dvaridx)
    {
        new 
    String:buffer[DIRVAR_VALUE_MAX_LENGTH];
        
    GetDirVarString(dvaridxbufferDIRVAR_VALUE_MAX_LENGTH);
        return 
    bool:StringToInt(buffer);
    }

    /**
     * Sets the boolean value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param value            New boolean value.
     * @noreturn
     * @error            Invalid dirvar index.
     */
    stock SetDirVarBool(dvaridxbool:value)
    {
        new 
    String:buffer[DIRVAR_VALUE_MAX_LENGTH];
        
    IntToString(_:valuebufferDIRVAR_VALUE_MAX_LENGTH);
        
    SetDirVarString(dvaridxbuffer);
    }

    /**
     * Returns the integer value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @return            The integer value of the dirvar.
     * @error            Invalid dirvar index.
     */
    stock GetDirVarInt(dvaridx)
    {
        new 
    String:buffer[DIRVAR_VALUE_MAX_LENGTH];
        
    GetDirVarString(dvaridxbufferDIRVAR_VALUE_MAX_LENGTH);
        return 
    StringToInt(buffer);
    }

    /**
     * Sets the integer value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param value            New integer value.
     * @noreturn
     * @error            Invalid dirvar index.
     */
    stock SetDirVarInt(dvaridxvalue)
    {
        new 
    String:buffer[DIRVAR_VALUE_MAX_LENGTH];
        
    IntToString(valuebufferDIRVAR_VALUE_MAX_LENGTH);
        
    SetDirVarString(dvaridxbuffer);
    }

    /**
     * Returns the floating point value of a director variable. 
     *
     * @param dvaridx        Index of the dirvar.
     * @return            The floating point value of the dirvar.
     * @error            Invalid dirvar index.
     */
    stock Float:GetDirVarFloat(dvaridx)
    {
        new 
    String:buffer[DIRVAR_VALUE_MAX_LENGTH];
        
    GetDirVarString(dvaridxbufferDIRVAR_VALUE_MAX_LENGTH);
        return 
    StringToFloat(buffer);
    }

    /**
     * Sets the floating point value of a director variable.
     *
     * @param dvaridx        Index of the dirvar.
     * @param value            New floating point value.
     * @noreturn
     * @error            Invalid dirvar index.
     */
    stock SetDirVarFloat(dvaridxFloat:value)
    {
        new 
    String:buffer[DIRVAR_VALUE_MAX_LENGTH];
        
    FloatToString(valuebufferDIRVAR_VALUE_MAX_LENGTH);
        
    SetDirVarString(dvaridxbuffer);


    Last edited by Mr. Zero; 08-07-2014 at 02:00.
    Mr. Zero is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-07-2014 , 01:59   Re: [L4D2] Director Variables
    Reply With Quote #3

    Posting this private plugin I had for a while after increasing disinterest in L4D2 and other stuff.

    Pretty simple stuff, plugin applies a convar facade over OnGetScript-Value, -Float and -String forwards provided by Left 4 Downtown 2. Nothing major but its really easy to work with when you have multiple plugins requiring access to certain dirvars and want to avoid hooking multiple times, clashes and what have you.

    Also semi-requested by darktemplarr as he wished to increase SI limits for Coop. This is done with the following dvars:
    Code:
    sm_dvar MaxSpecials 12
    sm_dvar DominatorLimit 5
    sm_dvar SmokerLimit 2
    sm_dvar BoomerLimit 2
    sm_dvar HunterLimit 2
    sm_dvar SpitterLimit 2
    sm_dvar ChargerLimit 2
    sm_dvar JockeyLimit 2
    Just as an example. Do remember some of these dvars are reset depending on which VScripts are called, such as before entering the gun shop on Dead Center map 2, the Director starts the 'quiet' script, which sets all common and special infected to 0 to give Survivors a break while reloading and stocking up on supplies.

    Use the bounds commands in these cases where you wish to be absolutely sure that the value does not drop below a certain threshold (or raise above!).

    Last edited by Mr. Zero; 08-07-2014 at 02:09.
    Mr. Zero is offline
    darktemplarr
    Member
    Join Date: Jun 2010
    Old 08-07-2014 , 09:03   Re: [L4D2] Director Variables
    Reply With Quote #4

    Thank you so very much for going to this kind of effort to solve this nasty little issue for me. Whilst I go download and test this lovely new potential solution, I just wanted to let you know I think you have the wrong link for your Left 4 Downtown 2 links. I click them and it takes me to a plugin for Scene Processor.
    But I came across left 4 downtown 2 while looking on in desperation for this very fix, I know where to find it.

    Edit: Unfortunately I can't seem to get this plugin to load for me. The sm_dvar stuff will not register in the console and I cannot understand what I might be doing wrong, if anything. Got Left 4 Downtown 2 installed with no problems, though I cannot be sure if it loaded correctly as I don't know how to check for any content it provides, because none of the content it provides is really a command or the like. I just assumed I got that working because version 1 crashed my game, updating the gamedata file didn't, so SOMETHING went through. This unfortunately isn't reading properly.

    Last edited by darktemplarr; 08-08-2014 at 02:39. Reason: tested plugin
    darktemplarr is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-09-2014 , 09:41   Re: [L4D2] Director Variables
    Reply With Quote #5

    Ah my mistake, fixed the links.

    As for your issue, please post the error log in your SourceMod log folder. It should contain an error if the plugin fails to load.

    Furthermore please post output from the following commands (wrap them in [CODE ] tags):
    sm plugins list
    sm exts list
    Mr. Zero is offline
    Krufftys Killers
    Senior Member
    Join Date: Jan 2014
    Old 08-09-2014 , 18:39   Re: [L4D2] Director Variables
    Reply With Quote #6

    [SM] Unable to find dvar: "MaxSpecials".
    [SM] Unable to find dvar: "DominatorLimit".
    [SM] Unable to find dvar: "SmokerLimit".
    [SM] Unable to find dvar: "BoomerLimit".
    [SM] Unable to find dvar: "HunterLimit".
    [SM] Unable to find dvar: "SpitterLimit".
    [SM] Unable to find dvar: "ChargerLimit".
    [SM] Unable to find dvar: "JockeyLimit".
    Krufftys Killers is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-09-2014 , 19:51   Re: [L4D2] Director Variables
    Reply With Quote #7

    Quote:
    Originally Posted by Krufftys Killers View Post
    [SM] Unable to find dvar: "MaxSpecials".
    [SM] Unable to find dvar: "DominatorLimit".
    [SM] Unable to find dvar: "SmokerLimit".
    [SM] Unable to find dvar: "BoomerLimit".
    [SM] Unable to find dvar: "HunterLimit".
    [SM] Unable to find dvar: "SpitterLimit".
    [SM] Unable to find dvar: "ChargerLimit".
    [SM] Unable to find dvar: "JockeyLimit".
    Quote:
    Originally Posted by Mr. Zero View Post
    Known Problems / Things to Notice:
    • Dvars can only be changed post being indexed by this plugin, which occurs after Director queries the variable for the first time. This means on the first map after server reboot, most dvars are not indexed yet and can not be altered, such as EscapeSpawnTanks. This plugin will silently error out (However it will print a message to the admin issuing command and/or server) if unable to find wanted dvar. There is no problem with placing plugin commands in configuration files for later application (once the wanted variable have been indexed).
    For those dvars, for the Director to query them for the first time, simply spawn a wanted SI class. For example, spawn a Spitter for SpitterLimit dvar to be indexed for the first time. Use sm_silentdvar in your configs to prevent error log spam when you are starting the map for the first time.
    Mr. Zero is offline
    darktemplarr
    Member
    Join Date: Jun 2010
    Old 08-10-2014 , 01:15   Re: [L4D2] Director Variables
    Reply With Quote #8

    Quote:
    Originally Posted by Mr. Zero View Post
    Ah my mistake, fixed the links.

    As for your issue, please post the error log in your SourceMod log folder. It should contain an error if the plugin fails to load.

    Furthermore please post output from the following commands (wrap them in [CODE ] tags):
    sm plugins list
    sm exts list
    Code:
    ] sm plugins list
    [SM] Listing 18 plugins:
      01 "Admin File Reader" (1.6.0) by AlliedModders LLC
      02 "Admin Help" (1.6.0) by AlliedModders LLC
      03 "Admin Menu" (1.6.0) by AlliedModders LLC
      04 "Anti-Flood" (1.6.0) by AlliedModders LLC
      05 "Basic Ban Commands" (1.6.0) by AlliedModders LLC
      06 "Basic Chat" (1.6.0) by AlliedModders LLC
      07 "Basic Comm Control" (1.6.0) by AlliedModders LLC
      08 "Basic Commands" (1.6.0) by AlliedModders LLC
      09 "Basic Info Triggers" (1.6.0) by AlliedModders LLC
      10 "Basic Votes" (1.6.0) by AlliedModders LLC
      11 "Client Preferences" (1.6.0) by AlliedModders LLC
      12 <Bad Load> directorvariables.smx
      13 "Fun Commands" (1.6.0) by AlliedModders LLC
      14 "Fun Votes" (1.6.0) by AlliedModders LLC
      15 Disabled: "Nextmap" (1.6.0) by AlliedModders LLC
      16 "Player Commands" (1.6.0) by AlliedModders LLC
      17 "Reserved Slots" (1.6.0) by AlliedModders LLC
      18 "Sound Commands" (1.6.0) by AlliedModders LLC
    ] sm exts list
    [SM] Displaying 8 extensions:
    [01] Automatic Updater (1.6.0): Updates SourceMod gamedata files
    [02] Webternet (1.6.0): Extension for interacting with URLs
    [03] Left 4 Downtown 2 Extension (0.5.4.2): Downtown1's extension to perform useful L4D1/L4D2 calls
    [04] BinTools (1.6.0): Low-level C/C++ Calling API
    [05] Top Menus (1.6.0): Creates sorted nested menus
    [06] SDK Tools (1.6.0): Source SDK Tools
    [07] Client Preferences (1.6.0): Saves client preference settings
    [08] SQLite (1.6.0): SQLite Driver
    I'm on windows 7, should that matter as I've seen different installation instructions for windows, linux, etc.

    log file contents for singular map load-up playtest. No commands or other variables, just a load up and quit.
    Code:
    L 08/10/2014 - 02:33:25: SourceMod log file session started (file "L20140810.log") (Version "1.6.0")
    L 08/10/2014 - 02:33:25: -------- Mapchange to c8m1_apartment --------
    L 08/10/2014 - 02:34:40: Log file closed.
    Edit: Did a fresh install of sourcemod 1.6.0, then Left 4 Downtown 2, then directorvariables, then ran it. Same results, exact same report for sm plugins list and sm exts list.

    Last edited by darktemplarr; 08-10-2014 at 06:09.
    darktemplarr is offline
    Krufftys Killers
    Senior Member
    Join Date: Jan 2014
    Old 08-10-2014 , 08:52   Re: [L4D2] Director Variables
    Reply With Quote #9

    Director Variables working on my too Linux servers 192.3.136.134:27015 Krufftys Anarchy and 216.144.252.163:27015 Krufftys Killers sweet plugin no errors so far great plugin .
    Thanks Mr. Zero
    Krufftys Killers is offline
    Mr. Zero
    Veteran Member
    Join Date: Jun 2009
    Location: Denmark
    Old 08-10-2014 , 09:23   Re: [L4D2] Director Variables
    Reply With Quote #10

    Quote:
    Originally Posted by darktemplarr View Post
    log file contents for singular map load-up playtest. No commands or other variables, just a load up and quit.
    Code:
    L 08/10/2014 - 02:33:25: SourceMod log file session started (file "L20140810.log") (Version "1.6.0")
    L 08/10/2014 - 02:33:25: -------- Mapchange to c8m1_apartment --------
    L 08/10/2014 - 02:34:40: Log file closed.
    Edit: Did a fresh install of sourcemod 1.6.0, then Left 4 Downtown 2, then directorvariables, then ran it. Same results, exact same report for sm plugins list and sm exts list.
    That would be your regular SourceMod log file, I'm asking for the one that should be prefixed with "errors_" followed by the date. Your plugin list does report the Director Variables plugin as a bad load and should leave a message in the error log as to why it was a bad load.

    Also try out the following command and post the output:
    sm plugins load directorvariables
    Mr. Zero is offline
    Reply


    Thread Tools
    Display Modes

    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 10:20.


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