Page 1 of 1

finding out who used func_button?

Posted: Sat Nov 05, 2016 6:39 pm
by Banz
Hello once again!

I was wondering if there was a way to find func_button with specific targetname and also find out who pressed that button?

Thanks in advance

Re: finding out who used func_button?

Posted: Sat Nov 05, 2016 6:59 pm
by Ayuto
Something like this might work:

Syntax: Select all

from listeners import OnEntityOutput

YOUR_TARGET_NAME = 'IDK'

@OnEntityOutput
def on_entity_output(output_name, activator, caller, value, delay):
if output_name != 'OnPressed':
return

if caller.classname != 'func_button':
return

if caller.targetname != YOUR_TARGET_NAME:
return

try:
player = Player(activator.index)
except ValueError:
return

print('Player {} activated the button.'.format(player.name))

http://wiki.sourcepython.com/developing ... tityoutput
https://developer.valvesoftware.com/wiki/Func_button

Re: finding out who used func_button?

Posted: Sat Nov 05, 2016 7:25 pm
by Banz
Ayuto wrote:Something like this might work:

Syntax: Select all

from listeners import OnEntityOutput

YOUR_TARGET_NAME = 'IDK'

@OnEntityOutput
def on_entity_output(output_name, activator, caller, value, delay):
if output_name != 'OnPressed':
return

if caller.classname != 'func_button':
return

if caller.targetname != YOUR_TARGET_NAME:
return

try:
player = Player(activator.index)
except ValueError:
return

print('Player {} activated the button.'.format(player.name))

http://wiki.sourcepython.com/developing ... tityoutput
https://developer.valvesoftware.com/wiki/Func_button


Thanks! But this gives me "AttributeError: Attribute "targetname" not found" when I press my button
But yeah this is progress so thank you! :)
Game: csgo build: 486 in case that matters

Re: finding out who used func_button?

Posted: Sat Nov 05, 2016 7:27 pm
by iPlayer
targetname -> target_name

Re: finding out who used func_button?

Posted: Sat Nov 05, 2016 7:31 pm
by Banz
iPlayer wrote:targetname -> target_name

This fixed it