PreEvent player_jump

Please post any questions about developing your plugin here. Please use the search function before posting!
roflmuffin
Junior Member
Posts: 19
Joined: Fri Nov 06, 2015 11:49 pm

PreEvent player_jump

Postby roflmuffin » Mon Dec 28, 2015 3:30 am

Hi there,

I cannot seem to use the @PreEvent decorator to hook the 'player_jump' event in CSGO. When I use the below:

Syntax: Select all

@Event('player_jump')
def jump_event(game_event):
print('Jump')


I receive 'Jump' in console everytime I jump, but this is of course a post hook. When I use the below code:

Syntax: Select all

@PreEvent('player_jump')
def jump_event(game_event):
print('Pre Jump')
return EventAction.CONTINUE


I never receive any output in console and it appears that the function is never run. Other pre hooks run fine (I tested player_spawn, player_death pre events). This is on SP version 205.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Dec 28, 2015 5:33 am

I honestly don't know what to tell you. It works perfectly fine for me.
Image
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Mon Dec 28, 2015 2:25 pm

Be sure you have 2 different function names for Event and PreEvent. If you have registered an Event with the function jump_event, you may not use jump_event for PreEvent, instead name it pre_jump_event or something.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Dec 28, 2015 3:52 pm

I don't think that has ever been true. There was previously an issue where, if you used the same function name multiple times, only the last would be unloaded. Recent changes have fixed that, though. But, from what I can remember, there has never been an issue with registering using the same name.

I actually tested with the following before posting my last reply, and both messages were sent properly:

Syntax: Select all

from events import Event
from events.hooks import PreEvent

@Event('player_jump')
def player_jump(game_event):
print('Jump Event')

@PreEvent('player_jump')
def player_jump(game_event):
print('Pre Jump Event')
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jan 01, 2016 1:25 pm

Yeah, the function's address is stored as a callback by the decorator class, therefore the name sort of doesn't matter. Am I right?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Fri Jan 01, 2016 1:27 pm

Correct, the name of the function itself doesn't matter.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jan 01, 2016 2:00 pm

Yes, it did used to matter on unload when we iterated over the __dir__ of each module.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Google [Bot] and 43 guests