PDA

View Full Version : Ideas for auto configurations



guiismiti
12th December 2013, 02:00
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:



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:



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:



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.

Tally
12th December 2013, 05:06
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.

IzNoGoD
12th December 2013, 08:24
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)

serthy
12th December 2013, 08:45
Cannot you just set a cvar called 'execonstart' to 'exec your_config_here.cfg' on every mapchange and run your server like +vstr execonstart?

kung foo man
12th December 2013, 09:01
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?1259-Tutorial-B3-Simple-and-Easy-Command-Adding!

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

https://github.com/kungfooman/libcod/blob/master/gsc.cpp


case 1204:
{
#if COD_VERSION == COD4_1_7
void (*Cmd_ExecuteString)(int a1, int 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(0, 0, msg); // idk what first 2 numbers do
#else
Cmd_ExecuteString(msg);
#endif

return stackPushInt(1);
}


Call it in CoDScript with: closer(1204, "set someKey someValue")

Tally
12th December 2013, 09:31
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.

serthy
12th December 2013, 09:58
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

kung foo man
12th December 2013, 10:09
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)



// 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"

guiismiti
12th December 2013, 13:59
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.