Skip to content

OnPlayerPostRunCommand #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jan 10, 2020 · 3 comments
Closed

OnPlayerPostRunCommand #299

ghost opened this issue Jan 10, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 10, 2020

Let's add this, It's very useful when you want to change something after processed command, because, for example if you set a velocity in OnPlayerRunCommand, velocity from the tick will be processed anyway.

@jordanbriere
Copy link
Contributor

I don't think internally doing twice the work to provide a post listener would worth the effort and extra computing time it implies to be honest. Making the majority of servers suffers that extra load for a listener that might be used by very few plugins that might have to handle that very specific case you mentioned doesn't seem like a good idea from an API standpoint. Especially considering you can already register your own post hook fairly easily:

@EntityPostHook(EntityCondition.is_player, 'run_command')
def _post_run_command(stack_data):
    player = make_object(Player, stack_data[0])
    ...

@Ayuto
Copy link
Member

Ayuto commented Jan 25, 2020

Actually, it shouldn't really have a performance impact. The hook is already installed, so we would just add a post hook callback. Inside of this callback we would simply check if there are PostPlayerRunCommand callbacks. If there aren't any, we would simply quit the handler like we did here:
https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/src/core/sp_hooks.cpp#L175

So, if no plugin registers a PostPlayerRunCommand callback, there are only one or two very simple additional calls.

@ghost
Copy link
Author

ghost commented Jan 25, 2020

Yes!!! Also as I know if I want it through standard EntityPostHook, I should to create the ecx storage otherwise the player pointer will be utilized. I have another problem without the post hook, when you entered in pre hook, gravity velocity (sv_gravity * server.tick_interval / 2.0) has already been added for some reason to player z axis. and maybe it would be better to do these things in post hook of previous tick.

jordanbriere added a commit that referenced this issue Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants