Page 1 of 1

Get Spectarget

Posted: Fri Jan 01, 2016 7:33 pm
by decompile
Hey how can i get the spectarget?

Tried something like this

Syntax: Select all

def _getSpecTarget(index):
handle = Player(index).get_property_int('CBasePlayer.m_hObserverTarget')
if handle == -1: return 0
return players.helpers.userid_from_inthandle(handle)


Would that work? Didn't tested it

Posted: Fri Jan 01, 2016 9:05 pm
by satoon101
That should work properly to return the userid of the observed player. We already have that property added to our data, though, so you can just use the observer_target attribute:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/data/source-python/entities/CBasePlayer.ini#L14

Posted: Fri Jan 01, 2016 9:05 pm
by Ayuto
No, you only need to use "m_hObserverTarget" instead of "CBasePlayer.m_hObserverTarget".

Posted: Fri Jan 01, 2016 9:48 pm
by decompile
Thank you