AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Retrive a last numbers after ':' from SteamID (https://forums.alliedmods.net/showthread.php?t=215524)

^SmileY 05-08-2013 18:48

Retrive a last numbers after ':' from SteamID
 
Hey, i need a some help to separate the numbers of SteamID;

example:

PHP Code:

new szSteam[35];
get_user_authid(id,szSteam,charsmax(szSteam));  // Its will return my Steam: STEAM_0:1:20326844

new szLeft[16],szRight[16];
    
strtok(szSteam,szLeft,charsmax(szLeft),szRight,charsmax(szRight),':');

server_print(szRight); // Its will return ":20326844" 

Any suggestion?

Ps. I used search but not really a useful results

EDIT:

I used this method and problem solved:

PHP Code:

    new szLeft[16],szRight[16];
    
strtok(szSteam,szLeft,charsmax(szLeft),szRight,charsmax(szRight),':');
    
strtok(szRight,szLeft,charsmax(szLeft),szRight,charsmax(szRight),':');
    
    
server_print(szRight); 

But its another better way?

.Dare Devil. 05-08-2013 19:55

Re: Retrive a last numbers after ':' from SteamID
 
PHP Code:

static ascount,numbers[16], posscount 0pos 0
for(0charsmax(szSteam); a++)
{
if(!
szSteam[a]) {
numbers[pos] = 0
break
}
if(
scount >= && szSteam[a] != ':' ) {
numbers[pos] = szSteam[a]
pos++
continue
}
if( 
szSteam[a] == ':' scount++



ConnorMcLeod 05-08-2013 19:58

Re: Retrive a last numbers after ':' from SteamID
 
This ?

PHP Code:

{
    new 
szAuthid[32];
    
get_user_authid(idszAuthidcharsmax(szAuthid));
    
szAuthid[9] = EOS;
    
server_print("Left:%s , Right:%s"szAuthidszAuthid[10]);



You always have weird question. You would have better to tell what you want to do with the steamid.
I remember having trouvle with ':' and replace simply with '_' like this :

szAuthid[7] = szAuthid[9] = '_';

And to reverse, so simple :

szAuthid[7] = szAuthid[9] = ':';

^SmileY 05-08-2013 20:41

Re: Retrive a last numbers after ':' from SteamID
 
But its still fix a SteamID for one size not?
Its example my SteamID, but i need basically to retrive the last numbers, to use with a unique set_task()

ConnorMcLeod 05-09-2013 06:15

Re: Retrive a last numbers after ':' from SteamID
 
Then, ask in first post that you want to use that number and not the string, prevent people from spend some time for nothing.

PHP Code:

new g_szAuthid[33][32];
new 
g_iPlayersAUTH[33];

public 
client_authorizedid )
{
    
get_user_authid(idg_szAuthid[id], charsmax(g_szAuthid[]));
    
g_iPlayersAUTH[id] = str_to_numg_szAuthid[10] );



hornet 05-09-2013 07:39

Re: Retrive a last numbers after ':' from SteamID
 
Quote:

Originally Posted by ConnorMcLeod (Post 1948642)
Then, ask in first post that you want to use that number and not the string, prevent people from spend some time for nothing.

Yet another statistic to the currently increasing XY Problem.


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

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