philippj / SteamworksPy

A working Python API system for Valve's Steamworks.
MIT License
212 stars 39 forks source link

GetFriendCount and GetFriendFromSourceByIndex methods #16

Closed labanau closed 4 years ago

labanau commented 5 years ago

I am hoping I can use these two functions to get the steam ID of players from my server with server steam id, but I can't find any of these two functions, are they implemented and how should you use them?

Gramps commented 5 years ago

Hey there. I do not believe those functions are enabled yet. I have slowly been working on getting the Python framework close to where the Godot Engine module is for a while now. The Python framework has a few weird quirks comparatively. I am basically rewriting it from scratch in what spare time I have.

That being said, I will push those functions to the top of my list for my next updste; it's been quite a while since the last one!

labanau commented 5 years ago

Hey there. I do not believe those functions are enabled yet. I have slowly been working on getting the Python framework close to where the Godot Engine module is for a while now. The Python framework has a few weird quirks comparatively. I am basically rewriting it from scratch in what spare time I have.

That being said, I will push those functions to the top of my list for my next updste; it's been quite a while since the last one!

Hey, Gramps! Thanks for the quick response, here and on the other issue, I will be following and waiting for the update!

Gramps commented 5 years ago

Yeah, the Python framework needs some love! And some is coming!

labanau commented 5 years ago

Hey, just a quick question, I have this code: ` from steamworks import *

Steam.Init()

Steam.GetSteamID()

Steam.GetFriendCount() `

However, when I try to run this I get this error-> INFO: SteamworksPy loaded for Windows INFO: Steam is running ERROR: Steamworks failed to initialize! Traceback (most recent call last): File "C:/../../PycharmProjects/untitled/miain.py", line 3, in <module> Steam.Init() File "C:\..\..\PycharmProjects\untitled\steamworks.py", line 111, in Init Steam.cdll.GetFriendByIndex.restype = c_uint64 File "C:\..\..\AppData\Local\Programs\Python\Python36-32\lib\ctypes\__init__.py", line 361, in __getattr__ func = self.__getitem__(name) File "C:\..\..\AppData\Local\Programs\Python\Python36-32\lib\ctypes\__init__.py", line 366, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: function 'GetFriendByIndex' not found

Even if I run the test, you have provided I get this error. Any ideas for a quick fix?

Gramps commented 5 years ago

Hmm, well it seems to be failing to even load the Steamworks API which is probably why those other functions fail. But why it's not loading Steamworks is the question. It contains the DLL files?

labanau commented 5 years ago

Hmm, well it seems to be failing to even load the Steamworks API which is probably why those other functions fail. But why it's not loading Steamworks is the question. Does it contain the DLL files?

It does include the files, I followed the guide, the strange thing is that I can't even compile the cpp on my visual studio to get the dll, so I used the precompiled dll, you have in the download section.

labanau commented 5 years ago

I managed to compile the dll file, I had to reinstall visual studio, now it just shows failed to initialize Steamworks. Do I need to pay for Steamworks and have a valid app id, to use the basic features and that is why it fails to initialize? Is it possible to hard-code that the app id is 480?

Gramps commented 5 years ago

Hey there! @KevinBRR had issues with initializing it too. Pay? No. You can use it regardless of even having a game on Steam. Using the Space Wars 480 should work. Just create a text file called steam_appid.text with just 480 in it and it should recognize the program as Space Wars.

I'll look into the initialization thing (hopefully) tomorrow and figure out why that happening!

labanau commented 5 years ago

Hey there! @kevinbrr had issues with initializing it too. Pay? No. You can use it regardless of even having a game on Steam. Using the Space Wars 480 should work. Just create a text file called steam_appid.text with just 480 in it and it should recognize the program as Space Wars.

I'll look into the initialization thing (hopefully) tomorrow and figure out why that happening!

It did fix it, if I run it on c++ version, I will try it with your wrapper in few minutes. One more question if you don't mind me asking, as it is not related to the issue. I want to check if the GetFriendFromSource works the way I think it does. May I ask how do you correctly provide the server steam id, to that function to get the number of friends to later call the GetFriendsFromSourceByIndex? I do have server id which looks like this 90125794806437897, in other words, how do you correctly pass the id to the function? Thanks for all your help!

