philippj / SteamworksPy

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

Need help by installing library #23

Open signofshadow opened 4 years ago

signofshadow commented 4 years ago

Hello there Wanted to ask if someone could help me installing the library so i can get startet with it. I downloaded the steamworks SDK and the steamworkspy library. I worked troug the explanation here: https://gramps.github.io/SteamworksPy/

Now here is a problem that i have. As far as i understand if i have a project open i have to copy the steamworkspy into the venv folder (as completly folder?). Also you have to copy first 2 folders from the steamworks sdk into the project folder. Now there is the part in the windows where it stand that i have to copy now a couple files from the folders i copied to the project folder and put those now in the project folder (hope you understand what i mean). Could someone help me and tell me if i need to write something in my code to include the library?

Thanks for help and sry for my english

signofshadow commented 4 years ago

Maybe as an additional comment, i always installed librarys with the pip install command on windows 10 and i am using pycharm 2019

Gramps commented 4 years ago

Well, you only need the Steamworks SDK folder if you are compiling the DLL, SO, or Dylib files from scratch. For compiling just copy all the necessary stuff into a clean folder and compile from there by following the instructions. If you get stuck during this process, let me know where.

If you use the pre-compiled ones (I recommend the pre-compiles) or have already compiled it, you just need to add the steamworks.py file and the DLL in your project folder. Then inside whatever you main project file is just add

from steamworks import *

As to where in your code you add stuff depends on what you are trying to do.

Just write back where you are at and we'll get it sorted out!

signofshadow commented 4 years ago

thanks for the help (sry for my delayed answer) i am going to try that out and if i need help i let it know you 😄

thanks a lot

signofshadow commented 4 years ago

image I hope there is no difference between there unless how it is comprimized 😄

https://github.com/Gramps/SteamworksPy/releases

signofshadow commented 4 years ago

I wrote recently a Python programm to query over A2S steam servers to get player information, and now i want to try if its possible to get besides the steam name and playing time the steam64 id 😄 i will find it soon out (currently i have like 60h experience in python)

Possible that these commands are not available in the steamworks library? getServerDetails / getServerCount https://partner.steamgames.com/doc/api/ISteamMatchmakingServers#GetServerCount

Gramps commented 4 years ago

Mmm, if they are not in now they will be added later, I believe. Since that is server code it will probably end up in a different branch from the master like I did with my GodotSteam library.

signofshadow commented 4 years ago

image

https://partner.steamgames.com/doc/api/ISteamMatchmakingServers#GetServerCount

the Commands are in the link above, and from the matchmaking Interface are these commands already in

signofshadow commented 4 years ago

i would like to help add things but i am too unexperienced to so i think

Gramps commented 4 years ago

Ah, there are two different matchmaking libraries; one for client and one for server. The ones you were talking about were server matchmaking. The ones already in the library are client matchmaking.

I'll add it to my list for the next update though.

labanau commented 4 years ago

The SteamMatchmakingServers methods return almost the same information as A2S, it does not return steamid. You can however return steamid using SteamFriends interface. There are some issues with it though, info is not fully correct and it can return less player then there actually is, additionally you need to be on the server or be fully authenticated with it to be able to read steamids, I am actually currently working on a similar project and for a few months can't figure out how to verify users with game servers without launching game :) if you have only 60h experience with python, I would suggest not to jump on Steamworks yet as it is not well documented and super irretating to work with.

signofshadow commented 4 years ago

Well if you find it out how to do so and share it, i would appreciate it! And i have 60h experience in python but a little bit more in another programming language (although the syntax isn't the same at all). And i needed a lot of time for my A2S code and got it all together with Google (searching for solutions when i got an error and couldn't figure it out on my own) 😊

So although my chances for success are very little i still wanna try to figure it out and will let you know if i find something out

Thanks for your support 😊

Gramps commented 4 years ago

Not sure I know what A2S is.

Yeah, getting Steam ID's from servers is a bit of a pain. If it's return less players then something might be wrong in the code. I've not actually tried it.

I know there is an open issue on GodotSteam looking for a way to pull auth data to combine with Valve's Steamworks Web API but not sure the auth tickets can be displayed fully... or I can't get it to work. Though it seems like there is a way since the Web API asks for web tokens in HEX.

Speaking of the Web API, I wonder if that might help in this endeavor.

labanau commented 4 years ago

A2S is steam server query protocol. But it is somewhat deprecated and old, it is not part of Steamworks. In Steamworks, you can get the same information as A2S from SteamMatchmakingServers interface with the methods of GetServerDetails, PingServer, GetRules

