AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION] CSteamID - SteamIDs as 64bit integers (https://forums.alliedmods.net/showthread.php?t=86019)

bl4nk 02-19-2009 13:22

[EXTENSION] CSteamID - SteamIDs as 64bit integers
 
CSteamID
v1.0.1

Description:
Provides some native functions for converting to and from SteamIDs stored as 64-bit integers.

Natives:
PHP Code:

/**
 * Gives the 64-bit int SteamID for a client
 *
 * @param client        Client index of the player.
 * @param buffer        Destination string buffer.
 * @param maxlength     Maximum length of output string buffer.
 * @return              True on success, false on invalid client index or failure to find edict index.
 */
native bool:GetClientCSteamID(clientString:buffer[], maxlength);

/**
 * Given a 64-bit int SteamID, gives the SteamID associated with it
 *
 * @param input         64-bit integer stored in a string
 * @param buffer        Destination string buffer for the SteamID.
 * @param maxlength     Maximum length of the output string buffer.
 * @return              True on success, false on invalid input string.
 */
native bool:CSteamIDToSteamID(String:input[], String:buffer[], maxlength);

/**
 * Given a SteamID, gives the 64-bit int SteamID associated with it
 *
 * @param input         SteamID stored in a string
 * @param buffer        Destination string buffer for the 64-bit int SteamID.
 * @param maxlength     Maximum length of the output string buffer.
 * @return              True on success, false on invalid SteamID.
 */
native bool:SteamIDToCSteamID(String:input[], String:buffer[], maxlength); 

Notes:
  • I call the 64bit int representation of a SteamID a CSteamID. Anywhere you see CSteamID, you can know that it's the 64bit int version.
  • A 64bit int SteamID is the same as a Steam Community friend ID.
  • As long as Valve keeps the functions used in this extension in their code, the 64bit int SteamIDs will outlast any changes done to normal SteamIDs (for example how they just changed from STEAM_0 to STEAM_1 and then back again).
  • GetClientCSteamID can be called before a player authorizes to the server. This means that during OnClientConnect you can grab their CSTeamID, and then convert that to their SteamID, and essentially get it before you normally could without this extension.
  • This extension will only work for OB mods. I tested on TF2, but it should work fine on DOD:S and any other OB mod.
Thanks to:
  • voogru - He's the inspiration behind this extension, and helped a ton during the process. Thanks for putting up with my bullshit the whole time. :]
  • Nephyrin - Some small help with casting types and such.
  • Valve - For screwing us over too many times to count.
Changelog:
  • 1.0.1
    • Added a check to see if steamID is NULL.
Download:
http://forums.alliedmods.net/showthr...52#post1800652

bl4nk 02-19-2009 15:45

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
Updated to version 1.0.1

DontWannaName 02-19-2009 17:54

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
Doesnt it need a plugin to actually call the conversion? Like cbaseservertest to call the extension?

bl4nk 02-19-2009 18:16

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
I'm just providing the natives for people to use in their plugins, how they use these functions is up to them.

koshmel 04-13-2009 13:38

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
can u make it for L4D?
or for all Source engine?

bl4nk 04-13-2009 15:11

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
Nope, it will only work for OB mods.

bl4nk 04-14-2009 00:13

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
Now that I think about it, I can make it so that this will work on any other mod. The only downside is that the "GetClientCSteamID" native won't work. You'll still be able to use the other two functions just fine though.

exvel 04-18-2009 16:08

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
I hope this will be integrated into default sourcemod API. Looks very useful for the unification of identation.

Powerlord 04-18-2010 03:34

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
Note: I haven't tried this code, I was just examining the sourcecode.

Maybe I'm missing something, but the source code for one of the conversions seems to be off.

More specifically, in SteamIDToCSteamID you add 76561197960265728 to the number in the Steam ID to get a steamcommunity ID.

However, CSteamIDToSteamID does not subtract this number from the steamcommunity ID you pass in before being displayed.

asherkin 04-18-2010 03:53

Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
 
That's because SteamIDToCSteamID is a hackish conversion, but is easier on the processing than that proper method. CSteamIDToSteamID does it properly. It's a bit more complex than this, but you can't understand it without understanding the CSteamID class and how they work, the page on the VDC is largely incorrect in how SteamIDs function.


All times are GMT -4. The time now is 10:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.