Page 1 of 1

Events

Posted: Thu Aug 01, 2013 6:49 pm
by Predz
Hey, I know the plugin is still very into alpha stages however I have built the source-python.dll to have a "play" with it. To see the new functions and modules.

I am using the script:

Code: Select all

from players.helpers import index_from_playerinfo
from events import Event
import messages

def tell(player, text):
    pindex = index_from_playerinfo(player)
    instance = messages.SayText2(index=pindex, chat=1, message=str(text))
    instance.send(pindex)

@Event
def player_spawn(GE):
   user = GE.get_int('userid')
   tell(user, '\x02Your Userid is '+str(user)+'')


But it wont actually register the event. I can get the "onCommand" to work, like "SayCommand", "ClientCommand", etc. Just for some reason I get this error: "GameEventListener2 callback in list should not be - player_spawn"

Anything I have done wrong?

Posted: Thu Aug 01, 2013 7:24 pm
by Predz
If have also tried going back a set into the Libs, and using EventRegistry but still the same error. :(

Code: Select all

from players.helpers import index_from_playerinfo
from events import EventRegistry
import messages

def tell(player, text):
    pindex = index_from_playerinfo(player)
    instance = messages.SayText2(index=pindex, chat=1, message=str(text))
    instance.send(pindex)

def load():
   EventRegistry.register_for_event('player_spawn', onSpawn)
   
def unload():
   EventRegistry.unregister_for_event('player_spawn', onSpawn)
   
def onSpawn(GE):
   user = GE.get_int('userid')
   tell(user, '\x02Your Userid is '+str(user)+'')

Posted: Thu Aug 01, 2013 7:28 pm
by satoon101
I seem to remember this error at some point. I will run some tests when I get home tonight. What game are you testing this on?

Also, just a heads up, but you are passing a userid to your tell function, but then acting as if it is a CPlayerInfo instance.

Satoon

Posted: Thu Aug 01, 2013 7:31 pm
by Predz
I am running this on CSGO, using Windows Server.

Posted: Thu Aug 01, 2013 9:58 pm
by Omega_K2
Actually events seem to work despite the error (on other events at least, maybe not on that specific one). Try to correct what satoon said first. You should be using index_from_userid, as you are passing userinfo and not playerinfo.

Edit: Yeah, can also confirm it doesn't seem to work atm, tried player_say. But I think only CS:GO spits out that error. Also found this by googling :
http://forums.alliedmods.net/showthread.php?t=194382

Posted: Fri Aug 02, 2013 1:43 am
by Omega_K2
Ok, instead of editing I better post this :P

Fix seems trivial (not sure what it does to orangebox, but fixes CS:GO at least :P)

Go to this file:
http://code.google.com/p/source-python/source/browse/src/core/modules/events/events_wrap.cpp#167

And replace:

Code: Select all

return 0;

with

Code: Select all

return EVENT_DEBUG_ID_INIT;


and recompile

Posted: Fri Aug 02, 2013 6:29 am
by Ayuto
Fixed as of the latest revision! Thanks for reporting and solving! :D

http://code.google.com/p/source-python/source/detail?r=631110465f107c65f21b71cf41e049fdf577b59d

Posted: Fri Aug 02, 2013 9:42 am
by Predz
Thx, I will have a test when I get back off holiday :)