PDA

View Full Version : [EXTENSION] CSteamID - SteamIDs as 64bit integers


bl4nk
02-19-2009, 13:22
CSteamID
v1.0.1

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

Natives:
/**
* 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(client, String: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.

For example, my SteamID is STEAM_0:0:15922928.
As a 64bit integer, it's 76561197992111584.
http://steamcommunity.com/profiles/76561197992111584


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/showthread.php?p=1800652#post1800652

bl4nk
02-19-2009, 15:45
Updated to version 1.0.1

DontWannaName
02-19-2009, 17:54
Doesnt it need a plugin to actually call the conversion? Like cbaseservertest to call the extension?

bl4nk
02-19-2009, 18:16
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
can u make it for L4D?
or for all Source engine?

bl4nk
04-13-2009, 15:11
Nope, it will only work for OB mods.

bl4nk
04-14-2009, 00:13
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
I hope this will be integrated into default sourcemod API. Looks very useful for the unification of identation.

Powerlord
04-18-2010, 03:34
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
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.

Afronanny
04-18-2010, 18:31
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.


//-----------------------------------------------------------------------------
// Purpose: Converts steam ID to its 64-bit representation
// Output : 64-bit representation of a Steam ID
//-----------------------------------------------------------------------------
uint64 ConvertToUint64() const
{
return (uint64) ( ( ( (uint64) m_EUniverse ) << 56 ) + ( ( (uint64) m_EAccountType ) << 52 ) +
( ( (uint64) m_unAccountInstance ) << 32 ) + m_unAccountID );
}

The answer is in steamclientpublic.h

berni
06-01-2010, 06:28
Any progress on this ? I need it for the ep1 engine.

voogru
06-01-2010, 10:10
Any progress on this ? I need it for the ep1 engine.

http://forums.alliedmods.net/showthread.php?t=60899

That's the best you'll get because EP1 engine doesn't have the GetClientSteamID()

berni
06-01-2010, 16:10
http://forums.alliedmods.net/showthread.php?t=60899

That's the best you'll get because EP1 engine doesn't have the GetClientSteamID()

I know that thread Voogru, but I only found a one way implementation for sourcemod but I want to do it 2 ways, and using 32bit integers for calculation is a bit dirty, isn't it ?

And bl4nk stated he is going to make this work for all other mods also...
you can ge the SteamID for every engine.

egor1908
06-01-2010, 17:17
I'm not blaming your work, i think it's great, but whan can this be used for? For gaining faster acces for someone's ID page?

asherkin
06-01-2010, 21:04
It's more reliable, i.e. a CSteamID won't break with trivial changes to the display format used (STEAM_1 instead of STEAM_0 for example).

voogru
06-02-2010, 12:33
It's more reliable, i.e. a CSteamID won't break with trivial changes to the display format used (STEAM_1 instead of STEAM_0 for example).

I think it's a matter of time before the STEAM_ mask goes away completely. It probably won't be until the next iteration of their engine though which they are probably secretly working on.

So using the 64 bit numbers may not be useful for the plug-ins (because a new engine will by default, break all of the plug-ins), but for stuff that resides in MySQL databases and on websites it will make that stuff immune to the changes.

egor1908
06-04-2010, 07:15
It's more reliable, i.e. a CSteamID won't break with trivial changes to the display format used (STEAM_1 instead of STEAM_0 for example).Isnt the first number depending on if you are online or not? That's what i have observed.

voogru
06-04-2010, 11:35
Isnt the first number depending on if you are online or not? That's what i have observed.

no.

pheadxdll
06-11-2010, 23:42
Just click one more time to download here (http://forums.alliedmods.net/showpost.php?p=1800652&postcount=31).

Munra
10-31-2010, 20:33
I noticed that when loading or refreshing plugins that use this extention the server crashes

TF2 Windows server

I was using this plugin http://forums.alliedmods.net/showthread.php?t=141963

pheadxdll
11-01-2010, 21:05
I don't have any problems with this extension. I use it on a TF2 windows server too, what's your SM version, any errors?

yousif666
11-05-2010, 06:47
where do i have to put the .inc file ??

and thanks :)

berni
11-05-2010, 14:54
.inc -> scripting/include/

yousif666
11-06-2010, 06:03
Thanks

cameltoe Joe
11-21-2010, 09:37
Hi I am looking for installation instructions to add this to my trading server but am unable to find any could you please advise?

pheadxdll
11-21-2010, 10:34
Certainly camel, just put the .dll and the .so in the sourcemod/extensions folder and your done.

cameltoe Joe
11-23-2010, 06:01
Certainly camel, just put the .dll and the .so in the sourcemod/extensions folder and your done.

Thankyou very much, Fantastic works a treat

Squallkins
08-24-2012, 22:57
This needs an update. Doesn't work after the recent update.

Cheers

pheadxdll
08-25-2012, 18:43
I compiled these against SM 1.4 and MM 1.8. Attached are the ep2v binaries that work with TF2/GMOD/CSS/DOD. Tested and works on windows, hopefully this fixes this for you.

pheadxdll
09-16-2012, 11:18
Somebody requested CSGO support so here it is, along with all the updated source files. Only tested the windows ep2v binary but they should all work.

Supported games: TF2/GMod/DOD/CSGO/CSS

SaberUK
10-27-2012, 10:45
To anyone who is having problems with this extension after the Scream Fortress update it can be fixed by symlinking libtier0.so and libvstdlib.so to their new _srv equivalents.


cd orangebox/bin
ln -s libtier0_srv.so libtier0.so
ln -s libvstdlib_srv.so libvstdlib.so

naris
10-27-2012, 13:56
To anyone who is having problems with this extension after the Scream Fortress update it can be fixed by symlinking libtier0.so and libvstdlib.so to their new _srv equivalents.


cd orangebox/bin
ln -s libtier0.so libtier0_srv.so
ln -s libvstdlib.so libvstdlib_srv.so


You have the ln commands backwards, it should be:


cd orangebox/bin
ln -s libtier0_srv.so libtier0.so
ln -s libvstdlib_srv.so libvstdlib.so

pheadxdll
10-27-2012, 14:17
That will work, but I've updated the ep2v.so binary in this (https://forums.alliedmods.net/showpost.php?p=1800652&postcount=31) post.

dddshroom
07-10-2015, 15:17
Is this extension still being updated? If not, what is the best up to date alternative?

I'm getting:

[10] <FAILED> file "csteamid.ext.2.csgo.so": /home/servonet/csgo_gungame/steamcmd/games/csgo/csgo/addons/sourcemod/extensions/csteamid.ext.2.csgo.so: undefined symbol: __dynamic_cast

Thanks for any information you can provide.

versatile_bfg
07-12-2015, 09:18
Is this extension still being updated? If not, what is the best up to date alternative?

I'm getting:

[10] <FAILED> file "csteamid.ext.2.csgo.so": /home/servonet/csgo_gungame/steamcmd/games/csgo/csgo/addons/sourcemod/extensions/csteamid.ext.2.csgo.so: undefined symbol: __dynamic_cast

Thanks for any information you can provide.

https://sm.alliedmods.net/new-api/clients/GetClientAuthId
bool GetClientAuthId(int client, AuthIdType (https://sm.alliedmods.net/new-api/clients/AuthIdType) authType, char[] auth, int maxlen, bool validate)eg: GetClientAuthId(client, AuthId_SteamID64, authid, sizeof(authid));
This does do it as a string though.
AuthId_SteamID64 = "A SteamID64 (uint64) as a String, ex "76561197968573709""
https://sm.alliedmods.net/new-api/clients/AuthIdType