DayZ 1.30
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 = g_Game.ServerConfigGetInt("adminLogPlayerHitsOnly"); // 1 - log player hits only / 0 - log all hits ( animals/infected )
45 m_PlacementFilter = g_Game.ServerConfigGetInt("adminLogPlacement"); // 1 - log placement ( traps, tents )
46 m_ActionsFilter = g_Game.ServerConfigGetInt("adminLogBuildActions"); // 1 - log basebuilding actions ( build, dismantle, destroy )
47 m_PlayerListFilter = g_Game.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 g_Game.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 if (source.IsTransport())
174 {
175 string vehicle = source.GetType();
176 Transport transport = Transport.Cast(source);
177 Human driver = transport.CrewDriver();
178 playerSource = PlayerBase.Cast(driver);
179 if (playerSource)
180 playerPrefix2 = GetPlayerPrefix( playerSource , playerSource.GetIdentity() );
181 else
182 playerPrefix2 = "NO DRIVER";
183
184 LogPrint( playerPrefix + " killed by " + playerPrefix2 + " (" + vehicle + ")" );
185 }
186 else
187 {
188 if (playerSource)
189 {
190 //fists
191 LogPrint( playerPrefix + " killed by " + playerPrefix2 + " with (MeleeFist)" );
192 }
193 else
194 {
195 //rest, Animals, Zombies
196 LogPrint( playerPrefix + " killed by " + source.GetType());
197 }
198
199 }
200 }
201
203 {
204 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
205 LogPrint( playerPrefix + " has drowned while unconscious" );
206 }
207
209 {
210 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
211 LogPrint( playerPrefix + " is choosing to respawn" );
212 }
213
215 {
216 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
217 if (player.IsUnconscious())
218 LogPrint( playerPrefix + " is disconnecting while being unconscious" );
219 else if (player.IsRestrained())
220 LogPrint( playerPrefix + " is disconnecting while being restrained" );
221 }
222
223 void PlayerHitBy( TotalDamageResult damageResult, int damageType, PlayerBase player, EntityAI source, int component, string dmgZone, string ammo ) // PlayerBase.c
224 {
225 if ( player && source )
226 {
227 string playerPrefix = GetPlayerPrefix( player , player.GetIdentity() ) + "[HP: " + player.GetHealth().ToString() + "]";
228 string playerPrefix2;
229 m_HitMessage = GetHitMessage( damageResult, component, dmgZone, ammo );
230 PlayerBase playerSource;
231
232 if ( source.IsPlayer() )// Fists
233 playerSource = PlayerBase.Cast( source );
234 else
235 playerSource = PlayerBase.Cast( source.GetHierarchyParent() );
236
237 if (playerSource)
238 playerPrefix2 = GetPlayerPrefix( playerSource , playerSource.GetIdentity() );
239
240 switch ( damageType )
241 {
242 case DamageType.CLOSE_COMBAT: // Player melee, animals, infected
243
244 if (source.IsZombie() || source.IsAnimal()) // Infected & Animals
245 {
246 if (m_HitFilter == 1)
247 break;
248
249 m_DisplayName = source.GetDisplayName();
250
251 LogPrint( playerPrefix + " hit by " + m_DisplayName + m_HitMessage );
252 }
253 else if (source.IsPlayer())// Fists
254 {
255 LogPrint( playerPrefix + " hit by " + playerPrefix2 + m_HitMessage );
256 }
257 else if ( playerSource && (source.IsMeleeWeapon() || source.IsWeapon())) // Melee weapons
258 {
259 m_ItemInHands = source.GetDisplayName();
260
261 LogPrint( playerPrefix + " hit by " + playerPrefix2 + m_HitMessage + " with " + m_ItemInHands );
262 }
263 else
264 {
265 m_DisplayName = source.GetType();
266
267 LogPrint( playerPrefix + " hit by " + m_DisplayName + m_HitMessage );
268 }
269 break;
270
271 case DamageType.FIRE_ARM: // Player ranged
272
273 if ( source.IsWeapon() && playerSource )
274 {
275 m_ItemInHands = source.GetDisplayName();
276 m_Distance = vector.Distance( player.GetPosition(), playerSource.GetPosition() );
277
278 LogPrint( playerPrefix + " hit by " + playerPrefix2 + m_HitMessage + " with " + m_ItemInHands + " from " + m_Distance + " meters ");
279 }
280 else
281 {
282 m_DisplayName = source.GetType();
283
284 LogPrint( playerPrefix + " hit by " + m_DisplayName + m_HitMessage );
285 }
286 break;
287
288 case DamageType.EXPLOSION: // Explosion
289
290 LogPrint( playerPrefix + " hit by explosion (" + ammo + ")" );
291 break;
292
293 case DamageType.STUN: // unused atm
294
295 LogPrint( playerPrefix + " stunned by " + ammo );
296 break;
297
298 case DamageType.CUSTOM: // Others (Vehicle hit, fall, fireplace, barbed wire ...)
299 float globalHealthDamage = damageResult.GetDamage("", "Health");
300 if (ammo == DayZPlayerImplementFallDamage.FALL_DAMAGE_AMMO_HEALTH || ammo == DayZPlayerImplementFallDamage.FALL_DAMAGE_AMMO_SHOCK || ammo == DayZPlayerImplementFallDamage.FALL_DAMAGE_AMMO_HEALTH_OTHER_ATTACHMENTS)
301 {
302 if (globalHealthDamage > 0.0)
303 LogPrint(playerPrefix + " hit by " + ammo);
304 }
305 else if ( source.GetType() == "AreaDamageManager" )
306 {
307 EntityAI parent = EntityAI.Cast( source );
308 if ( parent )
309 {
310 LogPrint( playerPrefix + " hit by " + parent.GetType() + " with " + ammo );
311 }
312 }
313 else if (source.IsTransport())
314 {
315 string vehicle = source.GetType();
316 Transport transport = Transport.Cast(source);
317 Human driver = transport.CrewDriver();
318 playerSource = PlayerBase.Cast(driver);
319 if (playerSource)
320 playerPrefix2 = GetPlayerPrefix( playerSource , playerSource.GetIdentity() );
321 else
322 playerPrefix2 = "NO DRIVER";
323
324 LogPrint( playerPrefix + " hit by " + playerPrefix2 + " with " + ammo + " (" + vehicle + ")" );
325 }
326 else
327 {
328 m_DisplayName = source.GetType();
329
330 LogPrint( playerPrefix + " hit by " + m_DisplayName + " with " + ammo );
331 }
332 break;
333
334 default:
335
336 LogPrint("DEBUG: PlayerHitBy() unknown damageType: " + ammo );
337 break;
338 }
339 }
340 else
341 {
342 LogPrint("DEBUG: player/source does not exist");
343 }
344 }
345
346 void UnconStart( PlayerBase player ) // PlayerBase.c
347 {
348 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
349
350 LogPrint( m_PlayerPrefix + " is unconscious" );
351 }
352
353 void UnconStop( PlayerBase player ) // PlayerBase.c
354 {
355 if ( player.IsAlive() ) // Do not log uncon stop for dead players
356 {
357 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
358
359 LogPrint( m_PlayerPrefix + " regained consciousness" );
360 }
361 }
362
363 void OnPlacementComplete( Man player, ItemBase item ) // ItemBase.c
364 {
365 if ( m_PlacementFilter == 1 )
366 {
367 m_Source = PlayerBase.Cast( player );
368 m_PlayerPrefix = GetPlayerPrefix( m_Source , m_Source.GetIdentity() );
369 m_DisplayName = item.GetDisplayName();
370
371 if ( m_DisplayName == "" )
372 {
373 LogPrint( m_PlayerPrefix + " placed Nameless Object" + "<" + item.GetType() + ">" );
374 }
375 else
376 {
377 LogPrint( m_PlayerPrefix + " placed " + m_DisplayName + "<" + item.GetType() + ">");
378 }
379 }
380 }
381
382 void OnContinouousAction( ActionData action_data ) // ActionContinouousBase.c
383 {
384 if ( m_ActionsFilter == 1 )
385 {
386 m_Message = action_data.m_Action.GetAdminLogMessage(action_data);
387
388 if(m_Message == "")
389 return;
390
391 m_PlayerPrefix = GetPlayerPrefix( action_data.m_Player , action_data.m_Player.GetIdentity() );
392
394 }
395 }
396
397 void OnEmote(PlayerBase player, EmoteBase emote)
398 {
399 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
400
401 ItemBase item = player.GetItemInHands();
402 if (item)
403 LogPrint(m_PlayerPrefix + " performed " + emote.GetInputActionName() + " with " + item.GetType());
404 else
405 LogPrint(m_PlayerPrefix + " performed " + emote.GetInputActionName());
406 }
407
408 void Suicide( PlayerBase player ) // EmoteManager.c
409 {
410 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
411
412 LogPrint( m_PlayerPrefix + " committed suicide" );
413 }
414
415 void BleedingOut( PlayerBase player ) // Bleeding.c
416 {
417 m_PlayerPrefix = GetPlayerPrefix( player , player.GetIdentity() );
418
419 LogPrint( m_PlayerPrefix + " bled out" );
420 }
421
422 //"top" == 'true' for flag all the way at the top, 'false' for all the way at the bottom
423 void TotemFlagChange(bool top, notnull PlayerBase player, notnull EntityAI totem)
424 {
425 if (m_ActionsFilter !=1)
426 return;
427
428 string prefix = GetPlayerPrefix(player, player.GetIdentity());
429 string flagType = totem.FindAttachmentBySlotName("Material_FPole_Flag").ClassName();
430 string action;
431
432 if (top)
433 action = "raised ";
434 else
435 action = "lowered ";
436
437 LogPrint( prefix + " has " + action + flagType + " on " + totem.ClassName() + " at " + totem.GetPosition());
438 }
439
441 {
442 g_Game.GetPlayers( m_PlayerArray );
443
444 if ( m_PlayerArray.Count() != 0 )
445 {
446 LogPrint( "##### PlayerList log: " + m_PlayerArray.Count().ToString() + " players" );
447
448 foreach ( Man player: m_PlayerArray )
449 {
450 m_Player = PlayerBase.Cast(player);
451 m_PlayerPrefix = GetPlayerPrefix( m_Player , m_Player.GetIdentity() );
452
454 }
455
456 LogPrint( "#####" );
457 }
458 }
459
460 void PlayerTeleportedLog(notnull PlayerBase player, vector startPos, vector targetPos, string reason)
461 {
462 m_PlayerPrefix = GetPlayerPrefix(player, player.GetIdentity());
463
464 LogPrint(m_PlayerPrefix + " was teleported from: " + startPos.ToString() + " to: " + targetPos.ToString() + ". Reason: " + reason);
465 }
466
467 void DirectAdminLogPrint(string str)
468 {
469 LogPrint(str);
470 }
471}
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:4074
void DayZPlayerImplementFallDamage(DayZPlayer pPlayer)
Определения DayZPlayerImplementFallDamage.c:73
void ExplosivesBase()
Определения ExplosivesBase.c:45
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
void PlayerStat(T min, T max, T init, string label, int flags)
Определения PlayerStatBase.c:43
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionBase m_Action
Определения ActionBase.c:34
Определения ActionBase.c:22
string GetInputActionName()
Определения EmoteBase.c:70
Определения EmoteBase.c:2
override bool IsMeleeWeapon()
Определения human.c:1360
Определения 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:382
int m_DotIndex
Определения PluginAdminLog.c:16
void Suicide(PlayerBase player)
Определения PluginAdminLog.c:408
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:346
void PlayerHitBy(TotalDamageResult damageResult, int damageType, PlayerBase player, EntityAI source, int component, string dmgZone, string ammo)
Определения PluginAdminLog.c:223
string m_DisplayName
Определения PluginAdminLog.c:9
void BleedingOut(PlayerBase player)
Определения PluginAdminLog.c:415
void OnPlacementComplete(Man player, ItemBase item)
Определения PluginAdminLog.c:363
string m_PlayerName
Определения PluginAdminLog.c:3
void DirectAdminLogPrint(string str)
Определения PluginAdminLog.c:467
void PlayerKilledByDrowningUncon(PlayerBase player)
Определения PluginAdminLog.c:202
void PlayerList()
Определения PluginAdminLog.c:440
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:214
void UnconStop(PlayerBase player)
Определения PluginAdminLog.c:353
void PlayerKilledByRespawn(PlayerBase player)
Определения PluginAdminLog.c:208
void TotemFlagChange(bool top, notnull PlayerBase player, notnull EntityAI totem)
Определения PluginAdminLog.c:423
string GetPlayerPrefix(PlayerBase player, PlayerIdentity identity)
Определения PluginAdminLog.c:67
void PlayerTeleportedLog(notnull PlayerBase player, vector startPos, vector targetPos, string reason)
Определения PluginAdminLog.c:460
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:397
static int GetPlayerListTimer()
Определения PluginAdminLog.c:30
Plugin interface for controlling of agent pool system.
Определения PluginBase.c:2
Определения DayZPlayerImplement.c:39
proto native float GetDamage(string zoneName, string healthType)
proto native float GetHighestDamage(string healthType)
Определения DamageSystem.c:2
Native class for boats - handles physics simulation.
Определения Boat.c:29
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:119