AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get ID by STEAMID (https://forums.alliedmods.net/showthread.php?t=22575)

Sandurr 12-30-2005 12:55

Get ID by STEAMID
 
Hi,

Is it possible to get a players ID when having his STEAMID?

Ty

XxAvalanchexX 12-30-2005 15:09

Code:
stock get_user_id(const authid[]) {     new players[32], num, i;     get_players(players, num, "c");     for(i=0;i<num;i++) {         new check[32];         get_user_authid(players[i],check,31);         if(equali(authid,check)) return players[i];     }     return 0;  }

PM 12-30-2005 15:25

Note that it'd be better to declare the "check" variable outside of the for loop. When the compiler sees the declaration of a variable it reserves space on the stack and then sets the bytes to zero. So it's better to do it once instead of doing it each iteration.

XxAvalanchexX 12-30-2005 15:32

Last time I tried that I had problems. I declared a variable outside a while loop, and inside the while loop I would assign it a value. The value always returned blank. When I made the variable declaration inside of the while loop, it worked fine. I thought it was a weird scope issue.

PM 12-30-2005 15:39

Yes, it would be helpful if you could post the code, maybe some non-lazy developer would look into it. (actually, we are all lazy, so don't)

Twilight Suzuka 12-30-2005 16:09

Isn't the lost processing speed negligable?

And I consider myself non-lazy...to an extent...

PM 12-30-2005 16:20

In this case, it most likely is, but there are people who like to point out any possible reasonable optimisation they see, mainly because they want to give good advice in case someone would like to implement a similar loop on a larger scale.

Why waste processor cycles anyway? :)

Twilight Suzuka 12-30-2005 16:32

Cause it looks infinitely better? ^^


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

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