Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
pluginremoteplayerdebugserver.c
Go to the documentation of this file.
1 class PluginRemotePlayerDebugServer extends PluginBase
2 {
3  ref set<PlayerBase> m_ClientList = new set<PlayerBase>;
4 
7  float m_AccuTime;
8  const int INTERVAL = 1;
9 
11  bool m_Watching;
12 
13  override void OnUpdate(float delta_time)
14  {
15  #ifdef SERVER
16  if ( m_ClientList.Count() != 0 )
17  {
18  m_AccuTime += delta_time;
19 
20  if ( m_AccuTime > INTERVAL )
21  {
22  m_AccuTime = 0;
23  SendDebug();
24  }
25  }
26  #endif
27  }
28 
29  void SetWatching(bool enable)
30  {
31  m_Watching = enable;
32  }
33 
34  bool GetWatching()
35  {
36  return m_Watching;
37  }
38 
39  void GatherPlayerInfo()
40  {
41  array<Man> players = new array<Man>;
42  GetGame().GetPlayers(players);
43  m_PlayerDebugStats.Clear();
44 
45  foreach (Man playerMan : players)
46  {
47  PlayerBase player = PlayerBase.Cast(playerMan);
49  m_PlayerDebugStats.Insert(rpd);
50  }
51  }
52 
53  void SendDebug()
54  {
55 #ifdef DIAG_DEVELOPER
56  GatherPlayerInfo();
58 
59  for(int i = 0; i < m_ClientList.Count(); ++i)
60  {
61  PlayerBase player = m_ClientList[i];
62  if (player)
63  {
64  ScriptRPC rpc = new ScriptRPC();
65  rpc.Write(m_PlayerDebugStats);
66 
67  foreach (PlayerBase player2, RemotePlayerDamageDebug value : m_PlayerDebugDamage)
68  {
69  if (player2)
70  {
71  player_damage.Insert(value);
72 
73  }
74  //int xs = 1 + 1;
75  }
76 
77  rpc.Write(player_damage);
78 
79  rpc.Send(player, ERPCs.DEV_PLAYER_DEBUG_DATA, true, player.GetIdentity());
80  m_PlayerDebugDamage.Clear();
81  }
82  else
83  {
84  m_ClientList.Remove(i);
85  --i;
86  }
87  }
88 #endif
89  }
90 
91 
92  void OnDamageEvent(PlayerBase player, TotalDamageResult damageResult)
93  {
94  if ( !GetWatching() || !damageResult )
95  return;
96 
97  float damage_global = damageResult.GetDamage("","");
98  float damage_blood = damageResult.GetDamage("","Blood");
99  float damage_shock = damageResult.GetDamage("","Shock");
100 
101  if ( m_PlayerDebugDamage.Contains(player) )
102  {
103  m_PlayerDebugDamage.Get(player).AddDamage( damage_global, damage_blood, damage_shock );
104  }
105  else
106  {
108  rpdd.AddDamage(damage_global, damage_blood, damage_shock);
109  m_PlayerDebugDamage.Insert(player, rpdd);
110  }
111  }
112 
113 
114  void OnRequestReceived(PlayerBase player, bool enable)
115  {
116  int index = m_ClientList.Find(player);
117 
118  if (enable)
119  {
120  m_ClientList.Insert(player);
121  SetWatching(true);
122  }
123  else if (index != -1 && m_ClientList.Count() != 0)
124  {
125  m_ClientList.Remove(index);
126  }
127 
128  if ( m_ClientList.Count() == 0 )
129  {
130  SetWatching(false);
131  }
132  }
133 
134  void OnRPC(ParamsReadContext ctx, PlayerBase player)
135  {
136  bool enable;
137  ctx.Read(enable);
138  OnRequestReceived(player, enable);
139  }
140 }
GetGame
proto native CGame GetGame()
PluginBase
Definition: pluginadminlog.c:1
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
OnRPC
void OnRPC(ParamsReadContext ctx)
Definition: displaystatus.c:216
m_PlayerDebugDamage
ref map< PlayerBase, ref RemotePlayerDamageDebug > m_PlayerDebugDamage
Definition: pluginremoteplayerdebugclient.c:12
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
RemotePlayerDamageDebug
Definition: remoteplayerdamagedebug.c:1
TotalDamageResult
Definition: damagesystem.c:1
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
ScriptRPC
Definition: gameplay.c:104
eRemoteDebugType
eRemoteDebugType
Definition: pluginremoteplayerdebugclient.c:1
m_DebugType
eRemoteDebugType m_DebugType
Definition: pluginremoteplayerdebugclient.c:19
array< ref RemotePlayerStatDebug >
ERPCs
ERPCs
Definition: erpcs.c:1
RemotePlayerStatDebug
void RemotePlayerStatDebug(PlayerBase player)
Definition: remoteplayerstatdebug.c:16
m_PlayerDebugStats
ref array< ref RemotePlayerStatDebug > m_PlayerDebugStats
Definition: pluginremoteplayerdebugclient.c:11