[HL2:DM] Infinite aux power for sprinting OR breathing

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Mon Apr 11, 2016 1:28 pm

Could someone please make for SourcePython?


https://forums.alliedmods.net/showthread.php?t=73097
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Apr 13, 2016 6:05 am

We don't currently have the CBasePlayer::PlayerRunCommand virtual function for HL2:MP in our data. So, the following uses a tick listener instead:

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


If need be, I can add ConVars for sprinting and breathing to allow one to be active instead of always both.

*Note that this requires the newest version of Source.Python (version 305) as it uses 2 properties I just added to the data.


*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
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Postby Painkiller » Wed Apr 13, 2016 4:49 pm

Hi Satoon i have problems.

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

Postby satoon101 » Wed Apr 13, 2016 5:12 pm

I am really not sure why that would happen, but that error seems to be happening when you unload the script. Does it work fine when it's loaded?
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Postby Painkiller » Wed Apr 13, 2016 5:43 pm

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

Postby satoon101 » Wed Apr 13, 2016 6:24 pm

I think you missed this part:
satoon101 wrote:*Edit: I have added CBasePlayer.run_command for hl2mp, so now the following works, as well (as of SP version 306):
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Postby Painkiller » Wed Apr 13, 2016 7:13 pm

I can not use this version.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Wed Apr 20, 2016 4:50 pm

Ok i have updated SP and works fine.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Wed May 08, 2019 3:18 pm

Since the SP update it does not work anymore as it should.

There is no boost.
You can only walk

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
Last edited by Ayuto on Wed May 08, 2019 7:16 pm, edited 1 time in total.
Reason: code --> python
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Ayuto » Wed May 08, 2019 7:21 pm

Oh, I think I know where the problem is. A week ago we improved the speed of many player properties by using a different implementation. However, the new implementation is probably reading the address of "active_devices" using the wrong data type. It's probably unsinged int/short instead of just int. I will investigate this next week.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Thu May 09, 2019 8:43 am

ok,
thanks in advance.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Ayuto » Sat May 11, 2019 8:55 am

User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Mon May 13, 2019 10:15 am

Thank you works fine.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Wed May 15, 2019 6:29 pm

After a long test, I noticed that the same error always appears at the end of the map.
Baster1985
Junior Member
Posts: 10
Joined: Tue Nov 20, 2012 1:21 am

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Baster1985 » Wed May 15, 2019 8:18 pm

It will be time to learn python
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Thu May 16, 2019 9:01 pm

Baster1985 wrote:It will be time to learn python


Yes, if you have time for it?

I would be glad.
Baster1985
Junior Member
Posts: 10
Joined: Tue Nov 20, 2012 1:21 am

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Baster1985 » Thu May 16, 2019 10:17 pm

I rather meant you. Then you do not have to ask others about every little thing
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Fri May 17, 2019 2:16 pm

There are scripters and craftsmen

I am a craftsperson.

I'm so sorry for something I did not create. I am very happy about the support of the community.

As I said, I also like to pay money.
viewtopic.php?f=9&t=2009
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Painkiller » Sun Jun 02, 2019 6:56 am

There's still spending that mistake.

It works in the beginning but after a certain time, not anymore.

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

Re: [HL2:DM] Infinite aux power for sprinting OR breathing

Postby Ayuto » Sun Jun 02, 2019 7:18 am

Just commited a fix:
https://github.com/Source-Python-Dev-Te ... b201fd0b2a

I will publish a new release today (version 690).

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 15 guests