PDA

View Full Version : Print Cvar Values [Possible REQ]


Yeef
11-29-2011, 17:07
I don't know if there's already a plugin or extension that will do this (or if it's built into Source already and I just didn't see it), but thus far I haven't been able to find one. What I'm looking for is a way to print the values of different cvars. So, for example, if were to type "echo $mp_maxrounds" into the console instead of actually printing "$mp_maxrounds" it would print "5" or whatever the variable is set to at the time.

I'm specifically looking to use this for TF2, but I'd imagine it'd be useful for any Source game. Primarily, I want to use it in conjunction with an SQL Plugin (http://forums.alliedmods.net/showthread.php?p=1270572) to log some info to a mySQL database on every map load. I'd imagine it could be useful for lots of other things as well.

Tylerst
11-29-2011, 20:57
The built in sm_cvar command already does this if you don't supply a value.

IE, if mp_whatever is set to "5", and you use the command sm_cvar mp_whatever, it will return what value the cvar is set to

TnTSCS
11-29-2011, 22:01
yes... and with "sm cvars ##" where ## is the listed plugin number it will show you all cvars and their values for that plugin...

say AdvCommands is listed as 15

sm cvars 15 shows:


19:00:41 sm cvars 15
19:00:43 [SM] Listing 15 convars for: Advanced admin commands
[Name] [Value]
sm_adv_admin_flags t
sm_adv_admin_immunity 60
sm_adv_admin_list 1
sm_adv_admin_vision 7
sm_adv_banlog 7
sm_adv_connect_announce 0
sm_adv_log 1
sm_adv_mapcfg 0
sm_adv_me 1
sm_adv_motd
sm_adv_notify 0
sm_adv_round_protection 0
sm_adv_silent 0
sm_adv_spawn_protection 0
sm_adv_version 0.16

Dr. McKay
11-29-2011, 22:16
Stating the obvious, but... just type the convar into the console directly without specifying a value?

Yeef
11-30-2011, 00:07
I think there's been some confusion. i'm not looking to print the values to the console, I'm looking to use them to create an SQL query using this plugin (http://forums.alliedmods.net/showthread.php?p=1270572). Specifically an insert that will log the time (which mySQL on its own), map name, and value of steamworks_sessionid_server.

What I need is the actual values of the cvars to be usable as a reference. So, for example sending the command sql_query "INSERT INTO `tablename` (map, match_id) VALUES ($host_map, $steamworks_sessionid_server)"would actually resolve to

sql_query "INSERT INTO `tablename` (map, match_id) VALUES (cp_steel, 153A543E)"

I hope that clears things up a bit with regards to the functionality I'm looking for.

Dr. McKay
11-30-2011, 00:20
I think there's been some confusion. i'm not looking to print the values to the console, I'm looking to use them to create an SQL query using this plugin (http://forums.alliedmods.net/showthread.php?p=1270572). Specifically an insert that will log the time (which mySQL on its own), map name, and value of steamworks_sessionid_server.

What I need is the actual values of the cvars to be usable as a reference. So, for example sending the command would actually resolve to



I hope that clears things up a bit with regards to the functionality I'm looking for.

You'd probably be better off getting a plugin written for your specific purpose. Either way, this would be used to get the value of an int cvar:
new Handle:steamworks_sessionid_server = FindConVar("steamworks_sessionid_server");
new value = GetConVarInt(steamworks_sessionid_server);
You can just use GetCurrentMap() for the map name.

Edit: Give me a few minutes and I'll probably have a working version for you.

Dr. McKay
11-30-2011, 00:41
Here, give this a shot.

Uses the database configuration "mapinfo", like below:

"mapinfo"
{
"driver" "mysql"
"host" "199.119.226.105"
"database" "mapinfo"
"user" "mysql_user"
"pass" "mysql_password"
//"timeout" "0"
//"port" "0"
}

Pick what table you're using with the sqlinfo_tablename cvar (defaults to "mapinfo" table).

Every time a new map is started, it calls one of these:

INSERT INTO `[[sqlinfo_tablename]]` (map, match_id) VALUES ('[[current map]]', '[[steamworks_sessionid_server]]')

Yeef
11-30-2011, 01:21
You're awesome dude. I appreciate it greatly! :]

One problem though, the plugin doesn't compile. The specific errors are:

(line 32) warning 213: tag mismatch
(line 33) error 035: argument type mismatch (argument 3)As far as I can tell it seems to be an issue with the tableCvar (sqlinfo_tablename).

[EDIT] Made a couple of small edits and got it working. Thanks again! :D