DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginAdminLog.c
См. документацию.
1class PluginAdminLog extends PluginBase // Class for admin log messages handled by script
2{
4 string m_Pid;
8 string m_Message;
15 string m_PosArray[3];
19 BleedingSourcesManagerServer m_BleedMgr;
20 // filters
21 protected int m_HitFilter;
22 protected int m_PlacementFilter;
23 protected int m_ActionsFilter;
24 protected int m_PlayerListFilter;
25
29
30 static int GetPlayerListTimer()
31 {
32 return 300; // seconds
33 }
34
35 /*
36 EXE side ADM log messages (not removable):
37 Connect / Disconnect
38 Chat
39 Player->Admin report (ingame chat: #toadmin <text>)
40 */
41
43 {
44 m_HitFilter = GetGame().ServerConfigGetInt("adminLogPlayerHitsOnly"); // 1 - log player hits only / 0 - log all hits ( animals/infected )
45 m_PlacementFilter = GetGame().ServerConfigGetInt("adminLogPlacement"); // 1 - log placement ( traps, tents )
46 m_ActionsFilter = GetGame().ServerConfigGetInt("adminLogBuildActions"); // 1 - log basebuilding actions ( build, dismantle, destroy )
47 m_PlayerListFilter = GetGame().ServerConfigGetInt("adminLogPlayerList"); // 1 - log periodic player list with position every 5 minutes
48
50
51 if ( m_PlayerListFilter == 1 )
52 {
53 m_Timer = new Timer();
54 m_Timer.Run( TIMER_PLAYERLIST , this, "PlayerList", NULL, true );
55 }
56 }
57
59 {
60 }
61
62 void LogPrint( string message )
63 {
64 GetGame().AdminLog( message );
65 }
66
67 string GetPlayerPrefix( PlayerBase player, PlayerIdentity identity ) // player name + id + position prefix for log prints
68 {
69
70 m_Position = player.GetPosition();
71 m_PosArray[3] = { m_Position[0].ToString(), m_Position[2].ToString(), m_Position[1].ToString() };
72
73 for ( int i = 0; i < 3; i++ ) // trim position precision
74 {
75 m_DotIndex = m_PosArray[i].IndexOf(".");
76 if ( m_DotIndex != -1 )
77 {
78 m_PosArray[i] = m_PosArray[i].Substring( 0, m_DotIndex + 2 );
79 }
80 }
81
82 if ( identity ) // return partial message even if it fails to fetch identity
83 {
84 //return "Player \"" + "Unknown/Dead Entity" + "\" (id=" + "Unknown" + " pos=<" + m_PosArray[0] + ", " + m_PosArray[1] + ", " + m_PosArray[2] + ">)";
85 m_PlayerName = "\"" + identity.GetName() + "\"";
86 m_Pid = identity.GetId();
87 }
88 else
89 {
90 m_PlayerName = "\"" + player.GetCachedName() + "\"";
91 m_Pid = player.GetCachedID();
92 }
93
94
95 if ( !player.IsAlive() )
96 {
97 m_PlayerName = m_PlayerName + " (DEAD)";
98 }
99
100 return "Player " + m_PlayerName + " (id=" + m_Pid + " pos=<" + m_PosArray[0] + ", " + m_PosArray[1] + ", " + m_PosArray[2] + ">)";
101 }
102
103 string GetHitMessage( TotalDamageResult damageResult, int component, string zone, string ammo)
104 {
105 if ( damageResult )
106 {
107 float dmg = damageResult.GetHighestDamage("Health");
108 return " into " + zone + "(" + component.ToString() + ") for " + dmg.ToString() + " damage (" + ammo + ")";
109 }
110 else // block
111 {
112 return " into Block" + "(" + component.ToString() + ") for 0 damage ";
113 }
114 }
115
116 void PlayerKilled( PlayerBase player, Object source ) // PlayerBase.c
117 {
118 if (!player || !source)
119 {
120 LogPrint("DEBUG: PlayerKilled() player/source does not exist");
121 return;
122 }
123
124 PlayerBase playerSource = PlayerBase.Cast( EntityAI.Cast( source ).GetHierarchyParent() );
125 if (!playerSource)
126 {
127 playerSource = PlayerBase.Cast( source );
128 }
129
130 string playerPrefix, playerPrefix2;
131 if (playerSource)
132 {
133 playerPrefix2 = GetPlayerPrefix( playerSource , playerSource.GetIdentity() );
134 }
135
136 playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
137 if (player == source) // deaths not caused by another object (starvation, dehydration)
138 {
139 m_StatWater = player.GetStatWater();
140 m_StatEnergy = player.GetStatEnergy();
141 m_BleedMgr = player.GetBleedingManagerServer();
142
143 string reason = " died.";
144 if (player.GetDrowningWaterLevelCheck())
145 reason = " drowned.";
146
147 string additionalStats;
149 additionalStats = " Stats> Water: " + m_StatWater.Get().ToString() + " Energy: " + m_StatEnergy.Get().ToString();
150
151 if (m_BleedMgr)
152 additionalStats = additionalStats + " Bleed sources: " + m_BleedMgr.GetBleedingSourcesCount().ToString();
153
154 LogPrint(playerPrefix + reason + additionalStats);
155
156 }
157 else if (source.IsWeapon() || source.IsMeleeWeapon()) // player
158 {
159 if (ExplosivesBase.Cast(source))
160 {
161 LogPrint( playerPrefix + " killed by " + source.GetDisplayName() );
162 }
163 else if (source.IsMeleeWeapon())
164 {
165 LogPrint( playerPrefix + " killed by " + playerPrefix2 + " with " + source.GetDisplayName() );
166 }
167 else
168 {
169 m_Distance = vector.Distance( player.GetPosition(), playerSource.GetPosition() );
170 LogPrint( playerPrefix + " killed by " + playerPrefix2 + " with " + source.GetDisplayName() + " from " + m_Distance + " meters " );
171 }
172 }
173 else
174 {
175 if (playerSource)
176 {
177 //fists
178 LogPrint( playerPrefix + " killed by " + playerPrefix2 + " with (MeleeFist)" );
179 }
180 else
181 {
182 //rest, Animals, Zombies
183 LogPrint( playerPrefix + " killed by " + source.GetType());
184 }
185
186 }
187 }
188
190 {
191 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
192 LogPrint( playerPrefix + " has drowned while unconscious" );
193 }
194
196 {
197 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
198 LogPrint( playerPrefix + " is choosing to respawn" );
199 }
200
202 {
203 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
204 if (player.IsUnconscious())
205 LogPrint( playerPrefix + " is disconnecting while being unconscious" );
206 else if (player.IsRestrained())
207 LogPrint( playerPrefix + " is disconnecting while being restrained" );
208 }
209
210 void PlayerHitBy( TotalDamageResult damageResult, int damageType, PlayerBase player, EntityAI source, int component, string dmgZone, string ammo ) // PlayerBase.c
211 {
212 if ( player && source )
213 {
214 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() ) + "[HP: " + player.GetHealth().ToString() + "]";
215 string playerPrefix2;
216 m_HitMessage = GetHitMessage( damageResult, component, dmgZone, ammo );
217 PlayerBase playerSource;
218
219 if ( source.IsPlayer() )// Fists
220 playerSource = PlayerBase.Cast( source );
221 else
222 playerSource = PlayerBase.Cast( source.GetHierarchyParent() );
223
224 if (playerSource)
225 playerPrefix2 = GetPlayerPrefix( playerSource , playerSource.GetIdentity() );
226
227 switch ( damageType )
228 {
229 case DamageType.CLOSE_COMBAT: // Player melee, animals, infected
230
231 if (source.IsZombie() || source.IsAnimal()) // Infected & Animals
232 {
233 if (m_HitFilter == 1)
234 break;
235
236 m_DisplayName = source.GetDisplayName();
237
238 LogPrint( playerPrefix + " hit by " + m_DisplayName + m_HitMessage );
239 }
240 else if (source.IsPlayer())// Fists
241 {
242 LogPrint( playerPrefix + " hit by " + playerPrefix2 + m_HitMessage );
243 }
244 else if ( playerSource && (source.IsMeleeWeapon() || source.IsWeapon())) // Melee weapons
245 {
246 m_ItemInHands = source.GetDisplayName();
247
248 LogPrint( playerPrefix + " hit by " + playerPrefix2 + m_HitMessage + " with " + m_ItemInHands );
249 }
250 else
251 {
252 m_DisplayName = source.GetType();
253
254 LogPrint( playerPrefix + " hit by " + m_DisplayName + m_HitMessage );
255 }
256 break;
257
258 case DamageType.FIRE_ARM: // Player ranged
259
260 if ( source.IsWeapon() && playerSource )
261 {
262 m_ItemInHands = source.GetDisplayName();
263 m_Distance = vector.Distance( player.GetPosition(), playerSource.GetPosition() );
264
265 LogPrint( playerPrefix + " hit by " + playerPrefix2 + m_HitMessage + " with " + m_ItemInHands + " from " + m_Distance + " meters ");
266 }
267 else
268 {
269 m_DisplayName = source.GetType();
270
271 LogPrint( playerPrefix + " hit by " + m_DisplayName + m_HitMessage );
272 }
273 break;
274
275 case DamageType.EXPLOSION: // Explosion
276
277 LogPrint( playerPrefix + " hit by explosion (" + ammo + ")" );
278 break;
279
280 case DamageType.STUN: // unused atm
281
282 LogPrint( playerPrefix + " stunned by " + ammo );
283 break;
284
285 case DamageType.CUSTOM: // Others (Vehicle hit, fall, fireplace, barbed wire ...)
286 float globalHealthDamage = damageResult.GetDamage("", "Health");
287 if (ammo == DayZPlayerImplementFallDamage.FALL_DAMAGE_AMMO_HEALTH || ammo == DayZPlayerImplementFallDamage.FALL_DAMAGE_AMMO_SHOCK || ammo == DayZPlayerImplementFallDamage.FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS)
288 {
289 if (globalHealthDamage > 0.0)
290 LogPrint(playerPrefix + " hit by " + ammo);
291 }
292 else if ( source.GetType() == "AreaDamageManager" )
293 {
294 EntityAI parent = EntityAI.Cast( source );
295 if ( parent )
296 {
297 LogPrint( playerPrefix + " hit by " + parent.GetType() + " with " + ammo );
298 }
299 }
300 else
301 {
302 m_DisplayName = source.GetType();
303
304 LogPrint( playerPrefix + " hit by " + m_DisplayName + " with " + ammo );
305 }
306 break;
307
308 default:
309
310 LogPrint("DEBUG: PlayerHitBy() unknown damageType: " + ammo );
311 break;
312 }
313 }
314 else
315 {
316 LogPrint("DEBUG: player/source does not exist");
317 }
318 }
319
320 void UnconStart( PlayerBase player ) // PlayerBase.c
321 {
322 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
323
324 LogPrint( m_PlayerPrefix + " is unconscious" );
325 }
326
327 void UnconStop( PlayerBase player ) // PlayerBase.c
328 {
329 if ( player.IsAlive() ) // Do not log uncon stop for dead players
330 {
331 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
332
333 LogPrint( m_PlayerPrefix + " regained consciousness" );
334 }
335 }
336
337 void OnPlacementComplete( Man player, ItemBase item ) // ItemBase.c
338 {
339 if ( m_PlacementFilter == 1 )
340 {
341 m_Source = PlayerBase.Cast( player );
342 m_PlayerPrefix = GetPlayerPrefix( m_Source , m_Source.GetIdentity() );
343 m_DisplayName = item.GetDisplayName();
344
345 if ( m_DisplayName == "" )
346 {
347 LogPrint( m_PlayerPrefix + " placed Nameless Object" + "<" + item.GetType() + ">" );
348 }
349 else
350 {
351 LogPrint( m_PlayerPrefix + " placed " + m_DisplayName + "<" + item.GetType() + ">");
352 }
353 }
354 }
355
356 void OnContinouousAction( ActionData action_data ) // ActionContinouousBase.c
357 {
358 if ( m_ActionsFilter == 1 )
359 {
360 m_Message = action_data.m_Action.GetAdminLogMessage(action_data);
361
362 if(m_Message == "")
363 return;
364
365 m_PlayerPrefix = GetPlayerPrefix( action_data.m_Player , action_data.m_Player.GetIdentity() );
366
368 }
369 }
370
371 void OnEmote(PlayerBase player, EmoteBase emote)
372 {
373 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
374
375 ItemBase item = player.GetItemInHands();
376 if (item)
377 LogPrint(m_PlayerPrefix + " performed " + emote.GetInputActionName() + " with " + item.GetType());
378 else
379 LogPrint(m_PlayerPrefix + " performed " + emote.GetInputActionName());
380 }
381
382 void Suicide( PlayerBase player ) // EmoteManager.c
383 {
384 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
385
386 LogPrint( m_PlayerPrefix + " committed suicide" );
387 }
388
389 void BleedingOut( PlayerBase player ) // Bleeding.c
390 {
391 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
392
393 LogPrint( m_PlayerPrefix + " bled out" );
394 }
395
396 //"top" == 'true' for flag all the way at the top, 'false' for all the way at the bottom
397 void TotemFlagChange(bool top, notnull PlayerBase player, notnull EntityAI totem)
398 {
399 if (m_ActionsFilter !=1)
400 return;
401
402 string prefix = GetPlayerPrefix(player, player.GetIdentity());
403 string flagType = totem.FindAttachmentBySlotName("Material_FPole_Flag").ClassName();
404 string action;
405
406 if (top)
407 action = "raised ";
408 else
409 action = "lowered ";
410
411 LogPrint( prefix + " has " + action + flagType + " on " + totem.ClassName() + " at " + totem.GetPosition());
412 }
413
415 {
417
418 if ( m_PlayerArray.Count() != 0 )
419 {
420 LogPrint( "##### PlayerList log: " + m_PlayerArray.Count().ToString() + " players" );
421
422 foreach ( Man player: m_PlayerArray )
423 {
424 m_Player = PlayerBase.Cast(player);
425 m_PlayerPrefix = GetPlayerPrefix( m_Player , m_Player.GetIdentity() );
426
428 }
429
430 LogPrint( "#####" );
431 }
432 }
433
434 void PlayerTeleportedLog(notnull PlayerBase player, vector startPos, vector targetPos, string reason)
435 {
436 m_PlayerPrefix = GetPlayerPrefix(player, player.GetIdentity());
437
438 LogPrint(m_PlayerPrefix + " was teleported from: " + startPos.ToString() + " to: " + targetPos.ToString() + ". Reason: " + reason);
439 }
440
441 void DirectAdminLogPrint(string str)
442 {
443 LogPrint(str);
444 }
445}
ActionBase ActionData
Определения ActionBase.c:30
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
void DayZPlayerImplementFallDamage(DayZPlayer pPlayer)
Определения DayZPlayerImplementFallDamage.c:73
void ExplosivesBase()
Определения ExplosivesBase.c:42
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
void PlayerStat(T min, T max, T init, string label, int flags)
Определения PlayerStatBase.c:43
proto native void GetPlayers(out array< Man > players)
proto native void AdminLog(string text)
proto native int ServerConfigGetInt(string name)
Server config parsing. Returns 0 if not found.
string GetInputActionName()
Определения EmoteBase.c:70
Определения EmoteBase.c:2
override bool IsMeleeWeapon()
Определения InventoryItem.c:81
Определения Building.c:6
Определения InventoryItem.c:731
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
proto string GetName()
nick (short) name of player
proto string GetId()
unique id of player (hashed steamID, database Xbox id...) can be used in database or logs
The class that will be instanced (moddable)
Определения gameplay.c:389
string m_PlayerPrefix2
Определения PluginAdminLog.c:7
void PlayerKilled(PlayerBase player, Object source)
Определения PluginAdminLog.c:116
void OnContinouousAction(ActionData action_data)
Определения PluginAdminLog.c:356
int m_DotIndex
Определения PluginAdminLog.c:16
void Suicide(PlayerBase player)
Определения PluginAdminLog.c:382
BleedingSourcesManagerServer m_BleedMgr
Определения PluginAdminLog.c:19
string m_Message
Определения PluginAdminLog.c:8
vector m_Position
Определения PluginAdminLog.c:5
int m_PlayerListFilter
Определения PluginAdminLog.c:24
void LogPrint(string message)
Определения PluginAdminLog.c:62
string m_PosArray[3]
Определения PluginAdminLog.c:15
int m_ActionsFilter
Определения PluginAdminLog.c:23
autoptr array< Man > m_PlayerArray
Определения PluginAdminLog.c:27
string m_Pid
Определения PluginAdminLog.c:4
void ~PluginAdminLog()
Определения PluginAdminLog.c:58
int m_PlacementFilter
Определения PluginAdminLog.c:22
const int TIMER_PLAYERLIST
Определения PluginAdminLog.c:28
void UnconStart(PlayerBase player)
Определения PluginAdminLog.c:320
void PlayerHitBy(TotalDamageResult damageResult, int damageType, PlayerBase player, EntityAI source, int component, string dmgZone, string ammo)
Определения PluginAdminLog.c:210
string m_DisplayName
Определения PluginAdminLog.c:9
void BleedingOut(PlayerBase player)
Определения PluginAdminLog.c:389
void OnPlacementComplete(Man player, ItemBase item)
Определения PluginAdminLog.c:337
string m_PlayerName
Определения PluginAdminLog.c:3
void DirectAdminLogPrint(string str)
Определения PluginAdminLog.c:441
void PlayerKilledByDrowningUncon(PlayerBase player)
Определения PluginAdminLog.c:189
void PlayerList()
Определения PluginAdminLog.c:414
ref Timer m_Timer
Определения PluginAdminLog.c:26
PlayerBase m_Source
Определения PluginAdminLog.c:13
PlayerStat< float > m_StatWater
Определения PluginAdminLog.c:17
void PlayerKilledByDisconnect(PlayerBase player)
Определения PluginAdminLog.c:201
void UnconStop(PlayerBase player)
Определения PluginAdminLog.c:327
void PlayerKilledByRespawn(PlayerBase player)
Определения PluginAdminLog.c:195
void TotemFlagChange(bool top, notnull PlayerBase player, notnull EntityAI totem)
Определения PluginAdminLog.c:397
string GetPlayerPrefix(PlayerBase player, PlayerIdentity identity)
Определения PluginAdminLog.c:67
void PlayerTeleportedLog(notnull PlayerBase player, vector startPos, vector targetPos, string reason)
Определения PluginAdminLog.c:434
PlayerBase m_Player
Определения PluginAdminLog.c:12
string m_HitMessage
Определения PluginAdminLog.c:10
PlayerStat< float > m_StatEnergy
Определения PluginAdminLog.c:18
string m_ItemInHands
Определения PluginAdminLog.c:14
void PluginAdminLog()
Определения PluginAdminLog.c:42
string GetHitMessage(TotalDamageResult damageResult, int component, string zone, string ammo)
Определения PluginAdminLog.c:103
float m_Distance
Определения PluginAdminLog.c:11
string m_PlayerPrefix
Определения PluginAdminLog.c:6
int m_HitFilter
Определения PluginAdminLog.c:21
void OnEmote(PlayerBase player, EmoteBase emote)
Определения PluginAdminLog.c:371
static int GetPlayerListTimer()
Определения PluginAdminLog.c:30
Определения PluginBase.c:2
Определения DayZPlayerImplement.c:63
proto native float GetDamage(string zoneName, string healthType)
proto native float GetHighestDamage(string healthType)
Определения DamageSystem.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
proto string ToString(bool beautify=true)
Vector to string.
Определения EnConvert.c:106
proto native CGame GetGame()