Events

Please post any questions about developing your plugin here. Please use the search function before posting!
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Events

Postby Predz » Thu Aug 01, 2013 6:49 pm

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?
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Thu Aug 01, 2013 7:24 pm

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)+'')
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Aug 01, 2013 7:28 pm

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
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Thu Aug 01, 2013 7:31 pm

I am running this on CSGO, using Windows Server.
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Thu Aug 01, 2013 9:58 pm

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
Libraries: k2tools
Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)
Plugins (game-specific): None atm

If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Postby Omega_K2 » Fri Aug 02, 2013 1:43 am

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
Libraries: k2tools

Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)

Plugins (game-specific): None atm



If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Aug 02, 2013 6:29 am

Fixed as of the latest revision! Thanks for reporting and solving! :D

http://code.google.com/p/source-python/source/detail?r=631110465f107c65f21b71cf41e049fdf577b59d
Predz
Senior Member
Posts: 158
Joined: Wed Aug 08, 2012 9:05 pm
Location: Bristol, United Kingdom

Postby Predz » Fri Aug 02, 2013 9:42 am

Thx, I will have a test when I get back off holiday :)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 37 guests