samsface / godot-steam-api

Godot Steam integration using GDNative.
403 stars 16 forks source link

[question] How to get user id? #22

Closed AndrejsKlavins closed 2 years ago

AndrejsKlavins commented 2 years ago

Hello, I have a super simple question that got me stumped. How can I get steam user id with this integration? I can successfully get everything working in general. The Steam established connection and returns for example user name.

I can ask it for get_steam_id with Steam.user.get_steam_id() But I have no idea how to extract the id int from the returned value.

Or am I doing it completely wrong?

samsface commented 2 years ago

@AndrejsKlavins Did you try var steam_id:int = Steam.user.get_steam_id().get_account_id()?

AndrejsKlavins commented 2 years ago

Hey thanks for the prompt answer!

Just tried it. It does output some kind of id, but I do not think its my steam user id.

image

Curiously when initializing the Steam API, it already outputs my steam user id (number 1). I just don't know how to access it. Here it matches my users steam profile page: https://steamcommunity.com/profiles/76561197992131603/

Steam.user.get_steam_id().get_account_id() outputs number 2 in the picture, which I am not sure what kind of id is.

samsface commented 2 years ago

@AndrejsKlavins Ah that's the community_id. So the steam api doesn't actually provide a function to get this. But you can work it out by bitshifting around the account id. I'll add a helper function to do this for you.

samsface commented 2 years ago

@AndrejsKlavins Added this new function: https://github.com/samsface/godot-steam-api/commit/0fa9c9a79c361f458bd071003717a1e1daaaa75d#diff-a98efc4eec90775eead1adcd034e30a15c4c1b145e7c0856a590b2eaa9f835a8R8

Can you test it works so I can close this issue?

AndrejsKlavins commented 2 years ago

@samsface

Thanks you tested it and everything works correctly!

samsface commented 2 years ago

@AndrejsKlavins awesome thanks for testing man.