Pretty sure I found a bug, looking to see if it can be replicated

Please post any questions about developing your plugin here. Please use the search function before posting!
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Pretty sure I found a bug, looking to see if it can be replicated

Postby arawra » Sun Sep 27, 2020 7:59 am

Trying to give a player weapons after setting their model to a chicken, and then back to the original.

Syntax: Select all

@ClientCommand('!polymorph')
def polymorph(command, index):
player = Player(index)
target = player.get_view_player()
if not target:
return
mdl = target.model
target.model = Model('models/chicken/chicken.mdl')
for weapon in target.weapons():
Delay(3, target.give_named_item, (weapon.weapon_name,))
weapon.remove()
Delay(3, resetModel, (target, mdl))

def resetModel(player, mdl):
player.model = mdl


Code: Select all

[SP] Caught an Exception:                                                                                               Traceback (most recent call last):                                                                                        File "..\addons\source-python\packages\source-python\listeners\tick.py", line 80, in _tick                                self.pop(0).execute()                                                                                                 File "..\addons\source-python\packages\source-python\listeners\tick.py", line 161, in execute                             return self.callback(*self.args, **self.kwargs)                                                                       File "..\addons\source-python\packages\source-python\memory\helpers.py", line 334, in __call__                            return super().__call__(self._this, *args)                                                                            File "<string>", line 1, in <lambda>                                                                                                                                                                                                          ValueError: Number of passed arguments is not equal to the required number.


The exception is caused on the Delay that gives weapons (tested this in various ways to make sure). At first I thought it was an issue with giving someone a weapon if they didn't have the animations for one etc (i.e. being a chicken) but then when I increased the delay to 3.5 versus the 3 second delay for returning the model to its original state, it gave the same error as well.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby L'In20Cible » Sun Sep 27, 2020 8:31 am

  1. sp info
  2. Complete code
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby arawra » Sun Sep 27, 2020 8:50 am

Code: Select all

sp info                                                                                                                                                                                                                                         IMPORTANT: Please copy the full output.                                                                                 --------------------------------------------------------                                                                Checksum      : 69ed9b7cbfc55f9465bec8a41d35d8c7                                                                        Date          : 2020-09-27 08:50:32.871054                                                                              OS            : Windows-10-10.0.18362                                                                                   Game          : csgo                                                                                                    SP version    : 700                                                                                                     Github commit : 53f3bb562a2975c828d4c5145e21979859f57731                                                                Server plugins:                                                                                                            00: Source.Python, (C) 2012-2020, Source.Python Team.                                                                SP plugins:                                                                                                                00: test6                                                                                                            --------------------------------------------------------


That was the complete code. The only thing not included were the imports.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby L'In20Cible » Sun Sep 27, 2020 8:57 am

arawra wrote:That was the complete code. The only thing not included were the imports.

Which should be included. We shouldn't have to fix import errors and your reproducible code should be loadable as is. :smile:

Anyways, I was unable to reproduce with:

Syntax: Select all

from players.entity import Player
from listeners.tick import Delay

Delay(1, Player(1).give_named_item, ('weapon_awp',))


What do you get if you print target.give_named_item.arguments? My first guess would be that you have a plugin that is registering that pointer without all the required parameters.
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby arawra » Sun Sep 27, 2020 9:03 am

L'In20Cible wrote:What do you get if you print target.give_named_item.arguments? My first guess would be that you have a plugin that is registering that pointer without all the required parameters.


Syntax: Select all

(_memory.DataType.POINTER, _memory.DataType.STRING, _memory.DataType.INT, _memory.DataType.POINTER, _memory.DataType.BOOL, _memory.DataType.POINTER)


I'm not sure what the original signature/value is for the function, so I am not sure what I'd be comparing to.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby L'In20Cible » Sun Sep 27, 2020 9:11 am

arawra wrote:
L'In20Cible wrote:What do you get if you print target.give_named_item.arguments? My first guess would be that you have a plugin that is registering that pointer without all the required parameters.


Syntax: Select all

(_memory.DataType.POINTER, _memory.DataType.STRING, _memory.DataType.INT, _memory.DataType.POINTER, _memory.DataType.BOOL, _memory.DataType.POINTER)


