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

[ANY] CVAR Randomizer


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Bittersweet
Veteran Member
Join Date: May 2012
Plugin ID:
3549
Plugin Version:
2013.02.26.11.40
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Randomizes existing cvars as defined in the randcvars.cfg file, then removes itself from memory
    Old 02-26-2013 , 12:23   [ANY] CVAR Randomizer
    Reply With Quote #1

    Description:
    Randomizes existing cvars as defined in ...addons\sourcemod\configs\randcvars.cfg file,
    and then removes itself from memory. Plugin will not create new cvars at this time.
    I've had a need for something like this and couldn't find anything close enough worth tailoring.

    Installation:
    Installation depends on how you want to use the plugin.
    If you want it called for every map, just put randcvar.smx in ...addons\sourcemod\plugins
    and randcvars.cfg in ...\addons\sourcemod\configs.
    Remember that the plugin removes itself from memory after it executes.

    Configuration:
    Without a correctly configured cfg file, the plugin does nothing
    The plugin recognizes 3 different types of definitions in the cfg file: F (float), I (integer),
    and L (list). The F type returns a float between the defined low and high values,
    to the defined precision.
    The I type returns an integer between the defined low and high values.
    The L type returns a random string from the listed items.

    Example cfg file:
    Below is an example.cfg, which is also attached as randcvars.cfg.

    The first entry is for the cvar mp_roundtime.
    It's a type F, so it will return a float value between 2.00 (lo) and 3.50 (hi),
    with 2 decimal places (prec).

    The second entry is for the cvar bot_difficulty.
    It's a type I, so it will return an integer value between 0 (lo) and 3 (hi).

    The third and last entry is for the cvar sm_gg_cfgdirname.
    It's a type L, so it will return a string value from the listed item.
    The items are read into key values per the count, so if the count is
    less than the number of items, items numbered greater than count
    will be disregarded. In other words if you have 8 list items, but only
    specify a count of 2, only the first 2 items will be considered. If
    count is greater then the number of listed items, the returned string
    will either be the last listed item, or an empty string. For best
    results, your count should always match the number of listed items.

    This is just an example file to illustrate how the plugin is used.
    It is important to note that
    the plugin aborts and removes itself from memory upon
    the first error in the cfg file. In other words, if all of the key values are set
    correctly for the first cvar, but incorrect for the second (or 3rd, or 4th, etc.)
    cvar, the first cvar will be changed, but the second (or 3rd, or 4th, etc.)
    cvar won't be changed.

    Code:
    //Rename this file to randcvars.cfg and place in ...\addons\sourcemod\configs
    //If there are any errors in the structure, the plugin will abort at that point
    "Randomized_Cvars"
    {
    	"mp_roundtime"     //cvar name.  Cvar must already exist, plugin does not create new Cvars
    	{
    		"type"	"F"  //Valid types are F (float), I (integer), and L (list)
    		"prec" 	"2" //Precision - an integer value representing the number of digits to return
                                        // to the right of the decimal point (used only for type F) 1-99 are valid
    		"lo"		"2.00"  //Lowest possible value to return (used only for types F and I)
    		"hi"		"3.50"  //Highest possible value to return (used only for types F and I)
    	}
    	"bot_difficulty"     //cvar name.  Cvar must already exist, plugin does not create new Cvars
    	{
    		"type"	"I"  //Valid types are F (float), I (integer), and L (list)
    		"lo"		"0"  //Lowest possible value to return (used only for types F and I)
    		"hi"		"3"  //Highest possible value to return (used only for types F and I)
    	}
    	"sm_gg_cfgdirname"     //cvar name.  Cvar must already exist, plugin does not create new Cvars
    	{
    		"type"	"L"  //Valid types are F (float), I (integer), and L (list)
    		"count"	"3"  //Number of items in the list (used only in type L).
    		"item 1"	"gungame1\"  //A list item (used only in type L)
    		"item 2"	"gungame2\"  //A list item (used only in type L)
    		"item 3" 	"gungame3\"  //A list item (used only in type L)
    	}
    }
    It is open source, so tailor to your needs at will
    Attached Files
    File Type: sp Get Plugin or Get Source (randcvar.sp - 1060 views - 7.4 KB)
    File Type: cfg randcvars.cfg (1.4 KB, 467 views)
    __________________
    Thank you in advance for your help

    My plugins:
    [CS:S] BOT Swat | [ANY] CVAR Randomizer | [CS:S] SM CS:S Tag Beta | [CS:S] Bot2Player
    Awesome & Crucial plugins by other people:
    [CS:S/CS:GO] GunGame | [UMC3] Ultimate Mapchooser | [ANY] Server Crontab | [ANY] SM ForceCamera

    Last edited by Bittersweet; 02-27-2013 at 20:11. Reason: Some fields were cleared for unknown reason
    Bittersweet is offline
    IceCucumber
    Member
    Join Date: Dec 2011
    Old 05-02-2013 , 21:38   Re: [ANY] CVAR Randomizer
    Reply With Quote #2

    Cool plugin! However, it seems to only do its thing if I manually load it, eg. "sm plugins load randcvar" or "sm plugins refresh" to server console. Upon a mapchange, the CVARs will remain in their default values. Is there a way around this? I'm not getting any errors logs, and am quite positive my randcvars.cfg syntax is correct.

    Quote:
    [randcvar 2013.02.26.11.40] - Loaded
    [SM] Loaded plugin randcvar.smx successfully.
    [SM] Plugin randcvar unloaded successfully.
    Code:
    "Randomized_Cvars"
    {
        "sm_cm_nextmap"
        {
            "type"      "L"
            "count"     "3"
            "item 1"    "nt_dawn_ctg"
            "item 2"    "nt_decom_ctg"
            "item 3"    "nt_ghost_ctg"
        }
    }

    Last edited by IceCucumber; 05-02-2013 at 22:09.
    IceCucumber is offline
    Bittersweet
    Veteran Member
    Join Date: May 2012
    Old 05-02-2013 , 22:31   Re: [ANY] CVAR Randomizer
    Reply With Quote #3

    Quote:
    Originally Posted by IceCucumber View Post
    Cool plugin! However, it seems to only do its thing if I manually load it, eg. "sm plugins load randcvar" or "sm plugins refresh" to server console. Upon a mapchange, the CVARs will remain in their default values. Is there a way around this? I'm not getting any errors logs, and am quite positive my randcvars.cfg syntax is correct.

    Code:
    "Randomized_Cvars"
    {
        "sm_cm_nextmap"
        {
            "type"      "L"
            "count"     "3"
            "item 1"    "nt_dawn_ctg"
            "item 2"    "nt_decom_ctg"
            "item 3"    "nt_ghost_ctg"
        }
    }
    Your syntax does look correct. The plugin loading may depend on the game type. If it's not loading between maps and you need it to, just stick a sm plugins load command in your server.cfg.

    edit: Remember, the plugin removes itself from memory after execution.
    __________________
    Thank you in advance for your help

    My plugins:
    [CS:S] BOT Swat | [ANY] CVAR Randomizer | [CS:S] SM CS:S Tag Beta | [CS:S] Bot2Player
    Awesome & Crucial plugins by other people:
    [CS:S/CS:GO] GunGame | [UMC3] Ultimate Mapchooser | [ANY] Server Crontab | [ANY] SM ForceCamera

    Last edited by Bittersweet; 05-02-2013 at 22:34. Reason: addition
    Bittersweet is offline
    IceCucumber
    Member
    Join Date: Dec 2011
    Old 05-03-2013 , 00:23   Re: [ANY] CVAR Randomizer
    Reply With Quote #4

    Using this with the MapCron plugin to create a timed "sm plugins load randcvar" on mapchange appears to work nicely. I'm assuming this is due to the CVAR Randomizer accessing the variables before they are read from their respective config files, which will then overwrite the randomizations. Adding a simple timer to this plugin would most likely work as well.
    IceCucumber is offline
    Bittersweet
    Veteran Member
    Join Date: May 2012
    Old 05-03-2013 , 07:04   Re: [ANY] CVAR Randomizer
    Reply With Quote #5

    Quote:
    Originally Posted by IceCucumber View Post
    Using this with the MapCron plugin to create a timed "sm plugins load randcvar" on mapchange appears to work nicely. I'm assuming this is due to the CVAR Randomizer accessing the variables before they are read from their respective config files, which will then overwrite the randomizations. Adding a simple timer to this plugin would most likely work as well.
    It really depends on how and when you call the plugin. Some users might want it called on every map change, while others might want it for just certain maps/game types. A timer might work for you, and you're free to modify the code to your needs. I wouldn't go with a timer on something like that because of the complexity of my server - too many plugins loading and unloading depending on the map and gametype. You'd have to check the order of operations, but you could call randcvar from autoexec.cfg, or even from a map specific .cfg file in your game folder\maps\cfg folder.
    __________________
    Thank you in advance for your help

    My plugins:
    [CS:S] BOT Swat | [ANY] CVAR Randomizer | [CS:S] SM CS:S Tag Beta | [CS:S] Bot2Player
    Awesome & Crucial plugins by other people:
    [CS:S/CS:GO] GunGame | [UMC3] Ultimate Mapchooser | [ANY] Server Crontab | [ANY] SM ForceCamera
    Bittersweet is offline
    3axap
    Member
    Join Date: Dec 2012
    Old 03-02-2018 , 02:45   Re: [ANY] CVAR Randomizer
    Reply With Quote #6

    Hello, Who can fix this?

    Code:
    File addons/sourcemod/configs/randcvars.cfg missing, aborting...
    L 03/02/2018 - 10:43:41: [randcvar.smx] File addons/sourcemod/configs/randcvars.cfg missing, aborting...
    L 03/02/2018 - 10:43:41: [SM] Exception reported: Invalid key value handle dc460367 (error 3)
    L 03/02/2018 - 10:43:41: [SM] Blaming: randcvar.smx
    L 03/02/2018 - 10:43:41: [SM] Call stack trace:
    L 03/02/2018 - 10:43:41: [SM]   [0] KvGetSectionName
    L 03/02/2018 - 10:43:41: [SM]   [1] Line 68, plugin.sp::LoadKeyValues
    L 03/02/2018 - 10:43:41: [SM]   [2] Line 64, plugin.sp::OnPluginStart
    [SM] Plugin randcvar.smx failed to load: Error detected in plugin startup (see error logs).
    Counter-Strike: Source
    3axap is offline
    freak.exe_uLow
    AlliedModders Donor
    Join Date: Jul 2012
    Location: Germany
    Old 03-02-2018 , 06:20   Re: [ANY] CVAR Randomizer
    Reply With Quote #7

    Quote:
    Originally Posted by 3axap View Post
    Hello, Who can fix this?

    Code:
    File addons/sourcemod/configs/randcvars.cfg missing, aborting...
    L 03/02/2018 - 10:43:41: [randcvar.smx] File addons/sourcemod/configs/randcvars.cfg missing, aborting...
    L 03/02/2018 - 10:43:41: [SM] Exception reported: Invalid key value handle dc460367 (error 3)
    L 03/02/2018 - 10:43:41: [SM] Blaming: randcvar.smx
    L 03/02/2018 - 10:43:41: [SM] Call stack trace:
    L 03/02/2018 - 10:43:41: [SM]   [0] KvGetSectionName
    L 03/02/2018 - 10:43:41: [SM]   [1] Line 68, plugin.sp::LoadKeyValues
    L 03/02/2018 - 10:43:41: [SM]   [2] Line 64, plugin.sp::OnPluginStart
    [SM] Plugin randcvar.smx failed to load: Error detected in plugin startup (see error logs).
    Counter-Strike: Source
    File addons/sourcemod/configs/randcvars.cfg missing, aborting...

    you missing a cfg upload the randcvars.cfg
    freak.exe_uLow is offline
    3axap
    Member
    Join Date: Dec 2012
    Old 03-02-2018 , 06:25   Re: [ANY] CVAR Randomizer
    Reply With Quote #8

    I put randcvars.cfg to addons/sourcemod/configs/randcvars.cfg from 1st post. I tried not to copy it, all plugins auto create a configuration file.

    Anyway an error.
    3axap 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 04:57.


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