Edit: Git -> https://github.com/Source-Python-Dev-Team/Source.Python/issues/3
Sometimes you can create objects of classes when you shouldn't be able to do because they are warpped, thus crashing the server when you call member functions.
Examples:
player_connect
-> IPlayerInfo does not work so early on (NULL afaik), but you can create an instance of CPlayerInfo, and once you call any member function the server crashes
CNetChannelInfo
-> INetChannelInfo returns NULL for bots, so if you use it on bots, server will crash
So in general this should be handled in the constructors properly, so we rather get a None value in python (like it was before the rewrite) instead of a server crash :P
General Issue with some wraps
General Issue with some wraps
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
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
I seem to be hitting this issue also. I am trying to get a player's steam id on connect.
userid = game_event.get_int('userid')
print("userid: %s" % userid)
playerinfo = playerinfo_from_userid(userid)
print("playerinfo: %s" % playerinfo)
steamid = playerinfo.get_networkid_string()
print("player steamid: %s" % steamid)
Sometimes this causes a segmentation fault, sometimes it works.
Omega, would you be able to give an example of what you mean by: "this should be handled in the constructors properly". Is this something I am doing wrong on the plugin side?
userid = game_event.get_int('userid')
print("userid: %s" % userid)
playerinfo = playerinfo_from_userid(userid)
print("playerinfo: %s" % playerinfo)
steamid = playerinfo.get_networkid_string()
print("player steamid: %s" % steamid)
Sometimes this causes a segmentation fault, sometimes it works.
Omega, would you be able to give an example of what you mean by: "this should be handled in the constructors properly". Is this something I am doing wrong on the plugin side?
edcolmar wrote:I seem to be hitting this issue also. I am trying to get a player's steam id on connect.
userid = game_event.get_int('userid')
print("userid: %s" % userid)
playerinfo = playerinfo_from_userid(userid)
print("playerinfo: %s" % playerinfo)
steamid = playerinfo.get_networkid_string()
print("player steamid: %s" % steamid)
Sometimes this causes a segmentation fault, sometimes it works.
Omega, would you be able to give an example of what you mean by: "this should be handled in the constructors properly". Is this something I am doing wrong on the plugin side?
I meant in c++/abstraction. I.e. they could be using a static factory function that simply returns null instead of the object with null points, that would resolve the problem (as null would be None)
I think checking for playerinfo with get_edict() and then is_valid() will work as a workaround.
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
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
Is this close?
@Event
def player_connect(game_event):
print("Player Connect")
userid = game_event.get_int('userid')
print("userid: %s" % userid)
edict = edict_from_userid(userid)
playerinfo = edict.get_prop('playerinfo')
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/events/listener.py', line 82, in fire_game_event
callback(game_event)
File '../addons/source-python/plugins/leetcoin/leetcoin.py', line 464, in player_connect
playerinfo = edict.get_prop('playerinfo')
AttributeError: 'CEdict' object has no attribute 'get_prop'
@Event
def player_connect(game_event):
print("Player Connect")
userid = game_event.get_int('userid')
print("userid: %s" % userid)
edict = edict_from_userid(userid)
playerinfo = edict.get_prop('playerinfo')
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/events/listener.py', line 82, in fire_game_event
callback(game_event)
File '../addons/source-python/plugins/leetcoin/leetcoin.py', line 464, in player_connect
playerinfo = edict.get_prop('playerinfo')
AttributeError: 'CEdict' object has no attribute 'get_prop'
We changed the format to get SendProp values from:to:We just have not updated the Wiki to show those changes.
Also, playerinfo is not a SendProp name. You can get a player's CPlayerInfo instance by instantiating it using the player's userid or CEdict instance:
Satoon
Code: Select all
<CEdict>.get_prop('<prop name>').get_<type>()
Code: Select all
<CEdict>.get_prop_<type>('<prop name>')
Also, playerinfo is not a SendProp name. You can get a player's CPlayerInfo instance by instantiating it using the player's userid or CEdict instance:
Code: Select all
playerinfo = CPlayerInfo(<userid>)
# or
playerinfo = CPlayerInfo(<CEdict>)
Satoon
edcolmar wrote:Thanks for the reply, but I don't quite follow. Could you paste an example?
Code: Select all
playerinfo = playerinfo_from_userid(userid)
# Avoid crash due to null pointer
if not playerinfo.get_edict().is_valid():
return
Though as I said this is also an issue with SP, currently you can't check whether the playerinfo instance is valid, only the entity pointer. You'll have to avoid using it in cases where it is invalid.
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
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
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 91 guests