SRCDS Steam group


can't get hostname cvar to work as cmd param
#1
I've written a management service that helps you to easily create srcds instances with different parameters through a web interface.

The web interface remotely communicates with a process which runs under a windows NT service, meaning the srcds instances will continue to run when logged off.

Everything is going smoothly, and I would like to release the tool to the community ASAP, but I still have one tiny problem. I thought it was a small problem, because of how simple it seems, but I haven't been able to figure it out for over 2 weeks.

I can't get the damn +hostname cvar to work through my command arguments, and I need this for my admin tool as I do all the configuration through CVARs.

This is what I try and run:
"C:\srcds\srcds.exe" -game hl2mp +map dm_overwatch +maxplayers 5 +hostname "bla" -console

I also tried by setting it with +hostname bla

What happens is that when I configure a hostname in the server.cfg, it takes the configured one. When I configure no hostname in the server.cfg it takes the default hostname which is "Half-Life 2 Deathmatch" which is the default hostname.

When I wait for the console to finish loading the srcds instance and then type in the console command "hostname bla" (without the parentheses), it changes the name to bla successfully.

When I say that it changes the name, I mean that in my server host listed with the correct name.

According the valve developer wiki it'sd efinitely the correct command to do this:

http://developer.valvesoftware.com/wiki/Command_Line_Options

Please help me, I've come so far in developing plug-ins and a development system, but it's just this one thing that I can;t get to work!
Reply
#2
why don't you just add hostname input field in the web interface? when users type their desired hostname intn the hostname input field, the server writes that information into server.cfg. like tcadmin, it reads %hostname%.

hostname "%hostname%" is written in server.cfg and whatever you put in the hostname input field replaces %hostname% in server.cfg
Reply
#3
Thanks for you reply.

That would be an option, but for one thing. I want to maintain more than one srcds instance at a time. My tool allows this, and it works quite well. So obviously I would need to be able to have a config file per game. And I've actually tried that before.

I wanted to try and spawn a config file for each instance and just instruct the instance to use the newly created config file, but that also did not work. It does not parse the created config file as instructed. I attempted to do this using the following command:

srcds.exe -exec myfile.cfg ..... other params

Although myfile.cfg exists, it does not execute it and load the hostname specified in it. I also deleted the server.cfg file which it used to parse just to make sure that it does not override this one, but with no luck - it just reverts back to default.

I'm open for creative suggestions, but unfortunately I couldn't get this to work. Maybe if you could help me with the syntax to instruct it to run a different config file through the command arguments I can try it again.

Even if i can just get an indication whether it is in fact possible to (a) set the hostname through the command arguments or (b) instruct srcds to use a specific config file through the command arguments, it would be GREATLY appreciated.
Reply
#4
as eXaXXion said

"why don't you just add hostname input field in the web interface? when users type their desired hostname intn the hostname input field, the server writes that information into server.cfg. like tcadmin, it reads %hostname%.

hostname "%hostname%" is written in server.cfg and whatever you put in the hostname input field replaces %hostname% in server.cfg"

but make a file called hostname.cfg and in the cfg folder and then add +exec hostname.cfg in ure command line

"srcds.exe -exec myfile.cfg ..... other params"

i think it is a + sign instead of a - 4 exec cause exec works on my server

that would work Big Grin
[Image: 66.199.240.229:27015.png]
Reply
#5
Yes what theape says is correct.

You have to us + because it's a cvar, not a built in startup command.
This way you can also set different server.cfg's for each server
example:
server 1: +exec server.cfg
server 2: +exec server2.cfg
etc etc...
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply
#6
Damnit, I can't get it to work on mine. Thanks for your replies though. I'm sure it might be something weird on my machine.

I tried using +exec instead of -exec. Remember, as I've stated before, I need to use all the cvars as cmd parameters. It might be one of the following reasons: (a) I have a plugin with it's own cvars defined in it. I wonder if this does not prevent SOME of the cvars from working. I explicitly say some of the cvars, because some are still definitely working, like +maxplayers.

