Hook for changes in base upkeep time?Solved

Dear uMod community,

I was wondering if there is a way to somehow hook changes in upkeep time?
As I noticed there wasn't a real hook for upkeep changes, I have tried to use a less optimal way where I use the OnLootEntityEnd hook like this:

void OnLootEntityEnd(BasePlayer player, BaseCombatEntity entity)
{
	if(entity.ShortPrefabName == "cupboard.tool.deployed") {
		BuildingPrivlidge priv = entity.GetBuildingPrivilege();
		float minutesLeft = priv.GetProtectedMinutes();
		string minutes = minutesLeft.ToString();
		Puts(minutes);
	}
}

 

But this code returns the wrong upkeep time in minutes when you close out on the toolcupboard inventory before the new upkeep time has been calculated.

I hope someone is able to point me in the right direction.
That would be much appreciated.

Best regards,
Elephant47
Try GetProtectedMinutes(true) ... it will force to recalculate. False (default) parameter returns only cached value
5d2e4d835505b.png Ultra
Try GetProtectedMinutes(true) ... it will force to recalculate. False (default) parameter returns only cached value

That works perfectly! Exactly what I have been looking for.
Thank you for your explanation Ultra!

I will mark this question as solved.

Locked automatically