AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Get steamid number (https://forums.alliedmods.net/showthread.php?t=163706)

Touch 08-02-2011 12:37

Get steamid number
 
Hello
Please tell us as soon as possible from STEAM_0:0:29367947 to 0:29367947.
That is, cut STEAM_0:.
PHP Code:

decl String:steamid[256];
GetClientAuthString(clientsteamidsizeof(steamid));

# We need a variable that will contain only steamid number (without "STEAM_0:") 

Very thanks!

pheadxdll 08-02-2011 12:41

Re: Get steamid number
 
PHP Code:

decl String:steamid[256]; 
GetClientAuthString(clientsteamidsizeof(steamid)); 

PrintToChatAll("%s"steamid[8]); // Will print: "0:29367947" in your case 

That will get a reference of the string from the 9th character. You could transpose it back onto the string with strcopy but there's really no need.

ajr1234 08-03-2011 03:32

Re: Get steamid number
 
I have a stock that may help you:
PHP Code:

stock GetSteamID(clientString:authstr[], maxlen)
{
    
GetClientAuthString(clientauthstrmaxlen);
    if(
StrEqual(authstr"STEAM_ID_LAN"false))
    
GetClientIP(clientauthstrmaxlen);
    
ReplaceString(authstrmaxlen"STEAM_0:"""false);
    
ReplaceString(authstrmaxlen"STEAM_1:"""false);


Use it like this:
PHP Code:

decl String:buffer[256];
GetSteamID(clientbuffersizeof(buffer));
// buffer now holds the steam ID 


berni 08-03-2011 15:46

Re: Get steamid number
 
Quote:

Originally Posted by ajr1234 (Post 1524676)
I have a stock that may help you:
PHP Code:

stock GetSteamID(clientString:authstr[], maxlen)
{
    
GetClientAuthString(clientauthstrmaxlen);
    if(
StrEqual(authstr"STEAM_ID_LAN"false))
    
GetClientIP(clientauthstrmaxlen);
    
ReplaceString(authstrmaxlen"STEAM_0:"""false);
    
ReplaceString(authstrmaxlen"STEAM_1:"""false);


Use it like this:
PHP Code:

decl String:buffer[256];
GetSteamID(clientbuffersizeof(buffer));
// buffer now holds the steam ID 


don't use this.

ajr1234 08-03-2011 23:34

Re: Get steamid number
 
Quote:

Originally Posted by berni (Post 1525111)
don't use this.

Someone told me the same thing once before. May I ask what's wrong with it?

Bacardi 08-04-2011 11:19

Re: Get steamid number
 
Quote:

Originally Posted by ajr1234 (Post 1525326)
Someone told me the same thing once before. May I ask what's wrong with it?

Complicated do simple thing,
What @pheadxdll post #2 you can not get simpler than it is.

sry bad english

Master53 08-05-2011 14:22

Re: Get steamid number
 
Well, you could convert the number into a useable Intiger ID. This is what i use.

PHP Code:

//Covert To String:
SteamIdToInt(ClientnBase 10)
{
    
decl String:SteamId[64], String:subinfo[3][16];
    
GetClientAuthString(ClientSteamIdsizeof(SteamId));
    
ExplodeString(SteamId":"subinfosizeof(subinfo), sizeof(subinfo[]));
    new 
Int StringToInt(subinfo[2], nBase);
    if(
StrEqual(subinfo[1], "1")) Int *= -1;
    return 
Int;


Credits go to Sammy Rocks. And me for some ajustments.

berni 08-05-2011 14:26

Re: Get steamid number
 
PHP Code:

//Initulize

//Declare:
decl

//Explode:
Explode

//Return:
return 

lol, silly comment author ?

This sucks too, doesn't have any advantages over pheadxdll's example.
I would prefer the long 64 Bit Friends ID then.

Master53 08-05-2011 15:10

Re: Get steamid number
 
Edited and is now better. I normally use a intiger based steam id when using SQL because it speeds up SQL and less data is transfered although it does the same thing.


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

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