Raised This Month: $ Target: $400
 0% 

register_cvar with -console option


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bianster
Junior Member
Join Date: Sep 2009
Old 11-05-2009 , 23:04   register_cvar with -console option
Reply With Quote #1

I've a question regarding register_cvar when running hlds.exe with the -console option. I have the code below and the value of my_cvar is initialised to what I specify when starting a HLDS instance (in +servercfgfile) but it's not picking it up when I start the server with -console.

Do I need to do something else when using the -console option? Using Metamod 1.91 and AMX Mod X 1.81.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define PLUGIN "HLDS Plugin"
#define VERSION "0.1"
#define AUTHOR "Author"

public plugin_init() {
  
register_plugin(PLUGINVERSIONAUTHOR)
  
register_cvar("my_cvar""0"FCVAR_SPONLY|FCVAR_SERVER)

  
log_message("mp_winlimit is %d"get_cvar_num("mp_winlimit"))
  
log_message("my_cvar is %d"get_cvar_num("my_cvar"))
}

public 
client_putinserver(id){
  
log_message("my_cvar is %d"get_cvar_num("my_cvar"))
  return 
PLUGIN_CONTINUE

bianster is offline
Old 11-06-2009, 00:03
fysiks
This message has been deleted by fysiks. Reason: Oh, nevermind, I read it wrong.
bianster
Junior Member
Join Date: Sep 2009
Old 11-08-2009 , 21:23   Re: register_cvar with -console option
Reply With Quote #3

I've tried it also with the vanilla server.cfg for cstrike. The same thing happens: the plugin doesn't pick up the value of the my_cvar in server.cfg when running with -console.

The command I used to start the HLDS instance doesn't do anything out of the ordinary: hlds.exe -console +log on -game cstrike -ip 127.0.0.1 +port 3000 +clientport 3000

server.cfg
// Use this file to configure your DEDICATED server.
// This config file is executed on server start.

// disable autoaim
sv_aim 0

// disable clients' ability to pause the server
pausable 0

// default server name. Change to "Bob's Server", etc.
hostname "Counter-Strike 1.6 Server"

// maximum client movement speed
sv_maxspeed 320

// 20 minute timelimit
mp_timelimit 20

sv_cheats 0

// load ban files
//exec listip.cfg
//exec banned.cfg

my_cvar 1
map de_dust

Changing the order of the my_cvar declaration in server.cfg doesn't help either, I've observed. Is it something else perhaps? It can't be just me experiencing this, now could it?
bianster is offline
bianster
Junior Member
Join Date: Sep 2009
Old 11-10-2009 , 05:39   Re: register_cvar with -console option
Reply With Quote #4

I decided to workaround this by keying off the builtin HLDS cvars instead.
bianster is offline
bianster
Junior Member
Join Date: Sep 2009
Old 04-15-2010 , 05:16   Re: register_cvar with -console option
Reply With Quote #5

I'm able to read the value of the plugin defined cvar after moving the map option from the configuration file to the start cmd, thanks to Lev2001 on the bug tracker.

I'm unable to read the value in plugin_init/plugin_cfg, and able to do so only after the first round has started on the server. I was under the impression that the value would have been loaded prior to plugin_init as I don't find anything on the docs that would indicate otherwise.

Is this expected behaviour? Or should I have been able to read it in plugin_init?
bianster is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 04-15-2010 , 21:20   Re: register_cvar with -console option
Reply With Quote #6

When do you realize that no one answers you?
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Old 04-15-2010, 22:15
fysiks
This message has been deleted by fysiks. Reason: nvm.
Reply



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 17:40.


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