Raised This Month: $12 Target: $400
 3% 

[EXTENSION] CSteamID - SteamIDs as 64bit integers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-19-2009 , 13:22   [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #1

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

Last edited by bl4nk; 09-16-2012 at 21:30.
bl4nk is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-19-2009 , 15:45   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #2

Updated to version 1.0.1
bl4nk is offline
DontWannaName
Veteran Member
Join Date: Jun 2007
Location: VALVe Land, WA
Old 02-19-2009 , 17:54   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #3

Doesnt it need a plugin to actually call the conversion? Like cbaseservertest to call the extension?
__________________

DontWannaName is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-19-2009 , 18:16   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #4

I'm just providing the natives for people to use in their plugins, how they use these functions is up to them.
bl4nk is offline
koshmel
Member
Join Date: Nov 2008
Old 04-13-2009 , 13:38   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #5

can u make it for L4D?
or for all Source engine?
koshmel is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-13-2009 , 15:11   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #6

Nope, it will only work for OB mods.
bl4nk is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-14-2009 , 00:13   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #7

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.
bl4nk is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-18-2009 , 16:08   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #8

I hope this will be integrated into default sourcemod API. Looks very useful for the unification of identation.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-18-2010 , 03:34   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #9

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.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 04-18-2010 , 03:53   Re: [EXTENSION] CSteamID - SteamIDs as 64bit integers
Reply With Quote #10

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.
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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