https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/players/weapons/projectiles.py#L18
That line used to be:
Syntax: Select all
class _ProjectileMeta(type):
Having tested, it seems that using 'type' instead causes the same error you are getting, but also crashes the server on plugin_load. I tested changing your example to use BaseEntity.__class__, but that still gave the same error. Changing it to use PlayerEntity.__class__, however, seems to work fine:
Syntax: Select all
from players.entity import PlayerEntity
class MetaTest(PlayerEntity.__class__):
def __new__(cls, name, bases, attrs):
attrs['_instances'] = dict()
return super(MetaTest, cls).__new__(cls, name, bases, attrs)
class Test(PlayerEntity, metaclass=MetaTest):
def __new__(cls, index):
if index not in cls._instances:
cls._instances[index] = super(Test, cls).__new__(cls, index)
return cls._instances[index]
class Test2(Test):
...
class Test3(Test):
...
one = Test(1)
two = Test2(1)
three = Test3(1)
print(one)
print(two)
print(three)
print(Test(1))
And that outputs:
Code: Select all
<new.new.Test object at 0x1E5C6900>
<new.new.Test2 object at 0x1E5C6930>
<new.new.Test3 object at 0x1E5C6960>
<new.new.Test object at 0x1E5C6900>