isteamgameserverstats.cs (5622B)
1 // This file is provided under The MIT License as part of Steamworks.NET. 2 // Copyright (c) 2013-2019 Riley Labrecque 3 // Please see the included LICENSE.txt for additional information. 4 5 // This file is automatically generated. 6 // Changes to this file will be reverted when you update Steamworks.NET 7 8 #if UNITY_ANDROID || UNITY_IOS || UNITY_TIZEN || UNITY_TVOS || UNITY_WEBGL || UNITY_WSA || UNITY_PS4 || UNITY_WII || UNITY_XBOXONE || UNITY_SWITCH 9 #define DISABLESTEAMWORKS 10 #endif 11 12 #if !DISABLESTEAMWORKS 13 14 using System.Runtime.InteropServices; 15 using IntPtr = System.IntPtr; 16 17 namespace Steamworks { 18 public static class SteamGameServerStats { 19 /// <summary> 20 /// <para> downloads stats for the user</para> 21 /// <para> returns a GSStatsReceived_t callback when completed</para> 22 /// <para> if the user has no stats, GSStatsReceived_t.m_eResult will be set to k_EResultFail</para> 23 /// <para> these stats will only be auto-updated for clients playing on the server. For other</para> 24 /// <para> users you'll need to call RequestUserStats() again to refresh any data</para> 25 /// </summary> 26 public static SteamAPICall_t RequestUserStats(CSteamID steamIDUser) { 27 InteropHelp.TestIfAvailableGameServer(); 28 return (SteamAPICall_t)NativeMethods.ISteamGameServerStats_RequestUserStats(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser); 29 } 30 31 /// <summary> 32 /// <para> requests stat information for a user, usable after a successful call to RequestUserStats()</para> 33 /// </summary> 34 public static bool GetUserStat(CSteamID steamIDUser, string pchName, out int pData) { 35 InteropHelp.TestIfAvailableGameServer(); 36 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 37 return NativeMethods.ISteamGameServerStats_GetUserStat(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, out pData); 38 } 39 } 40 41 public static bool GetUserStat(CSteamID steamIDUser, string pchName, out float pData) { 42 InteropHelp.TestIfAvailableGameServer(); 43 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 44 return NativeMethods.ISteamGameServerStats_GetUserStat0(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, out pData); 45 } 46 } 47 48 public static bool GetUserAchievement(CSteamID steamIDUser, string pchName, out bool pbAchieved) { 49 InteropHelp.TestIfAvailableGameServer(); 50 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 51 return NativeMethods.ISteamGameServerStats_GetUserAchievement(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, out pbAchieved); 52 } 53 } 54 55 /// <summary> 56 /// <para> Set / update stats and achievements.</para> 57 /// <para> Note: These updates will work only on stats game servers are allowed to edit and only for</para> 58 /// <para> game servers that have been declared as officially controlled by the game creators.</para> 59 /// <para> Set the IP range of your official servers on the Steamworks page</para> 60 /// </summary> 61 public static bool SetUserStat(CSteamID steamIDUser, string pchName, int nData) { 62 InteropHelp.TestIfAvailableGameServer(); 63 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 64 return NativeMethods.ISteamGameServerStats_SetUserStat(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, nData); 65 } 66 } 67 68 public static bool SetUserStat(CSteamID steamIDUser, string pchName, float fData) { 69 InteropHelp.TestIfAvailableGameServer(); 70 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 71 return NativeMethods.ISteamGameServerStats_SetUserStat0(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, fData); 72 } 73 } 74 75 public static bool UpdateUserAvgRateStat(CSteamID steamIDUser, string pchName, float flCountThisSession, double dSessionLength) { 76 InteropHelp.TestIfAvailableGameServer(); 77 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 78 return NativeMethods.ISteamGameServerStats_UpdateUserAvgRateStat(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2, flCountThisSession, dSessionLength); 79 } 80 } 81 82 public static bool SetUserAchievement(CSteamID steamIDUser, string pchName) { 83 InteropHelp.TestIfAvailableGameServer(); 84 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 85 return NativeMethods.ISteamGameServerStats_SetUserAchievement(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2); 86 } 87 } 88 89 public static bool ClearUserAchievement(CSteamID steamIDUser, string pchName) { 90 InteropHelp.TestIfAvailableGameServer(); 91 using (var pchName2 = new InteropHelp.UTF8StringHandle(pchName)) { 92 return NativeMethods.ISteamGameServerStats_ClearUserAchievement(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser, pchName2); 93 } 94 } 95 96 /// <summary> 97 /// <para> Store the current data on the server, will get a GSStatsStored_t callback when set.</para> 98 /// <para> If the callback has a result of k_EResultInvalidParam, one or more stats</para> 99 /// <para> uploaded has been rejected, either because they broke constraints</para> 100 /// <para> or were out of date. In this case the server sends back updated values.</para> 101 /// <para> The stats should be re-iterated to keep in sync.</para> 102 /// </summary> 103 public static SteamAPICall_t StoreUserStats(CSteamID steamIDUser) { 104 InteropHelp.TestIfAvailableGameServer(); 105 return (SteamAPICall_t)NativeMethods.ISteamGameServerStats_StoreUserStats(CSteamGameServerAPIContext.GetSteamGameServerStats(), steamIDUser); 106 } 107 } 108 } 109 110 #endif // !DISABLESTEAMWORKS