AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] Is round in progress? (https://forums.alliedmods.net/showthread.php?t=250423)

pcmaster 10-24-2014 13:36

[TF2] Is round in progress?
 
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

Re: [TF2] Is round in progress?
 
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

Re: [TF2] Is round in progress?
 
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()


Powerlord 10-24-2014 14:41

Re: [TF2] Is round in progress?
 
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

Re: [TF2] Is round in progress?
 
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

Re: [TF2] Is round in progress?
 
https://sm.alliedmods.net/api/index....=show&id=1003&
Use onmapstart for lateload.

Leonardo 10-26-2014 06:29

Re: [TF2] Is round in progress?
 
Quote:

Originally Posted by pcmaster (Post 2215284)
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 ); 



All times are GMT -4. The time now is 15:49.

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