PDA

View Full Version : [TF2] Is round in progress?


pcmaster
10-24-2014, 13:36
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?

Powerlord
10-24-2014, 13:40
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.

pcmaster
10-24-2014, 14:17
Thanks for your response.

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

Example code:


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

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


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\sourcem od\scripting\include\sdktools_gamerules.inc:: GameRules_GetRoundState()

Powerlord
10-24-2014, 14:41
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.

pcmaster
10-24-2014, 14:44
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!

friagram
10-25-2014, 02:32
https://sm.alliedmods.net/api/index.php?fastload=show&id=1003&
Use onmapstart for lateload.

Leonardo
10-26-2014, 06:29
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.
new bool:bLateLoaded = false;

public APLRes:AskPluginLoad2( Handle:hPlugin, bool:bLateLoad, String:szError[], iErrorLength )
{
bLateLoaded = bLateLoad;
return APLRes_Success;
}

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