First off I think I can use get_player_info
to get the player_info_s/player_info_t structure
Does Source Python define or provide helpers for this structure anywhere? If not how do I go about creating this in my plugin?
It's been a while I've messed with the Source Engine, but this piqued my interest. I would like access to the struct itself, but I'm in particular looking to access the CustomFiles array.
I also looked around in IDA and the SDK for a disclosed function that accesses this array, to maybe just find an offset but I couldn't find anything with source available in a server binary. (I looked at the alliedmodders Source SDK, the Valve Source 2013 SDK and the old VSES repo)
Thanks!
Using engine server's get_player_info
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Using engine server's get_player_info
We could probably export that type (feel free to PR it, or create an issue as feature request) but here is an untested example showing how you could call and read it:
Offsets are based on the link you provided, which are likely to be outdated and/or different for each games though. Alternatively, you could use a CustomType to make it easier as well.
EDIT: Updated the offsets, tested on CS:S and they appears correct for that game.
Syntax: Select all
from engines.server import engine_server
from memory import alloc
from memory import get_virtual_function
from memory.helpers import Array
from memory.manager import manager
# Get the GetPlayerInfo function
get_player_info = get_virtual_function(engine_server, 'GetPlayerInfo')
# Allocate space to store the info
info = alloc(132)
# Call the function
get_player_info(engine_server, <index>, info)
# Read some data
name = info.get_string_array()
userID = info.get_int(32)
guid = info.get_string_array(36)
friendsID = info.get_uint(72)
friendsName = info.get_string_array(76)
_ = info.get_bool(108)
customFiles = Array(manager, False, 'uint', info + 112, 4)
filesDownloaded = info.get_uchar(128)
Offsets are based on the link you provided, which are likely to be outdated and/or different for each games though. Alternatively, you could use a CustomType to make it easier as well.
EDIT: Updated the offsets, tested on CS:S and they appears correct for that game.
Re: Using engine server's get_player_info
Thanks for the quick reply!
I did find that for CS:S the offsets are wrong, I'm pretty sure either fakeplayer or ishltv got removed.
I verified and customFiles has an offset of 112 (length is 4 instead of 16 too, I'm pretty sure it's 4*4 = 16)
That should bring it to
And this will convert an int in the customFiles array to an usable crc32
I did find that for CS:S the offsets are wrong, I'm pretty sure either fakeplayer or ishltv got removed.
I verified and customFiles has an offset of 112 (length is 4 instead of 16 too, I'm pretty sure it's 4*4 = 16)
That should bring it to
Syntax: Select all
from engines.server import engine_server
from memory import alloc
from memory import get_virtual_function
from memory.helpers import Array
from memory.manager import manager
# Get the GetPlayerInfo function
get_player_info = get_virtual_function(engine_server, 'GetPlayerInfo')
# Allocate space to store the info
info = alloc(132)
# Call the function
get_player_info(engine_server, <index>, info)
# Read some data
name = info.get_string_array()
userID = info.get_int(32)
guid = info.get_string_array(36)
friendsID = info.get_uint(72)
friendsName = info.get_string_array(76)
_ = info.get_bool(108)
customFiles = Array(manager, False, 'uint', info + 112, 4)
filesDownloaded = info.get_uchar(128)
And this will convert an int in the customFiles array to an usable crc32
Syntax: Select all
import struct
def crc32_from_uint(i):
return hex(struct.unpack("<I", struct.pack(">I", i))[0])[2:]
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: Using engine server's get_player_info
Doldol wrote:I did find that for CS:S the offsets are wrong, I'm pretty sure either fakeplayer or ishltv got removed.
It's probably the opposite; wasn't added at the time that game was released. I believe it is ishltv that is missing, because 108 was True for regular bots and False for me when I tested yesterday.
Doldol wrote:I verified and customFiles has an offset of 112 (length is 4 instead of 16 too, I'm pretty sure it's 4*4 = 16)
Yes, that's right! That's the length of the array, not its memory size.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 3 guests