diff --git a/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj b/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj
index c87f1b0..9ff3737 100644
--- a/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj
+++ b/Facepunch.Steamworks.Test/Facepunch.Steamworks.Test.csproj
@@ -93,6 +93,7 @@
+
diff --git a/Facepunch.Steamworks.Test/Server/Server.cs b/Facepunch.Steamworks.Test/Server/Server.cs
index ca7f70c..15c4b55 100644
--- a/Facepunch.Steamworks.Test/Server/Server.cs
+++ b/Facepunch.Steamworks.Test/Server/Server.cs
@@ -9,7 +9,7 @@ namespace Facepunch.Steamworks.Test
[DeploymentItem( "vstdlib_s.dll" )]
[DeploymentItem( "steamclient.dll" )]
[TestClass]
- public class Server
+ public partial class Server
{
[TestMethod]
public void Init()
diff --git a/Facepunch.Steamworks.Test/Server/Stats.cs b/Facepunch.Steamworks.Test/Server/Stats.cs
new file mode 100644
index 0000000..5bb69e1
--- /dev/null
+++ b/Facepunch.Steamworks.Test/Server/Stats.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Text;
+using System.Threading;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Facepunch.Steamworks.Test
+{
+ public partial class Server
+ {
+ [TestMethod]
+ public void StatsGet()
+ {
+ using ( var server = new Facepunch.Steamworks.Server( 252490, 0, 30002, true, "VersionString" ) )
+ {
+ Assert.IsTrue( server.Valid );
+ server.LogOnAnonymous();
+
+ ulong MySteamId = 76561197960279927;
+
+ server.Stats.Refresh( MySteamId );
+
+ // TODO - Callback on complete
+
+ Thread.Sleep( 2000 );
+
+ var deaths = server.Stats.GetInt( MySteamId, "deaths", -1 );
+
+ Console.WriteLine( "Deaths: {0}", deaths );
+ Assert.IsTrue( deaths > 0 );
+ }
+ }
+
+ }
+}
diff --git a/Facepunch.Steamworks/Facepunch.Steamworks.csproj b/Facepunch.Steamworks/Facepunch.Steamworks.csproj
index 29aaec7..ec01503 100644
--- a/Facepunch.Steamworks/Facepunch.Steamworks.csproj
+++ b/Facepunch.Steamworks/Facepunch.Steamworks.csproj
@@ -135,6 +135,7 @@
+
diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs
index fa5feaf..751fa51 100644
--- a/Facepunch.Steamworks/Server.cs
+++ b/Facepunch.Steamworks/Server.cs
@@ -352,5 +352,10 @@ namespace Facepunch.Steamworks
{
native.gameServer.BUpdateUserData( steamid, name, (uint) score );
}
+
+ public bool LoggedOn
+ {
+ get { return native.gameServer.BLoggedOn(); }
+ }
}
}
diff --git a/Facepunch.Steamworks/Server/Stats.cs b/Facepunch.Steamworks/Server/Stats.cs
new file mode 100644
index 0000000..36db54c
--- /dev/null
+++ b/Facepunch.Steamworks/Server/Stats.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Facepunch.Steamworks
+{
+ public partial class Server
+ {
+ ServerStats _stats;
+
+ public ServerStats Stats
+ {
+ get
+ {
+ if ( _stats == null )
+ _stats = new ServerStats( this );
+
+ return _stats;
+ }
+ }
+ }
+
+ public class ServerStats
+ {
+ internal Server server;
+
+ internal ServerStats( Server s )
+ {
+ server = s;
+ }
+
+ [StructLayout( LayoutKind.Sequential )]
+ public struct StatsReceived
+ {
+ public int Result;
+ public ulong SteamId;
+ }
+
+ ///
+ /// Retrieve the stats for this user
+ ///
+ public void Refresh( ulong steamid )
+ {
+ var handle = server.native.stats.RequestUserStats( steamid );
+ }
+
+ public void Commit( ulong steamid )
+ {
+ server.native.stats.StoreUserStats( steamid );
+ }
+
+ ///
+ /// Set the named statistic for this user
+ ///
+ public bool Set( ulong steamid, string name, int stat )
+ {
+ return server.native.stats.SetUserStat( steamid, name, stat );
+ }
+
+ ///
+ /// Set the named statistic for this user
+ ///
+ public bool Set( ulong steamid, string name, float stat )
+ {
+ return server.native.stats.SetUserStat0( steamid, name, stat );
+ }
+
+ ///
+ /// Set the named stat for this user
+ ///
+ public int GetInt( ulong steamid, string name, int defaultValue = 0 )
+ {
+ int data = defaultValue;
+
+ if ( !server.native.stats.GetUserStat( steamid, name, ref data ) )
+ return defaultValue;
+
+ return data;
+ }
+
+ ///
+ /// Set the named stat for this user
+ ///
+ public float GetFloat( ulong steamid, string name, float defaultValue = 0 )
+ {
+ float data = defaultValue;
+
+ if ( !server.native.stats.GetUserStat0( steamid, name, ref data ) )
+ return defaultValue;
+
+ return data;
+ }
+ }
+}