Results 1 to 9 of 9

Thread: Ideas for auto configurations

  1. #1
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts

    Ideas for auto configurations

    Hello,


    Context:
    Auto configuration was an idea I had (maybe some of you had it aswell) to configure specific settings for each map.



    Here it is:
    I modified every mapname.gsc in the maps/mp/ directory, and, basically, I added this to the beginning:

    Code:
    	if(getCvar("scr_autoconfig") == "1"){
    		mapname = getcvar("mapname");
    
    		setCvar("scr_allow_fraggrenades", (getCvar("scr_allow_fraggrenades_" + mapname)));
    		setCvar("scr_allow_smokegrenades", (getCvar("scr_allow_smokegrenades_" + mapname)));
    		setCvar("scr_allow_sprint", (getCvar("scr_allow_sprint_" + mapname)));
    	}
    This allows me to define if there's going to be fraggrenades / smokegrenades / sprint in any map that has autoconfig implemented.
    At the moment, I'm using auto config with MOAM (mod of all menus) - which allows me to define if there's gonna be all weapons or regular weapons or rifles only or pistols only in a map, but I won't post the code unless someone asks me, it's a bit long and unnecessary here.




    The problem:

    It is working perfectly right now, but I still think it can be improved.
    Like, if I wanted to add another configuration, e. g. scr_tdm_scorelimit, I would have to modify the mod to add:

    Code:
    		setCvar("scr_tdm_scorelimit", (getCvar("scr_tdm_scorelimit_" + mapname)));
    And we all know that, when you modify a mod in a pure server, you need to change your fs_game, or the players who have downloaded the previous mod will have conflicts.

    So, basically, what I need to know is the command to execute a .cfg file from the script. I'm not good with syntax, I really have no clue if there is how.

    It would look like:

    Code:
    	mapname = getcvar("mapname");
    	exec(mapname + ".cfg");
    But this does not work - I get the unknown function error report when I try it.

    mp_breakout.gsc is attached with the current configuration I'm using on my mod.


    Does anybody know if there is such a script command to exec a .cfg file? I think this can be very useful, and I also hope this idea was useful.
    Attached Files Attached Files
    set logfile 2

  2. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    There is no function in COD script to execute a config file for a server. You can do it for a player, but not for a server.

    The server function execute/exec which we place in our commandlines does not accept modifications (unless you use libcod). This is done at the server boot level. So, there is no way to execute a particular config file for a particular map.

    In COD UO, you could do these things, but not with the COD2 engine.

  3. The Following User Says Thank You to Tally For This Useful Post:

    guiismiti (12th December 2013)

  4. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Just install libcod and add everything to a mysql database.
    Overkill? yes. Working? yes.

    Or just go low-tech and manually read a cfg file with the fileoperations available.

    Also,
    And we all know that, when you modify a mod in a pure server, you need to change your fs_game, or the players who have downloaded the previous mod will have conflicts.
    is not true.

    I run a pure server, changed my clientfiles over 20 times in the last few months and made at least 500x modifications to the script (script is serverside)

  5. The Following User Says Thank You to IzNoGoD For This Useful Post:

    guiismiti (12th December 2013)

  6. #4
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Cannot you just set a cvar called 'execonstart' to 'exec your_config_here.cfg' on every mapchange and run your server like +vstr execonstart?

  7. #5
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Quote Originally Posted by guiismiti View Post
    And we all know that, when you modify a mod in a pure server, you need to change your fs_game, or the players who have downloaded the previous mod will have conflicts.
    You don't need to change any .iwd-file, when you just change the scripts. Either you put your scripts into a name_svr_.iwd or just without any .iwd in fs_game/maps/mp/

    If you really need some exec-function without libcod, you can also use BigBrotherBot/rcon for that, I made an easy to understand tutorial here: http://killtube.org/showthread.php?1...Command-Adding!

    A direct Cmd_ExecuteString()-function got added by Mitch in libcod:

    https://github.com/kungfooman/libcod...master/gsc.cpp
    PHP Code:
                    case 1204:
                    {
                            
    #if COD_VERSION == COD4_1_7
                                    
    void (*Cmd_ExecuteString)(int a1int a2, const char *text);
                            
    #else
                                    
    void (*Cmd_ExecuteString)(const char *text);
                            
    #endif

                            
    (*(int *)&Cmd_ExecuteString) = getExecuteString();

                            
    char *msg;
                            
    int helper 0;
                            
    helper += stackGetParamString(1, &msg); // todo: is string?

                            
    if (helper 1)
                            {
                                    
    printf_hide("scriptengine> wrongs args for: say(): at least 1 arg\n");
                                    return 
    stackReturnInt(0);
                            }

                            
    #if COD_VERSION == COD4_1_7
                                    
    Cmd_ExecuteString(00msg); // idk what first 2 numbers do
                            #else
                                    
    Cmd_ExecuteString(msg);
                            
    #endif

                            
    return stackPushInt(1);
                    } 
    Call it in CoDScript with: closer(1204, "set someKey someValue")
    timescale 0.01

  8. The Following User Says Thank You to kung foo man For This Useful Post:

    guiismiti (12th December 2013)

  9. #6
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by serthy View Post
    Cannot you just set a cvar called 'execonstart' to 'exec your_config_here.cfg' on every mapchange and run your server like +vstr execonstart?
    That might work on a player, but not on a server.

  10. #7
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    Quote Originally Posted by Tally View Post
    That might work on a player, but not on a server.
    Okay, i will test this when im at home.

    Another possibility could be something similar what Iznogod mentioned:
    create a exec.cfg file CoD2 file functions and call this one in your startup +exec scriptdata/exec.cfg
    in it wite something on every map ending:
    exec your_config.cfg

  11. #8
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Just an idea, the config_mp.cfg might be exploitable also, since it's saved and loaded at every map change (disallow writing to the file, so its not changed at runtime)

    Code:
    // generated by Call of Duty, do not modify
    unbindall
    unbindall
    bind ESCAPE "togglemenu"
    bind SPACE "+melee_breath"
    bind 1 "openscriptmenu command weapon_american"
    bind 2 "openscriptmenu command weapon_british"
    bind 3 "openScriptMenu keysMenu key3"
    seta fx_sort "1"
    seta g_allowvote "1"
    seta g_antilag "1"
    seta g_banIPs ""
    seta g_clonePlayerMaxVelocity "80"
    seta g_deadChat "0"
    timescale 0.01

  12. #9
    Corporal guiismiti's Avatar
    Join Date
    Dec 2013
    Location
    Brazil
    Posts
    244
    Thanks
    121
    Thanked 42 Times in 31 Posts
    Over 5 years editting mods and I did not know you could place scripts out of the .iwd files...

    Anyway, I can't install libcod cause the server is rented.
    About the pure server issue - whenever I changed a .iwd file, people downloaded the new file and got kicked because of the old one (if it wasn't deleted). But, like I said, now I know I don't need to modify the .iwd.

    Looks like the best solution for me is to take the scripts off, very simple.
    set logfile 2

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •