AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_cvar with -console option (https://forums.alliedmods.net/showthread.php?t=108495)

bianster 11-05-2009 23:04

register_cvar with -console option
 
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 11-08-2009 21:23

Re: register_cvar with -console option
 
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 11-10-2009 05:39

Re: register_cvar with -console option
 
I decided to workaround this by keying off the builtin HLDS cvars instead.

bianster 04-15-2010 05:16

Re: register_cvar with -console option
 
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?

Jelle 04-15-2010 21:20

Re: register_cvar with -console option
 
When do you realize that no one answers you?


All times are GMT -4. The time now is 17:40.

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