Best way to retrieve steamid / gametag?

Please post any questions about developing your plugin here. Please use the search function before posting!
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Best way to retrieve steamid / gametag?

Postby Tuck » Sat Aug 18, 2012 7:16 am

whats the fastest way to retrieve steamid from userid? and retrieve players gametag from steamid/userid ?


currently i would retrieve it this way;

Syntax: Select all

from Source import Player

for player in Player.Players():
if player.GetUserID() == userid:
steam_id = player.GetNetworkIDString()
tag = player.GetName()
-Tuck
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sat Aug 18, 2012 7:42 am

Well if you had the player instance already you could use IVEngineServer.GetPlayerNetworkIDString()
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sat Aug 18, 2012 7:48 am

so looping true all the IPlayerInfo are the fastest way possible if only information i have is userid? :)
-Tuck
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sat Aug 18, 2012 8:06 am

I believe so.. We may later add library methods that do the looping for you, but all that will provide is a little less work on your end.

Satoon has been messing with the player stuff much more than I have, so maybe he will chime in.
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sat Aug 18, 2012 8:26 am

Monday wrote:I believe so.. We may later add library methods that do the looping for you, but all that will provide is a little less work on your end.

Satoon has been messing with the player stuff much more than I have, so maybe he will chime in.


well looping is fine though, maybe it's just me but wouldnt a api that stores the IPlayerInfo in a dict where each key is a userid be even faster than having to loop? :)
-Tuck
User avatar
Monday
Administrator
Posts: 98
Joined: Thu Jul 12, 2012 4:15 am

Postby Monday » Sat Aug 18, 2012 8:27 am

I'm not sure about this... but I think this would work:

Syntax: Select all

myPlayer = Player.PlayerOfUserid(userid)
steamid = myPlayer.GetNetworkIDString()
tag = myPlayer.GetName()


Try it out?

Tuck wrote:well looping is fine though, maybe it's just me but wouldnt a api that stores the IPlayerInfo in a dict where each key is a userid be even faster than having to loop? :)


Not really.. the problem with that is it will slow down the plugin itself, because it has to do all that work regardless if you use the functionality or not.
Tuck
Global Moderator
Posts: 205
Joined: Sat Jul 14, 2012 9:35 pm
Location: Copenhagen

Postby Tuck » Sat Aug 18, 2012 8:29 am

Monday wrote:I'm not sure about this... but I think this would work:

Syntax: Select all

myPlayer = Player.PlayerOfUserid(userid)
steamid = myPlayer.GetNetworkIDString()
tag = myPlayer.GetName()


Try it out?


Oh damn i feel stupid the PlayerOfUserid method (think i read about it yesterday) forgot all about that xD

Thanks a bunch :) was just what i was looking for :)
-Tuck
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sat Aug 18, 2012 8:57 am

Tuck wrote:Oh damn i feel stupid the PlayerOfUserid method (think i read about it yesterday) forgot all about that xD

Thanks a bunch :) was just what i was looking for :)


Don't feel stupid^^ feel..... surprised that this works ;)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 33 guests