- Timestamp:
- Apr 30, 2015, 1:55:16 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/MapRendering/Web/API/GetPlayersOnline.cs
r230 r233 1 1 using AllocsFixes.JSON; 2 using AllocsFixes.PersistentData; 2 3 using System; 3 4 using System.Collections.Generic; … … 15 16 foreach (KeyValuePair<int, EntityPlayer> current in w.Players.dict) { 16 17 ClientInfo ci = ConnectionManager.Instance.GetClientInfoForEntityId (current.Key); 17 string ip = string.Empty; 18 if (ci != null) { 19 ip = ci.ip; 20 } 18 Player player = PersistentContainer.Instance.Players [ci.playerId, false]; 21 19 22 20 JSONObject pos = new JSONObject(); 23 pos.Add ("x", new JSONNumber((int)current.Value.GetPosition().x));24 pos.Add ("y", new JSONNumber((int)current.Value.GetPosition().y));25 pos.Add ("z", new JSONNumber((int)current.Value.GetPosition().z));21 pos.Add ("x", new JSONNumber ((int)current.Value.GetPosition ().x)); 22 pos.Add ("y", new JSONNumber ((int)current.Value.GetPosition ().y)); 23 pos.Add ("z", new JSONNumber ((int)current.Value.GetPosition ().z)); 26 24 27 25 JSONObject p = new JSONObject(); 28 p.Add("steamid", new JSONString(ci.playerId)); 29 p.Add("ip", new JSONString(ip)); 30 p.Add("name", new JSONString(current.Value.EntityName)); 31 p.Add("online", new JSONBoolean(true)); 32 p.Add("position", pos); 26 p.Add ("steamid", new JSONString (ci.playerId)); 27 p.Add ("ip", new JSONString (ci != null ? ci.ip : string.Empty)); 28 p.Add ("name", new JSONString (current.Value.EntityName)); 29 p.Add ("online", new JSONBoolean (true)); 30 p.Add ("position", pos); 31 32 p.Add ("experience", new JSONNumber (player != null ? player.Experience : 0)); 33 p.Add ("level", new JSONNumber (player != null ? player.Level : -1)); 34 p.Add ("health", new JSONNumber (current.Value.Health)); 35 p.Add ("stamina", new JSONNumber (current.Value.Stamina)); 36 p.Add ("zombiekills", new JSONNumber (current.Value.KilledZombies)); 37 p.Add ("playerkills", new JSONNumber (current.Value.KilledPlayers)); 38 p.Add ("playerdeaths", new JSONNumber (current.Value.Died)); 39 p.Add ("score", new JSONNumber (current.Value.Score)); 33 40 34 41 players.Add(p);
Note:
See TracChangeset
for help on using the changeset viewer.