source: TFP-WebServer/WebServer/src/WebAPI/APIs/WorldState/GetPlayersOnline.cs@ 474

Last change on this file since 474 was 433, checked in by alloc, 19 months ago

Fixed: User registration allowed same username for multiple users

File size: 2.0 KB
Line 
1// using AllocsFixes.PersistentData;
2// using JetBrains.Annotations;
3//
4// namespace Webserver.WebAPI.APIs {
5// [UsedImplicitly]
6// public class GetPlayersOnline : AbsWebAPI {
7// public override void HandleRequest (RequestContext _context) {
8// JsonArray players = new JsonArray ();
9//
10// World w = GameManager.Instance.World;
11// foreach ((int entityId, EntityPlayer entityPlayer) in w.Players.dict) {
12// ClientInfo ci = ConnectionManager.Instance.Clients.ForEntityId (entityId);
13// Player player = PersistentContainer.Instance.Players [ci.InternalId, false];
14//
15// JsonObject pos = new JsonObject ();
16// pos.Add ("x", new JsonNumber ((int) entityPlayer.GetPosition ().x));
17// pos.Add ("y", new JsonNumber ((int) entityPlayer.GetPosition ().y));
18// pos.Add ("z", new JsonNumber ((int) entityPlayer.GetPosition ().z));
19//
20// JsonObject p = new JsonObject ();
21// p.Add ("steamid", new JsonString (ci.PlatformId.CombinedString));
22// p.Add ("entityid", new JsonNumber (ci.entityId));
23// p.Add ("ip", new JsonString (ci.ip));
24// p.Add ("name", new JsonString (entityPlayer.EntityName));
25// p.Add ("online", new JsonBoolean (true));
26// p.Add ("position", pos);
27//
28// p.Add ("level", new JsonNumber (player?.Level ?? -1));
29// p.Add ("health", new JsonNumber (entityPlayer.Health));
30// p.Add ("stamina", new JsonNumber (entityPlayer.Stamina));
31// p.Add ("zombiekills", new JsonNumber (entityPlayer.KilledZombies));
32// p.Add ("playerkills", new JsonNumber (entityPlayer.KilledPlayers));
33// p.Add ("playerdeaths", new JsonNumber (entityPlayer.Died));
34// p.Add ("score", new JsonNumber (entityPlayer.Score));
35//
36// p.Add ("totalplaytime", new JsonNumber (player?.TotalPlayTime ?? -1));
37// p.Add ("lastonline", new JsonString (player != null ? player.LastOnline.ToString ("s") : string.Empty));
38// p.Add ("ping", new JsonNumber (ci.ping));
39//
40// players.Add (p);
41// }
42//
43// WebUtils.WriteJson (_context.Response, players);
44// }
45// }
46// }
Note: See TracBrowser for help on using the repository browser.