Get Spectarget

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Get Spectarget

Postby decompile » Fri Jan 01, 2016 7:33 pm

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
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jan 01, 2016 9:05 pm

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
Image
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Jan 01, 2016 9:05 pm

No, you only need to use "m_hObserverTarget" instead of "CBasePlayer.m_hObserverTarget".
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Postby decompile » Fri Jan 01, 2016 9:48 pm

Thank you

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 141 guests