Raised This Month: $12 Target: $400
 3% 

[TF2] Is round in progress?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 10-24-2014 , 13:36   [TF2] Is round in progress?
Reply With Quote #1

Hello,

for a plugin I am currently working on, I am looking for a way to detect whether or not a round is currently active (aka. the round_start event fired).
Hooking the start functions works fine, but I also want to detect that when the plugin is being late-loaded - the events don't fire until the next round start.

Anyway to check that?
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-24-2014 , 13:40   Re: [TF2] Is round in progress?
Reply With Quote #2

Side note: TF2 doesn't use the round_start and round_end events... it uses teamplay_round_start and teamplay_round_win.

Anyway, there's probably something in the tf_objective_resource entity, but I haven't looked through its netprops to check that.

Edit: Er... actually, look through theSDKTools GameRules_GetRoundState stuff. I want to say that only RoundState_RoundRunning and RoundState_Stalemate occur while a round is running.

Edit 2: RoundState_Stalemate is used for both Sudden Death and Arena. Unfortunately, it may also be used for what happens when both teams lose after a Sudden Death round or if Sudden Death is disabled... I haven't tested it to find out. Although the "one team is in humiliation" length is controlled by mp_bonusroundtime... so that may be RoundState_Bonus.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-24-2014 at 14:01.
Powerlord is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 10-24-2014 , 14:17   Re: [TF2] Is round in progress?
Reply With Quote #3

Thanks for your response.

Unfortunately, GameRules_GetRoundState doesn't appear to be working on AskPluginLoad2, it simply doesn't do anything.

Example code:

PHP Code:
PrintToServer("Stuff: %d"_:GameRules_GetRoundState()); 
Nothing gets printed out, not even "Stuff".

EDIT:
Just looked into my error logs, getting spammed with this:

Code:
L 10/24/2014 - 20:21:01: [SM] Plugin encountered error 21: Native is not bound
L 10/24/2014 - 20:21:01: [SM] Native "GameRules_GetProp" reported: 
L 10/24/2014 - 20:21:01: [SM] Displaying call stack trace for plugin "ghostfort_giftfarm.smx":
L 10/24/2014 - 20:21:01: [SM]   [0]  Line 201, E:\Sourcemod_Dev\TF2_Server\tf\addons\sourcemod\scripting\include\sdktools_gamerules.inc::GameRules_GetRoundState()
__________________
Stopped hosting servers as of November 2018, no longer active around here.

Last edited by pcmaster; 10-24-2014 at 14:24.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-24-2014 , 14:41   Re: [TF2] Is round in progress?
Reply With Quote #4

It almost sounds like SDKTools isn't loaded when this plugin's AskPluginLoad2 is being called.

...you do have an #include <sdktools> and not after an #undef REQUIRE_EXTENSIONS, right?

Incidentally, you can also tell if the plugin is late loaded from AskPluginLoad2... are you checking that before calling GameRules_GetRoundState? The various GameRules_ function will probably fail if the server has no GameRules object created.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 10-24-2014 , 14:44   Re: [TF2] Is round in progress?
Reply With Quote #5

As it seems, AskPluginLoad2 is too early for GameRules_* stuff, so I moved it into OnPluginStart and simply set a global variable if the plugin was late loaded or not.
Works now, thanks for your help!
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 10-25-2014 , 02:32   Re: [TF2] Is round in progress?
Reply With Quote #6

https://sm.alliedmods.net/api/index....=show&id=1003&
Use onmapstart for lateload.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 10-25-2014 at 02:33.
friagram is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 10-26-2014 , 06:29   Re: [TF2] Is round in progress?
Reply With Quote #7

Quote:
Originally Posted by pcmaster View Post
As it seems, AskPluginLoad2 is too early for GameRules_* stuff, so I moved it into OnPluginStart and simply set a global variable if the plugin was late loaded or not.
Works now, thanks for your help!
Yep.
PHP Code:
new bool:bLateLoaded false;

public 
APLRes:AskPluginLoad2Handle:hPluginbool:bLateLoadString:szError[], iErrorLength )
{
    
bLateLoaded bLateLoad;
    return 
APLRes_Success;
}

// Or any other callback; depends on your code purpose.
public OnPluginStart()
    
PrintToServer"bLateLoaded = %d"bLateLoaded ); 
__________________

Last edited by Leonardo; 10-26-2014 at 06:30.
Leonardo is offline
Reply


Thread Tools
Display Modes

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 04:31.


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