Gramps commented 5 years ago

That ID does look valid I think. If I remember correctly there are a few ways to get the Steam server ID's, but from what we have in SteamworksPy currently only CreateLobby would return a server ID. In GodotSteam there are a few functions that would do it like requestLobbyList and, again, createLobby.

KevBRR commented 5 years ago

I noticed you mentioned "@kevinbrr", and probably meant me. Never really had problems with initializing. GetFriendFromSource and GetFriendsFromSourceByIndex is for the moment not a part of the SteamworksPy wrapper. You would have to add it manually through the cpp, compile it and add it under "Restypes and Argtypes" in the steamworks.py file, and also add it as a static-method in steamworks.py file. Question, @Gromis how did you go about getting the server id?

Gramps commented 5 years ago

Oops, wrong person! And OK, gotcha. Yeah, I am still slowly getting SteamworksPy up to where GodotSteam is.

labanau commented 5 years ago

I noticed you mentioned "@kevinbrr", and probably meant me. Never really had problems with initializing. GetFriendFromSource and GetFriendsFromSourceByIndex is for the moment not a part of the SteamworksPy wrapper. You would have to add it manually through the cpp, compile it and add it under "Restypes and Argtypes" in the steamworks.py file, and also add it as a static-method in steamworks.py file. Question, @Gromis how did you go about getting the server id?

@KevBRR You can get it when the user is on that server. So if I connect to the random server and then ping the person through steam web API, it will show you the IP and Steam server id. However, it is strange as if you use GetFriendFromSource, you would first need to connect to that server to get the "permissions", so I am trying to figure out how to get the players from that server without joining it.

labanau commented 5 years ago

There are two ways of how you can do it. One, which is really simple, connect to the server you want to get the server steam id. You need to make sure that you have a public profile as to get the IP and the ID you will need a public profile. Now what you do:

  1. Open your web browser
  2. Go to this link : http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={api_key}&steamids={steamid}
  3. Fill in the apikey and steamid, don't forget to remove '{}' brackets.

You will get a big response about your profile with the server steam id you are on.

The second way, do the same thing just through python with the urllib library or like smth as CURL and you will get it in dictionary format.

KevBRR commented 5 years ago

Yea, I see what you mean with getFriendCountFromSource. Almost seems pointless seeing as you have to "physically" be on the server to get permissions and be able to retrieve who's on the server, to then iterate through who's on.

labanau commented 5 years ago

@KevBRR Could you please send the GetFriendCountByIndex code that you made working with the people on the same server?

KevBRR commented 5 years ago

By **GetFriendCountByIndex* I assume you mean GetFriendByIndex**, think @Gramps already added it to the latest build.

labanau commented 5 years ago

By **GetFriendCountByIndex* I assume you mean GetFriendByIndex**, think @Gramps already added it to the latest build.

Yea, but the function implemented somehow always prints the all friends list instead of OnGameServer

Gramps commented 5 years ago

Yeah, the flag is set to get all friends. It should be updated to allow you to use any flag you want or just default to all. Something I need to change in the next update for sure.

As for getting server ID's, the process is a bit difficult from what I've seen over the last week of looking at things. Slightly easier with access to a master server list.

labanau commented 5 years ago

How is it going with updating the API? Are you still working on it?

Gramps commented 5 years ago

Pretty slow, sadly, but it is coming along. This summer has been crazy busy and I only get a few hours a day, once a week, to work on this and my GodotSteam module.

That being said, I'm converting all the functionality over, testing it, fixing bugs, then converting the next batch of functions. I don't really have a time frame of when this will be available but I might just start pushing each section (apps, friends, matchmaking, user stats, etc.) to the experimental branch as I get them finished.

Gramps commented 4 years ago

Man, it's been a while since I wrote back and been a super busy summer. Nonetheless, I am starting my slow update to the experimental branch. Added apps and a pre-compiled Windows DLL today. Will be adding more (hopefully) each week until I get to where my Godot Steamworks module is.