I'm not sure what the original signature/value is for the function, so I am not sure what I'd be comparing to.

That prototype is correct. If you add a debug message at the top of ../players/engines/csgo/__init__.py#L168-L174 does it gets printed?
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby arawra » Sun Sep 27, 2020 9:14 am

L'In20Cible wrote:That prototype is correct. If you add a debug message at the top of ../players/engines/csgo/__init__.py#L168-L174 does it gets printed?



Code: Select all

[Source.Python] Loading...                                                                                              ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                LOADING ../players/engines/csgo/__init__.py                                                                             ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                [Source.Python] Loaded successfully.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby L'In20Cible » Sun Sep 27, 2020 9:16 am

arawra wrote:
L'In20Cible wrote:That prototype is correct. If you add a debug message at the top of ../players/engines/csgo/__init__.py#L168-L174 does it gets printed?



Code: Select all

[Source.Python] Loading...                                                                                              ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                LOADING ../players/engines/csgo/__init__.py                                                                             ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                ----------------------------------------                                                                                [Source.Python] Loaded successfully.

I mean inside the function. For example:

Syntax: Select all

@wrap_entity_mem_func
def give_named_item(
self, item, sub_type=0, econ_item_view=None, unk=False, unk2=NULL):
"""Give the player a named item."""
# TODO: What's the unk argument for?
# unk2 is a Vector (position)? Should do some tests...
print('>> GIVE NAMED ITEM:', self.name, item, sub_type, econ_item_view, unk, unk2)
return [item, sub_type, econ_item_view, unk, unk2]
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby arawra » Sun Sep 27, 2020 9:24 am

An exception was raised without printing my statement.

I did supply the default arguments explicitly, and the function returns without exception.

Syntax: Select all

from engines.precache import Model
from players.entity import Player
from listeners.tick import Delay
from commands.client import ClientCommand
from memory import NULL

@ClientCommand('!polymorph')
def polymorph(command, index):
player = Player(index)
target = player.get_view_player()
if not target:
return
mdl = target.model
#target.model = Model('models/chicken/chicken.mdl')
print(target.give_named_item.arguments)
for weapon in target.weapons():
Delay(3, target.give_named_item, (weapon.weapon_name, 0, None, False, NULL))
weapon.remove()
#Delay(3, resetModel, (target, mdl))


Could it be possible that *args or **kwargs are overwriting the default arguments? (I am very unfamiliar with *args or *kwargs in Python).
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby L'In20Cible » Sun Sep 27, 2020 9:31 am

arawra wrote:An exception was raised without printing my statement.

I did supply the default arguments explicitly, and the function returns without exception.

Syntax: Select all

from engines.precache import Model
from players.entity import Player
from listeners.tick import Delay
from commands.client import ClientCommand
from memory import NULL

@ClientCommand('!polymorph')
def polymorph(command, index):
player = Player(index)
target = player.get_view_player()
if not target:
return
mdl = target.model
#target.model = Model('models/chicken/chicken.mdl')
print(target.give_named_item.arguments)
for weapon in target.weapons():
Delay(3, target.give_named_item, (weapon.weapon_name, 0, None, False, NULL))
weapon.remove()
#Delay(3, resetModel, (target, mdl))


Could it be possible that *args or **kwargs are overwriting the default arguments? (I am very unfamiliar with *args or *kwargs in Python).


Can you PM me your FTP credentials or a zip of your addons directory?
arawra
Senior Member
Posts: 190
Joined: Fri Jun 21, 2013 6:51 am

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby arawra » Sun Sep 27, 2020 9:37 am

Sent.

Files are still uploading, so maybe give it 15m.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Pretty sure I found a bug, looking to see if it can be replicated

Postby L'In20Cible » Sun Sep 27, 2020 10:30 am

I found the issue. The problem isn't give_named_item but Player.get_view_player. It returns a Player, but in that scope Player is _base.Player not engines.csgo.Player and since that class do not have the wrapper it calls it with missing arguments. Replace:

Syntax: Select all

target = player.get_view_player()
To:

Syntax: Select all

target = Player(player.get_view_player().index)


For now until we get that fixed.

EDIT: Fixed into 96d303b.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 20 guests