For steamids, methods such as SteamFriends->GetFriendCount will return the steamids from which you can call other things as player names etc. Unfortunately, it does return incorrect data and you can't really do much about it except filtering people who already left the server by using IsUserInSource method.

For the auth ticket usages with web api, you need to call SteamUsers->GetAuthSesssionTicket() which then return the ticket. You need to resize the ticket to the correct length (the correct size is returned with the method) and finally you need to convert it to string and pass it in the WebApi, the conversion in C# looks like this

StringBuilder sb = new StringBuilder();
foreach (byte b in p)
{
      sb.AppendFormat("{0:x2}", b);
}
hexTicket = sb.ToString();

I am still trying to figure out how to authenticate with the game server itself to get the data (steamids) the only way I have right now is to join the server physically, but I know there is a way as I know of few discord bots which do that with other steamworks wrappers (Facepunch and C++ original version)

Gramps commented 4 years ago

Sounds like a pain. What is the A2S stuff useful for?

Yeah, I will take that code sample into account when trying to solve the auth ticket thing.

Hmm, that last part I'm not so sure how to. Haven't really tried to mess with the server stuff just yet. Still working on getting the callbacks to fire correctly.

signofshadow commented 4 years ago

The A2S allows you to query the game server or the head/master server with the Port and IP address. If you use the game server query you can get infos like steam name, player count, player score, server name, etc. a bunch of others infos too. I am still watching in steamworks for the steamID solution, i too saw some discord bots which can handle that

Gramps commented 4 years ago

Ah, OK. Well, hopefully we can get that ironed out soon.

Nereg commented 4 years ago

The A2S allows you to query the game server or the head/master server with the Port and IP address. If you use the game server query you can get infos like steam name, player count, player score, server name, etc. a bunch of others infos too. I am still watching in steamworks for the steamID solution, i too saw some discord bots which can handle that

yeah I am interesed in that. I found this article from facepuch forum where they said that you could get server's steam id and then pass it to GetFriendCountFromSource and GetFriendFromSourceByIndex, which returns "users in a chat room, lobby, game server or clan". Could anyone proof that ? because I now have some problemms with running this library

Nereg commented 4 years ago

And there are no such API calls from your library. please add

Gramps commented 4 years ago

That might work. I know some functions won't provide data the "user doesn't know about". Nonetheless, I will try to get Apps and Friends up to speed this weekend. That will include the GetFriendCountFromSource and GetFriendFromSourceByIndex. I'm not sure if they will do the job you are requiring but it's worth a shot.

One of the main issues I run into is passing back an array or dictionary from C++ to Python. I haven't quite figured out the best way to do that with CTypes.

Nereg commented 4 years ago

I am installing vs studio because it won't compile without it :/ damn windows I hate it (and my target system is linux -_-)

Gramps commented 4 years ago

That sucks. I usually use the Visual Studio Command Prompt tools instead of the IDE as it is a, in my opinion, nightmare.

Nereg commented 4 years ago

Installed vs studio. Tryed to compile and got SteamworksPy.cpp(9): fatal error C1083: Cannot open include file: 'sdk\steam\steam_api.h': No such file or directory Here is screenshot : https://prnt.sc/u0umew Also here is full script output (as well as source because I modified it to match my installation path) : https://pastebin.com/ReSWi0Fc

Gramps commented 4 years ago

Hmm, I haven't actually used this library in a long time as I no longer develop games with Python. However, where do you have the Steam header files?

Nereg commented 4 years ago

Here they are : https://prnt.sc/u21wfz and https://prnt.sc/u21xx8

Gramps commented 4 years ago

Yeah, that looks like they are in the right place. And the build file looks OK. I honestly have no idea why this is giving that errors as everything seems in place. Maybe @philippj can shed some light?

philippj commented 4 years ago

Hey. I located the issue in the build script and pushed a fix for it. Please pull the latest version and try again.

The library needs all the SDK source to be in a folder called steam, the link command in the build script linked directly in the steam folder instead of linking the steam folder itself in the current build root.

Nereg commented 4 years ago

So OK here is new dll's for latest version that I compiled: 64-bit 32-bit

Gramps commented 4 years ago

Are those for testing?

Nereg commented 4 years ago

Yep. Because older dlls are incompatible with new code (https://github.com/philippj/SteamworksPy/commit/9903c5cc66776fa3a55ea7acabf42a12ed25def8)