• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Accessing player's SteamID from script

rallfo

Grizzled Veteran
Jun 12, 2009
194
1
www.rallfo.com
(1) Is there any way of retrieving a player's SteamID within script in the same way PlayerController.GetPlayerIDHash() returns the mysterious player global ID?

(2) Or is there a built in way of exporting live player name / steamID tuples out of a running server for passing to a secondary process?

Server log files are full of lines in the form "Log: STEAMAUTH : Accepted Client : SteamID [X:XXXXXXXX] (XXXXXXXXXXXXXXXXX)" so obviously the engine has access to this data to potentially provide (1), and further (2) could be achieved by a clunky program actually parsing the log files for these lines but that's obviously less desirable than a proper method of accessing this data...

Having (1) would open the door to all sorts of useful access control plugins including banning by steam ID and using existing public ban lists of notorious griefers/cheaters (I have my own from a tf2 server for example), plugins that provide custom integration with steam (e.g. showing real avatars in game) and other interesting ideas.

So if that data is not currently available to scripters could it be made available in the next patch? The steamid is obviously stored in memory so exporting it as a native function to unrealscript should be trivial. Furthermore source engine games already make steamids freely available to scripters without encountering any security issues etc.

And (2) would allow interesting mashups with steamcommunity.com and server websites for stats tracking and the like.

Thanks!
 
Last edited:
Assuming KF works similar to RO (which is very likely), i assume you run a windows server. Linux servers return the SteamID when calling the function.
To get the ID on windows server you have to substract a constant. Dont have it here, just compare your steamID and the number you get from the function.

Again, only from my experience with RO :)
 
Upvote 0
Firstly thanks very much for that pointer worluk, I had no idea that the PlayerIDHash was in some way related to the steamid, I'd assumed it was some arbitrarily assigned ID given out by tripwire's servers.

So I'm posting the following that answers my own question, though this may be old hat to you scripting gurus. ^_^

On closer inspection it appears that to get the information you want out of this value you don't so much have to subtract some arbitrary number as pay attention to its binary representation.

Source server admins are used to seeing steamIDs in the form:
Code:
STEAM_0:ServerID:AuthID
where ServerID is a 1bit number denoting which of two steam authentication clusters the ID resides on and AuthID is the main steam id (63bit). And yes that first digit always appears to be 0 for PC users as far as I know*

The number retrieved from GetPlayerIDHash(), the global ID displayed in the web admin interface and referenced elsewhere in game is in fact a 64bit packed representation of this (Little-Endian).

That is if BinaryRepresentation is the binary representation of such a number then:
Code:
BinaryRepresentation[LSB]=ServerID
BinaryRepresentation[..LSB)=AuthID
So that's how to properly go about translating these values to and from the standard form.

Further verifying that this how the information is packed is that the following works:

Obtaining a steam community ID from such a number can be done in one operation (that is the number used on steamcommunity.com and the invitation system):
Code:
SteamCommunityID = GetPlayerIDHash() + MagicNumber
where MagicNumber = 76561197960265728
And http://www.steamcommunity.com/profiles/SteamCommunityID will yield the profile of the given player.

Doing this translation on the STEAM_0:ServerID:AuthID form requires a conditional on the ServerID value as well as format parsing so this packed 64bit representation is actually a more elegant and efficient representation.

Addendum: I'm not sure whether MagicNumber actually is a magic number or adding it actually effects some other operation at a binary level (possibly two's complement and something else) but if there is such an operation then they are isomorphic.

* If this assumption turns out to be false it is likely that this number will be in the MSBs of the packed representation.
 
Last edited:
Upvote 0