• gm_steamworks - Steamworks library
    70 replies, posted
  • Avatar of Skondra
  • This is my binding to VoiDeD's Steamworks API, [url="http://osw.limetech.org/"]Open Steamworks[/url]. [u][b]Download[/b][/u] [url]http://code.google.com/p/chrisaster/source/browse/trunk/gm_steamworks/[/url] (Last updated [b]09/06/10 21:40[/b]) [u][b]Function List[/b][/u] [code] steamworks.CSteamID() steamworks.ISteamClient() steamworks.Steam_BGetCallback() steamworks.Steam_FreeLastCallback() ISteamClient007:CreateSteamPipe() ISteamClient007:ConnectToGlobalUser(hSteamPipe) ISteamClient007:GetISteamUser(hSteamUser, hSteamPipe, interfaceVersion) ISteamClient007:GetISteamFriends(hSteamUser, hSteamPipe, interfaceVersion) ISteamUser005:IsPrimaryChatDestination() ISteamUser005:GetHSteamUser() ISteamUser005:GetCSteamID() ISteamUser005:LoggedOn() ISteamUser005:SetSelfAsPrimaryChatDestination() ISteamUser012:GetHSteamUser() ISteamUser012:GetCSteamID() ISteamUser012:LoggedOn() ISteamFriends002:AcknowledgeInviteToClan(CSID, bool) ISteamFriends002:AddFriend(CSID) ISteamFriends002:AddFriendByName(nameOrEmail) ISteamFriends002:GetChatMessage(friendCSID, chatID) ISteamFriends002:InviteFriendToClan(friendCSID, groupCSID) ISteamFriends002:RemoveFriend(friendCSID) ISteamFriends002:SendMsgToFriend(friendCSID, messageType, messageBody) ISteamFriends002:SetPersonaState(personaState) ISteamFriends005:ActivateGameOverlay(pchDialog) ISteamFriends005:ActivateGameOverlayToStore(appID) ISteamFriends005:ActivateGameOverlayToUser(pchDialog, friendCSID) ISteamFriends005:ActivateGameOverlayToWebPage(pchURL) ISteamFriends005:GetClanByIndex(clanIndex) ISteamFriends005:GetClanCount() ISteamFriends005:GetClanName(groupCSID) ISteamFriends005:GetFriendByIndex(friendIndex, friendFlags) ISteamFriends005:GetFriendCount(friendFlags) ISteamFriends005:GetFriendCountFromSource(sourceCSID) ISteamFriends005:GetFriendFromSourceByIndex(sourceCSID, friendIndex) ISteamFriends005:GetFriendGamePlayed(friendCSID) ISteamFriends005:GetFriendPersonaName(friendCSID) ISteamFriends005:GetFriendPersonaNameHistory(friendCSID, historyIndex) ISteamFriends005:GetFriendPersonaState(friendCSID) ISteamFriends005:GetFriendRelationship(friendCSID) ISteamFriends005:GetPersonaName() ISteamFriends005:GetPersonaState() ISteamFriends005:HasFriend(friendCSID, friendFlags) ISteamFriends005:IsUserInSource(userCSID, sourceCSID) ISteamFriends005:SetInGameVoiceSpeaking(userCSID, bSpeaking) ISteamFriends005:SetPersonaName(personaName) CSteamID:GetAccountID() CSteamID:GetEAccountType() CSteamID:GetEUniverse() CSteamID:GetUnAccountInstance() CSteamID:InstancedSet(accountID, accountInstance, eUniverse, eAccountType) CSteamID:IsValid() CSteamID:Render() CSteamID:Set(accountID, eUniverse, accountType) CSteamID:SetAccountID(accountID) CSteamID:SetEUniverse(eUniverse) PubParam:To(newTypeMetaID) CallbackMsg_t:GetCubParam() CallbackMsg_t:GetHSteamUser() CallbackMsg_t:GetCallback() CallbackMsg_t:GetPubParam() GameOverlayActivated_t:IsActive() PersonaStateChange_t:GetSteamID() PersonaStateChange_t:GetFlags() FriendChatMsg_t:GetReceiver() FriendChatMsg_t:GetSender() FriendChatMsg_t:GetChatID() FriendEndChatSession_t:GetCSteamID() FriendAdded_t:GetSuccess() FriendAdded_t:GetSteamID() UserRequestingFriendship_t:GetSteamID() FriendGameInfo_t:GetCGameID() FriendGameInfo_t:GetGameIP() FriendGameInfo_t:GetGamePort() FriendGameInfo_t:GetQueryPort() CGameID:AppID() CGameID:IsMod() CGameID:IsP2PFile() CGameID:IsShortcut() CGameID:IsSteamApp() CGameID:IsValid() CGameID:ModID() [/code] [u][b]Examples[/b][/u] [lua] //steamworks.lua require("steamworks") steamClient007 = steamworks.ISteamClient(7) if (!steamClient007) then return end hSteamPipe = steamClient007:CreateSteamPipe() if (!hSteamPipe) then return end hSteamUser = steamClient007:ConnectToGlobalUser(hSteamPipe) if (!hSteamUser) then return end steamUser012 = steamClient007:GetISteamUser(hSteamUser, hSteamPipe, 12) if (!steamUser012) then return end if (!steamUser012:LoggedOn()) then return end steamFriends005 = steamClient007:GetISteamFriends(hSteamUser, hSteamPipe, 5) if (!steamFriends005) then return end steamFriends002 = steamClient007:GetISteamFriends(hSteamUser, hSteamPipe, 2) if (!steamFriends002) then return end hook.Add("Think", "Steam_BGetCallback", function() callbackMsg = steamworks.Steam_BGetCallback(hSteamPipe) if (!callbackMsg) then return end if (callbackMsg:GetCallback() == (300 + 31)) then local gameOverlay = callbackMsg:GetPubParam():To(FindMetaTable("GameOverlayActivated_t").MetaID) hook.Call("GameOverlayActivated", nil, gameOverlay:IsActive()) elseif (callbackMsg:GetCallback() == (300 + 4)) then local personaChange = callbackMsg:GetPubParam():To(FindMetaTable("PersonaStateChange_t").MetaID) local personaSID = personaChange:GetSteamID() if (personaSID) then local personaCSID = steamworks.CSteamID() personaCSID:Set(personaSID, 1, 1) if (personaChange:GetFlags() == 0x001) then hook.Call("EPersonaChangeName", nil, personaCSID) elseif (personaChange:GetFlags() == 0x002) then hook.Call("EPersonaChangeStatus", nil, personaCSID) elseif (personaChange:GetFlags() == 0x004) then hook.Call("EPersonaChangeComeOnline", nil, personaCSID) elseif (personaChange:GetFlags() == 0x008) then hook.Call("EPersonaChangeGoneOffline", nil, personaCSID) elseif (personaChange:GetFlags() == 0x010) then hook.Call("EPersonaChangeGamePlayed", nil, personaCSID) elseif (personaChange:GetFlags() == 0x020) then hook.Call("EPersonaChangeGameServer", nil, personaCSID) elseif (personaChange:GetFlags() == 0x040) then hook.Call("EPersonaChangeAvatar", nil, personaCSID) elseif (personaChange:GetFlags() == 0x080) then hook.Call("EPersonaChangeJoinedSource", nil, personaCSID) elseif (personaChange:GetFlags() == 0x100) then hook.Call("EPersonaChangeLeftSource", nil, personaCSID) elseif (personaChange:GetFlags() == 0x200) then hook.Call("EPersonaChangeRelationshipChanged", nil, personaCSID) elseif (personaChange:GetFlags() == 0x400) then hook.Call("EPersonaChangeNameFirstSet", nil, personaCSID) end end end steamworks.Steam_FreeLastCallback(hSteamPipe) end ) [/lua] [lua] include("steamworks.lua") local EPersonaStateStrings = { "Offline", "Online", "Busy", "Away", "Snooze", } hook.Add("GameOverlayActivated", "SHook", function(state) if (state) then print(string.format("[%s] Opened game overlay", os.date())) else print(string.format("[%s] Closed game overlay", os.date())) end end ) hook.Add("EPersonaChangeName", "SHook", function(id) print(string.format("[%s] The owner of %s changed their name to '%s'", os.date(), id:Render(), steamFriends005:GetFriendPersonaName(id))) end ) hook.Add("EPersonaChangeStatus", "SHook", function(id) print(string.format("[%s] '%s' is now %s", os.date(), steamFriends005:GetFriendPersonaName(id), EPersonaStateStrings[steamFriends005:GetFriendPersonaState(id)+1])) end ) hook.Add("EPersonaChangeComeOnline", "SHook", function(id) print(string.format("[%s] '%s' signed in", os.date(), steamFriends005:GetFriendPersonaName(id))) end ) hook.Add("EPersonaChangeGoneOffline", "SHook", function(id) print(string.format("[%s] '%s' signed out", os.date(), steamFriends005:GetFriendPersonaName(id))) end ) hook.Add("EPersonaChangeGamePlayed", "SHook", function(id) local gamePlayed = steamFriends005:GetFriendGamePlayed(id) if (gamePlayed) then print(string.format("[%s] '%s' is now playing {AppID:%d}", os.date(), steamFriends005:GetFriendPersonaName(id), gamePlayed:GetCGameID():AppID())) else print(string.format("[%s] '%s' is no longer playing anything", os.date(), steamFriends005:GetFriendPersonaName(id))) end end ) hook.Add("EPersonaChangeGameServer", "SHook", function(id) print(string.format("[%s] '%s' is now playing on %s:%d", os.date(), steamFriends005:GetFriendPersonaName(id), steamFriends005:GetFriendGamePlayed(id):GetGameIP(), steamFriends005:GetFriendGamePlayed(id):Get
  • Avatar of lexic
  • I see you didn't manage to work out how to display the user's previous name. :(
  • Avatar of Skondra
  • [QUOTE=Lexic;17638278]I see you didn't manage to work out how to display the user's previous name. :([/QUOTE] CSteamID:NameHistory(0) might work.
  • Avatar of VoiDeD
  • Glad to see the API is getting some use. Feel free to post about any C++ API related issues here as well, since there really is no official thread for the Open Steamworks project. Also, I'm looking for anyone who is willing to test functions, and since you seem to be the right person for the job chrisaster, feel free to PM or post details about any functions you've tested. (If any)
  • Avatar of Skondra
  • [QUOTE=cyber_cam34;17646947]Can you make a function to get users/steamids in a group?[/QUOTE] Done.
  • Avatar of Crazy Quebec
  • Just to make sure, with this you can access all of the functionalities of the Steam Community and possibly interface steam with other messaging clients?
  • Avatar of Skondra
  • I'm still working on hooking chat messages, however it seems that there is no callback being made for incoming nor outgoing messages.
  • Avatar of slayer3032
  • I just messaged everyone on my friends list with this. It messaged people who where appearing offline, it was hilarious. This module is awesome.
  • Avatar of raBBish
  • Incase anyone's interested, here's a list of friendFlags: [code] k_EFriendFlagNone = 0 k_EFriendFlagBlocked = 1 k_EFriendFlagFriendshipRequested = 2 k_EFriendFlagImmediate = 4 // "regular" friend k_EFriendFlagClanMember = 8 k_EFriendFlagOnGameServer = 16, //k_EFriendFlagHasPlayedWith = 32 //k_EFriendFlagFriendOfFriend = 64 k_EFriendFlagRequestingFriendship = 128, k_EFriendFlagRequestingInfo = 256 k_EFriendFlagAll = 65 535 [/code] And logon states: [code] k_ELogonStateNotLoggedOn = 0 k_ELogonStateLoggingOn = 1 k_ELogonStateLoggingOff = 2 k_ELogonStateLoggedOn = 3 [/code] EDIT: Just noticed this takes logon states as strings [editline]05:36AM[/editline] [lua] steamworks.SetStatus("anythingbutempty") [/lua] Hilarity ensues
  • Avatar of VoiDeD
  • I created a thread for the Open Steamworks project. You can find it here: [url]http://www.facepunch.com/showthread.php?p=17667828[/url] I'll be around in both threads to help out.
  • [QUOTE=THERPM;17668073]it's probably a virus chrisaster "SKONDRA" is a hacker[/QUOTE] lol @ this dude
  • Avatar of Deco Da Man
  • Skondra! [QUOTE=VoiDeD;17669965]The 64bit representation of a CSteamID is a community ID. [cpp] CSteamID id((uint64)76561197969249708L); [/cpp] As for string representations, you'll have to manually parse them.[/QUOTE] steamworks.CSteamIDFromID(community_id) please! [editline]02:15PM[/editline] And a hook for chat messages.. I know it's possible cause there's something that uses it in the Open Steamworks thread.
  • Avatar of ashashinand
  • [QUOTE=THERPM;17668073]it's probably a virus chrisaster "SKONDRA" is a hacker[/QUOTE] funny oh wait you're serious
  • Avatar of raBBish
  • [QUOTE=Deco Da Man;17671108]I've been having fun with this :D [url]http://codepad.org/mvJ7gbH3[/url][/QUOTE] That's awesome :D Though I recommend that you do not click your own name, made my Steam crash.
  • Avatar of Skondra
  • [QUOTE=Deco Da Man;17670243]Skondra! steamworks.CSteamIDFromID(community_id) please! [editline]02:15PM[/editline] And a hook for chat messages.. I know it's possible cause there's something that uses it in the Open Steamworks thread.[/QUOTE] I'll give it a go when I get home, along with a way to generate CSteamID's from a player's Steam ID string. I've also added CSteamID:IsFriend(friendFlags) so that you can check whether a player falls under the specified flags. (Useful for auto-inviting recently met players)
  • Avatar of Deco Da Man
  • [QUOTE=Skondra;17672507]I'll give it a go when I get home, along with a way to generate CSteamID's from a player's Steam ID string. I've also added CSteamID:IsFriend(friendFlags) so that you can check whether a player falls under the specified flags. (Useful for auto-inviting recently met players)[/QUOTE] <3 Thanks for making this module :D And thanks to VoiDeD for putting together Open Steamworks :D
  • Avatar of Skapocalypse
  • [QUOTE=THERPM;17668073]it's probably a virus chrisaster "SKONDRA" is a hacker[/QUOTE] Have a box :)