[HL2:DM] Infinite aux power for sprinting OR breathing
Posted: Mon Apr 11, 2016 1:28 pm
Syntax: Select all
from filters.players import PlayerIter
from listeners import OnTick
SPRINTING = 1
BREATHING = 4
@OnTick
def _tick():
for player in PlayerIter('alive'):
active_devices = player.active_devices
if active_devices & SPRINTING:
player.active_devices = active_devices & ~SPRINTING
player.suit_power_load = 0
if active_devices & BREATHING:
player.active_devices = active_devices & ~BREATHING
player.suit_power_load = 0
Syntax: Select all
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from memory import make_object
from players.entity import Player
SPRINTING = 1
BREATHING = 4
@EntityPreHook(EntityCondition.is_player, 'run_command')
def pre_run_command(stackdata):
player = make_object(Player, stackdata[0])
if player.dead:
return
active_devices = player.active_devices
if active_devices & SPRINTING:
player.active_devices = active_devices & ~SPRINTING
player.suit_power_load = 0
if active_devices & BREATHING:
player.active_devices = active_devices & ~BREATHING
player.suit_power_load = 0
Syntax: Select all
18:48:20 [SP] Unloading plugin 'auxpower'...
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/plugins/command.py', line 204, in call_command
self[sub_command](*args)
File '../addons/source-python/packages/source-python/plugins/command.py', line 342, in reload_plugin
self.unload_plugin(plugin_name)
File '../addons/source-python/packages/source-python/plugins/command.py', line 320, in unload_plugin
del self.manager[plugin_name]
File '../addons/source-python/packages/source-python/plugins/manager.py', line 149, in __delitem__
self._remove_modules(plugin_name)
File '../addons/source-python/packages/source-python/plugins/manager.py', line 197, in _remove_modules
instance._unload_instance()
File '../addons/source-python/packages/source-python/entities/hooks.py', line 143, in _unload_instance
_waiting_entity_hooks.remove(self)
ValueError: list.remove(x): x not in list
Syntax: Select all
9:41:53 sp load auxpower
19:41:53 [SP] Loading plugin 'auxpower'...
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/plugins/manager.py', line 71, in __missing__
instance = self.instance(plugin_name, self.base_import)
File '../addons/source-python/packages/source-python/plugins/instance.py', line 82, in __init__
self._plugin = import_module(import_name)
File '../addons/source-python/plugins/auxpower/auxpower.py', line 10, in <module>
@EntityPreHook(EntityCondition.is_player, 'run_command')
File '../addons/source-python/packages/source-python/entities/hooks.py', line 103, in __call__
if self.initialize(entity):
File '../addons/source-python/packages/source-python/entities/hooks.py', line 131, in initialize
self.hooked_function = getattr(entity, self.function)
File '../addons/source-python/packages/source-python/entities/entity.py', line 98, in __getattr__
raise AttributeError('Attribute '{0}' not found'.format(attr))
AttributeError: Attribute 'run_command' not found
[SP] Plugin 'auxpower' was unable to be loaded.
satoon101 wrote:*Edit: I have added CBasePlayer.run_command for hl2mp, so now the following works, as well (as of SP version 306):
Syntax: Select all
from entities.hooks import EntityCondition
from entities.hooks import EntityPreHook
from memory import make_object
from players.entity import Player
SPRINTING = 1
BREATHING = 4
@EntityPreHook(EntityCondition.is_player, 'run_command')
def pre_run_command(stackdata):
player = make_object(Player, stackdata[0])
if player.dead:
return
active_devices = player.active_devices
if active_devices & SPRINTING:
player.active_devices = active_devices & ~SPRINTING
player.suit_power_load = 0
if active_devices & BREATHING:
player.active_devices = active_devices & ~BREATHING
player.suit_power_load = 0
Baster1985 wrote:It will be time to learn python
Code: Select all
2019-06-02 08:47:29 - sp - EXCEPTION
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/auxpower/auxpower.py", line 20, in pre_run_command
player.suit_power_load = 0
File "../addons/source-python/packages/source-python/entities/_base.py", line 125, in __setattr__
object.__setattr__(self, attr, value)
ValueError: Unable to find property 'm_flSuitPowerLoad'.