Why getPropertyText not work on Network server?

Discussions about Coding and Scripting
Buggie
Godlike
Posts: 1906
Joined: Sat Mar 21, 2020 5:32 am

Why getPropertyText not work on Network server?

Post by Buggie »

I put simple code inside UTConsole
event PostRender( canvas Canvas )

Code: Select all

local Canvas C;
local PlayerPawn me;

C = Canvas;
me = Root.Console.ViewPort.Actor;

if (me.Weapon.isA('Translocator')) {
	C.SetPos(0, C.ClipY - 300); 
	C.DrawText(" DBG: '" $ 
		me.Weapon.GetPropertyText("MaxTossForce") $ "'; '" $ 				// 1
		Translocator(me.Weapon).GetPropertyText("MaxTossForce") $ "'; '" $ 		// 2
		Translocator(me.Weapon).MaxTossForce $ "'");					// 3
}
Now if I start practice session or multiplayer game I see 3 same values.
But if I start dedicated server, or enter to Network server, I see empty strings for first two values, and proper value, for third. Why?
User avatar
anth
Adept
Posts: 253
Joined: Thu May 13, 2010 2:23 am

Re: Why getPropertyText not work on Network server?

Post by anth »

GetPropertyText and SetPropertyText only work if actor.role == ROLE_AUTHORITY. Try to temporarily set the role of the weapon to ROLE_Authority and restore the old role after calling GetPropertyText.
Buggie
Godlike
Posts: 1906
Joined: Sat Mar 21, 2020 5:32 am

Re: Why getPropertyText not work on Network server?

Post by Buggie »

Thank you. Worked.
I ended with next helper:

Code: Select all

simulated function string getVal(Actor actor, string prop) {
	local string ret;

	Root.Console.ViewPort.Actor.MyHUD.Role = actor.Role; // Always ROLE_Authority so we can use for temp store for avoid Enum issue on set later
	actor.Role = actor.ENetRole.ROLE_Authority;
	ret = actor.GetPropertyText(prop);
	actor.Role = Root.Console.ViewPort.Actor.MyHUD.Role;
	Root.Console.ViewPort.Actor.MyHUD.Role = actor.ENetRole.ROLE_Authority;
	return ret;
}