Or (b) I have an older version of srcds perhaps. What's the best way to ensure that I've got the latest version? Do I need to use hldsupdatetool for this? I have steam installed on my dev computer and according to it's update news I've already got the latest version of srcds: March 08 2006.

I'll test without the plug-in, but it would be greatly appreciated if someone can tell me how to ensure that I've got the latest version of srcds.

thanks guys!
Reply
#7
You have to run the HLDSupdatetool to check for new versions. If it doesnt download new stuff your version is the latest.

Exactly WHY do you have to use everything in the startupline? I find this rather weird since I always try to use as much as possible in the server.cfg's
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply
#8
r u sure that the hostname.cfg file is in ure cfg folder ?

What plugin do u have ?

you will no if ure server is out of date if u try and connect to it and it will tell you. try running the update cmd

HldsUpdateTool.exe -command update -game <game> -dir <installdir>

If u still can't get it to work but u say server.cfg works then why don't u add exec hostname.cfg in ure server.cfg then it will exec that file when server.cfg is opened

[Image: 66.199.240.229:27015.png]
Reply
#9
I appreciate you guys' help, but i do not think you understand what I want to do with my admin tool.

Drocona: "Exactly WHY do you have to use everything in the startupline? I find this rather weird since I always try to use as much as possible in the server.cfg's"

My admin tool currently creates multiple instances of the srcds to run in a windows service. The tool is written to set the variables for every instance, like hostname, maxplayers, etc through the command arguments. That way I can use the MicroSoft .Net framework's ProcessStartInfo class in order to pass parameters to srcds, instead of hacking it with spawning different config files. Valve's wiki contains a parameter for the hostname which does not work through the command argument. So in order to get by that I would need to write an ugly hack to spawn different config files (one for each instance) so that their parameters may differ - I think this is horrible. It just intoduce a chance for more bugs to creep in. So to answer your question: I need to set it through the command arguments becuause I have written a tool to dynamically cerate new srcds instances through an interface - so that people do not need to muck around with crappy config files. I event tried to make peace with the fact that I'll need to HACK it, but I can' even get the +exec command to work through the command arguments..

theape: "If u still can't get it to work but u say server.cfg works then why don't u add exec hostname.cfg in ure server.cfg then it will exec that file when server.cfg is opened "

Because the admin using my tool wants to create three different isntances with different names dynamically - it does not make sense to go and create hardcoded instance names in the config files. I need to be able to specify through the command arguments (my only dynamic way to pass parameters) in order to specify either a name or a config file.

What I'll attempt to do, and this almost makes me sick to my stomach, because I code for a living, and will be fired if I ever did something like this at my work Smile, is to use a template file for the server.cfg. This will work ins such a way that when the admin starts a new game, the tool will load this template, insert the required variables in the config file, overwrite the server.cfg and then start the srcds instance. Srcds will then pick up the correct variables and run. This is possible because the file is ececuted only once.
It just irritates me because the documentation specifies arguments that doesn't work. My problem is possibly that I'm the only sucker that wants to use it in this way Smile

I tested without the plugin and it made no difference. The plugin is something that I wrote in order to provide more CVARs to the system so that I can set it. My custom written cvars works...
Reply
#10
hmm well +hostname really is a working startup command so I don't know why it doesnt work, are you sure there are no bugs anywhere in your coding. Same goes for +exec and any other +CVAR command you use.

BTW I've used the +hostname command for over a year, same goes for +exec.

Also, server.cfg executes on every mapchange, autoexec.cfg only when you start the server up.

And lol why would you get fired Big Grin using templates aint bad

good luck
Join the Source Dedicated Server Support Group on Steam Community!
Source Dedicated Server (SRCDS)
Free to join, Live support! (When available)

http://forums.srcds.com/viewtopic/5114
Reply
#11
Maybe you do have a hostname command in the CFG file. Try removing it.
Reply
#12
andrade Wrote:Maybe you do have a hostname command in the CFG file. Try removing it.

very creative suggestion
Reply
#13
tkx
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)