Raised This Month: $32 Target: $400
 8% 

CVar Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XARIUS
SourceMod Donor
Join Date: May 2008
Location: Atlanta, GA
Old 10-01-2008 , 10:19   CVar Help
Reply With Quote #1

Hey folks, got a question.

Warmup round plugin works great, but I'm having issues with getting the cvar's set from the config file prior to OnMapStart triggering.

Basically, if you restart the server, the initial map uses the plugin defaults, and the second map onward uses the values from the config file.

Where the hell can I put AutoExecConfig besides OnPluginStart to get it to load the values from the config earlier/faster, so that the first map on "load" has the proper settings? It has to go after the cvar's and it has to go after the hookconvarchanges, so I'm sorta stumped.

Code:
public OnPluginStart()
{
  LoadTranslations("warmup.phrases");
  CreateConVar("sm_warmupround_version", VERSION, "Warmup Round Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  g_Cvarenabled = CreateConVar("sm_warmupround_enabled", "1", "Enable this plugin. 0 = Disabled");
  g_Cvartime = CreateConVar("sm_warmupround_time", "30", "Time in seconds for the warmup to last.  Minimum 15.", _, true, 15.0, true, 120.0);
  g_Cvarweapon = CreateConVar("sm_warmupround_weapon", "hegrenade", "Weapon to give players during warmup.  Leave blank for knife only.  HEGrenades are unlimted.  Examples: deagle,fiveseven,elite,p228");
  g_Cvarrespawn = CreateConVar("sm_warmupround_respawn", "1", "Respawn players during warmup. 0 = Disabled");
  g_Cvarfriendlyfire = CreateConVar("sm_warmupround_friendlyfire", "1", "Disable friendly fire during warmup. (Use this if you keep friendly fire ON normally) 0 = Disabled");
  g_Cvarpreexec = CreateConVar("sm_warmupround_preexec", "", "Config file to execute prior to warmup round starting.  File goes in /cfg/ directory.  (Example: 'prewarmup.cfg' | Leave blank for none)");
  g_Cvarpostexec = CreateConVar("sm_warmupround_postexec", "", "Config file to execute after warmup round has ended.  File goes in /cfg/ directory.  (Example: 'postwarmup.cfg' | Leave blank for none)");
  GetLanguageInfo(GetServerLanguage(), languagecode, sizeof(languagecode), language, sizeof(language));

  HookEvent("player_death", EventPlayerDeath, EventHookMode_Post);
  HookEvent("item_pickup", EventItemPickup, EventHookMode_Post);
  HookEvent("weapon_fire", EventWeaponFire, EventHookMode_Post);
  
  HookConVarChange(g_Cvarenabled, OnSettingChanged);
  HookConVarChange(g_Cvartime, OnSettingChanged);
  HookConVarChange(g_Cvarweapon, OnSettingChanged);
  HookConVarChange(g_Cvarrespawn, OnSettingChanged);
  HookConVarChange(g_Cvarfriendlyfire, OnSettingChanged);
  HookConVarChange(g_Cvarpreexec, OnSettingChanged);
  HookConVarChange(g_Cvarpostexec, OnSettingChanged);

  g_enabled = GetConVarBool(g_Cvarenabled);
  g_respawn = GetConVarBool(g_Cvarrespawn);
  g_friendlyfire = GetConVarBool(g_Cvarfriendlyfire);
  g_time = GetConVarInt(g_Cvartime);
  GetConVarString(g_Cvarpreexec, g_preexec, sizeof(g_preexec));
  GetConVarString(g_Cvarpostexec, g_postexec, sizeof(g_postexec));
  GetConVarString(g_Cvarweapon, g_weapon, sizeof(g_weapon));
  timesrepeated = g_time;

  SetupOffsets();
  
  AutoExecConfig(true, "warmup");
}
Thanks,

X
XARIUS is offline
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 10-01-2008 , 10:29   Re: CVar Help
Reply With Quote #2

In my experience, OnMapStart() seems to fire before the configs are executed. You should use OnConfigsExecuted().
__________________
"Good grammar is essential, Robin."
- Batman
L. Duke is offline
Lebson506th
Veteran Member
Join Date: Jul 2008
Old 10-01-2008 , 10:40   Re: CVar Help
Reply With Quote #3

But OnConfigsExecuted is bugged on listen servers except for the most recent version of the 1.1 trunk
__________________
My Plugins
Spray Tracer by Nican, maintained by me
Simple TK Manager
DoD:S Admin Weapons

Links
Resistance and Liberation (A HL2 Multiplayer Modification)
Lebson506th is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 10-01-2008 , 10:45   Re: CVar Help
Reply With Quote #4

I would suggest OnConfigsExecuted as well, but I've had problems with it.

If nothing else, you can create a timer to do it in OnPluginStart.
RM_Hamster is offline
XARIUS
SourceMod Donor
Join Date: May 2008
Location: Atlanta, GA
Old 10-01-2008 , 10:48   Re: CVar Help
Reply With Quote #5

Maybe the problem is I'm triggering the warmup round in the wrong place then.

The best place I found to start the warmup *was* using OnMapStart..

Code:
public OnMapStart()
{
    if (g_enabled)
    {
    timesrepeated = g_time;
    IsWarmup = true;
    new String:buffer[32] = "cfg/";
    StrCat(buffer, sizeof(buffer), g_preexec);
    if (FileExists(buffer))
    {
      ServerCommand("exec %s", g_preexec);
    }
    if (g_friendlyfire)
    {
      ServerCommand("mp_friendlyfire 0");
    }
    CreateTimer(1.0, Countdown, _, TIMER_REPEAT);
    }
}
Is there another event I can use to start the warmup round so that I can get the cart out from in front of the horse? The point was to find a place that only fires once, when a new map starts.

Last edited by XARIUS; 10-01-2008 at 10:54.
XARIUS is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 10-01-2008 , 10:57   Re: CVar Help
Reply With Quote #6

Actually, looking through the API reference, perhaps OnAutoConfigsBuffered is what you're looking for?

http://docs.sourcemod.net/api/index....ad=show&id=852
RM_Hamster is offline
XARIUS
SourceMod Donor
Join Date: May 2008
Location: Atlanta, GA
Old 10-01-2008 , 11:03   Re: CVar Help
Reply With Quote #7

Quote:
Originally Posted by RM_Hamster View Post
Actually, looking through the API reference, perhaps OnAutoConfigsBuffered is what you're looking for?

http://docs.sourcemod.net/api/index....ad=show&id=852
Most Excellent, thanks!

It works like a charm.
XARIUS is offline
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 10-01-2008 , 15:12   Re: CVar Help
Reply With Quote #8

No problem
RM_Hamster is offline
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 05:38.


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