Search found 241 matches

by Mahi
Sun Jul 26, 2015 3:48 pm
Forum: Plugin Development Support
Topic: EntityPreHook bump_weapon lags
Replies: 8
Views: 7083

Just so you know, we are working on a weapon restrict system that will handle not only bumping weapons but also stops restricted players from purchasing them . I hope the bolded part is going to be optional! What if you want the player to still be able to drop items for his teammates, but not use t...
by Mahi
Sat Jul 25, 2015 1:18 pm
Forum: Plugin Development Support
Topic: Getting the name of a game event in PostHook of firing an event?
Replies: 1
Views: 2034

Getting the name of a game event in PostHook of firing an event?

I'm trying to fire my own game event listeners after all the other listeners have been called. I'm using PostHook for this purpose, here's my code: FIRE_EVENT_FUNC = get_object_pointer(game_event_manager).make_virtual_function( 7 if PLATFORM == 'windows' else 8, Convention.THISCA...
by Mahi
Fri Jul 17, 2015 5:16 pm
Forum: News & Announcements
Topic: New release July 2nd, 2015!!
Replies: 14
Views: 34860

When it was first added, we didn't have a built in way to slay a player. If someone saw that a PlayerEntity instance had a 'kill' method, they might try to use it and it would crash their server instead of kill the player. We do have a 'slay' method now, that we could also wrap with kill, which wou...
by Mahi
Fri Jul 17, 2015 11:10 am
Forum: News & Announcements
Topic: New release July 2nd, 2015!!
Replies: 14
Views: 34860

Yes, that is what he meant. Also, we have the Kill Input dynamically added as the 'remove' method for the Entity class: https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/data/source-python/entities/CBaseEntity.ini#L16 Entity(index).remove() Is ...
by Mahi
Sun Jul 12, 2015 11:17 pm
Forum: Custom Packages
Topic: EasyPlayer
Replies: 15
Views: 37974

Thanks for the suggestion! I'm not sure what you mean by this? How's it an improvement over the current style? Avoid checking for None where, I don't think we need to check for None at the moment? Also, I don't see how your example supports multiple effects of the same type. EDIT: Ahh, you were refe...
by Mahi
Sun Jul 12, 2015 5:51 pm
Forum: Custom Packages
Topic: EasyPlayer
Replies: 15
Views: 37974

Update 12.7.2015: You no longer use player.freeze(0) to unfreeze a player, but instead you capture a _PlayerEffect instance and call .cancel() method on it. This way you can even cancel effects with a fixed duration. (Thanks to Ayuto for the suggestion :) ) Here's an example of the n...
by Mahi
Sat Jul 11, 2015 8:24 pm
Forum: Plugin Development Support
Topic: [TF2] *_from_index functions are screwed up...
Replies: 20
Views: 15111

"playerinfo_from_index(PlayerInfo)" tells us that you're passing in a PlayerInfo instance, not an index. Try printing out the "index" before using it on a function
by Mahi
Tue Jul 07, 2015 12:05 pm
Forum: Custom Packages
Topic: EasyPlayer
Replies: 15
Views: 37974

EasyPlayer

EasyPlayer is an idea of a player class that automates all the player effects without having to worry about other people's plugins interfering with your plugin. A good example of this are move types: Your plugin gives noclip to someone for 10 seconds (using player.move_type = MoveType.NOCLIP ), but ...
by Mahi
Mon Jul 06, 2015 5:53 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Alright, good to know. But yeah, I'm fine with using type(PlayerEntity) as long as it works! :) And I'm aware of type(x) == x.__class__, but I've always found type() better looking and less-hacky :)
by Mahi
Mon Jul 06, 2015 3:09 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Interesting. So you're unaware of why this issue is happening? I can't find any classes related to player class that even use metaclasses... Well, I'll just use type(PlayerEntity) for now. :) Thanks for the help!
by Mahi
Mon Jul 06, 2015 2:24 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Indeed, it wouldn't be ideal, which is why I tried metaclasses. However, there seems to be a metaclass conflict, apparently PlayerEntity already has a custom metaclass (coming from BaseEntity, couldn't find it elsewhere? I could be blind though): [SP] Caught an Exception: Traceback (most recent call...
by Mahi
Mon Jul 06, 2015 9:36 am
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

class P(PlayerEntity): _instances = {} def __new__(cls, index): if index not in cls._instances: instance = cls._instances[index] = super().__new__(cls, index) instance._effects = collections.defaultdict(list) instance.restrictions = set() return cls._...
by Mahi
Sun Jul 05, 2015 2:29 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Yes, your edit is correct. :) You wouldn't need to use my Player class for anything if you were to subclass your own :) Sorry if I explained it badly.
by Mahi
Sun Jul 05, 2015 9:55 am
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

If someone subclassed your Player class, they would have to overwrite your __new__ anyway and use a different dictionary. The global dictionary only holds one instance per index. I liked your other edits that you now seem to have edited out where you admitted your implementation is wrong. Setting i...
by Mahi
Sat Jul 04, 2015 4:48 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

L'In20Cible wrote:You can calls your __init__ after __new__ in your own __new__ method. As long as it is called prior setting an attribute so boost can link the instance to its wrapper.
Again didn't quite understand, sorry... :( Can you give an example? What do you mean call my __init__ after __new__?
by Mahi
Sat Jul 04, 2015 2:19 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Why don't you use the global dictionary instead of calling Player() constantly? player = player_dictionary[game_event.get_int('userid')] You 'could' also set that value at the class level instead of using __new__ or __init__. What if someone wants to subclass my Player class? They'd...
by Mahi
Sat Jul 04, 2015 2:05 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Here's a quick example of something similar to what I'm trying to do: from players.entity import PlayerEntity from players.helpers import index_from_userid from events import Event _player_dict = {} @Event def player_hurt(game_event): player = Player(index_from_userid(game_event.get_...
by Mahi
Sat Jul 04, 2015 1:01 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Using object.__setattr__() isn't a feasibule solution, as my class is designed to be subclassed, and I'd have to use object.__setattr__() in all the subclasses too. Would you guys have any workaround for this? I don't think it's desirable to have to call __init__ before you can set attributes on an ...
by Mahi
Fri Jul 03, 2015 3:24 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Check out how Entity overridesoverrides __new__. You need to call __init__ to construct the base class. Not sure what you mean by this. I can't define "just_an_attribute" in __init__, since it's something that needs to be defined only once. I ended up using object.__setattr__(inst, 'just_an_attribu...
by Mahi
Fri Jul 03, 2015 1:17 pm
Forum: Plugin Development Support
Topic: Unable to add attributes to a subclass of PlayerEntity in __new__?
Replies: 23
Views: 12230

Unable to add attributes to a subclass of PlayerEntity in __new__?

from players.entity import PlayerEntity class MyPlayer(PlayerEntity): def __new__(cls, index): inst = super().__new__(cls, index) inst.just_an_attribute = True return inst Raises the following error when used: [SP] Caught an Exception: Traceback (most recent call las...

Go to advanced search