[CS:S] Scope Detecting

Please post any questions about developing your plugin here. Please use the search function before posting!
cssbestrpg
Senior Member
Posts: 288
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

[CS:S] Scope Detecting

Postby cssbestrpg » Fri Apr 26, 2024 8:30 pm

hi, i am trying to detect if player scoped weapon, but it gives an error

Syntax: Select all

from filters.players import PlayerIter
from listeners.tick import Repeat

def load():
laser_aiming.start(1)

def unload():
laser_aiming.stop()

alive_players = PlayerIter(['alive', 'human'])

@Repeat
def laser_aiming():
for player in alive_players:
weapon = player.get_active_weapon()
if weapon is None:
return
classname = weapon.classname.split('_')[1]
if classname not in ['awp','scout']:
continue
scoped = player.get_property_bool('m_bIsScoped')
if scoped == True:
continue


Code: Select all

[2024-04-26 23:27:31]:
[Source.Python]
[2024-04-26 23:27:31]:
[SP] Caught an Exception:
[2024-04-26 23:27:31]: Traceback (most recent call last):
[2024-04-26 23:27:31]: File "../addons/source-python/packages/source-python/listeners/tick.py", line 79, in _tick
[2024-04-26 23:27:31]: self.pop(0).execute()
[2024-04-26 23:27:31]: File "../addons/source-python/packages/source-python/listeners/tick.py", line 160, in execute
[2024-04-26 23:27:31]: return self.callback(*self.args, **self.kwargs)
[2024-04-26 23:27:31]: File "../addons/source-python/packages/source-python/listeners/tick.py", line 607, in _execute
[2024-04-26 23:27:31]: self.callback(*self.args, **self.kwargs)
[2024-04-26 23:27:31]: File "../addons/source-python/plugins/crosshair/crosshair.py", line 21, in laser_aiming
[2024-04-26 23:27:31]: scoped = player.get_property_bool('m_bIsScoped')
[2024-04-26 23:27:31]: ValueError: Unable to find property 'm_bIsScoped'.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 48 guests