mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 06:35:49 +03:00
PlayerCountAsync
This commit is contained in:
parent
650fb08522
commit
f18de016b1
@ -29,6 +29,14 @@ public void AchievementList()
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task PlayerCountAsync()
|
||||
{
|
||||
var players = await SteamUserStats.PlayerCountAsync();
|
||||
Assert.AreNotEqual( players, -1 );
|
||||
Console.WriteLine( $"players: {players}" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,5 +34,18 @@ public static IEnumerable<Achievement> Achievements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the number of players currently playing this game.
|
||||
/// Or -1 if failed.
|
||||
/// </summary>
|
||||
public static async Task<int> PlayerCountAsync()
|
||||
{
|
||||
var result = await Internal.GetNumberOfCurrentPlayers();
|
||||
if ( !result.HasValue || result.Value.Success == 0 )
|
||||
return -1;
|
||||
|
||||
return result.Value.CPlayers;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user