Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
missionserver.c
Go to the documentation of this file.
1 //: string uid of the player
4 
5 class MissionServer extends MissionBase
6 {
7  ref array<Man> m_Players;
8  ref array<ref CorpseData> m_DeadPlayersArray;
9  ref map<PlayerBase, ref LogoutInfo> m_LogoutPlayers;
10  ref map<PlayerBase, ref LogoutInfo> m_NewLogoutPlayers;
11  ref RainProcurementHandler m_RainProcHandler;
12  const int SCHEDULER_PLAYERS_PER_TICK = 5;
13  int m_currentPlayer;
14  int m_RespawnMode;
15 
16  // -----------------------
17  // ARTILLERY SOUNDS SETUP
18  // -----------------------
19  private float m_ArtyBarrageTimer = 0; // This is not to be edited in Init.c this is just to increment time
20 
21  // Variables to be modified in Init.c
22  protected bool m_PlayArty = false; // Toggle if Off map artillery sounds are played
23  protected float m_ArtyDelay = 0; // Set how much time there is between two barrages (in seconds)
24  protected int m_MinSimultaneousStrikes = 0; // The MIN of simultaneous shots on the map (Will be clamped between 1 and max shots)
25  protected int m_MaxSimultaneousStrikes = 0; // The MAX of simultaneous shots on the map (Will be clamped between 1 and max amount of coords)
26  protected ref array<vector> m_FiringPos; // Where we should fire from. On Init set the relevant data
27 
28  //All Chernarus firing coordinates
29  protected const ref array<vector> CHERNARUS_STRIKE_POS =
30  {
31  "-500.00 165.00 5231.69",
32  "-500.00 300.00 9934.41",
33  "10406.86 192.00 15860.00",
34  "4811.75 370.00 15860.00",
35  "-500.00 453.00 15860.00"
36  };
37 
38  //All livonia firing coordinates
39  protected const ref array<vector> LIVONIA_STRIKE_POS =
40  {
41  "7440.00 417.00 -500.00",
42  "-500.00 276.00 5473.00",
43  "-500.00 265.00 9852.00",
44  "4953.00 240.00 13300.00",
45  "9620.00 188.00 13300.00",
46  "13300.00 204.00 10322.00",
47  "13300.00 288.00 6204.00",
48  "13300.00 296.00 -500.00"
49  };
50  // -----------------------
51  // END OF ARTILLERY SETUP
52  // -----------------------
53 
55  MissionBase m_mission;
56  PluginAdditionalInfo m_moduleDefaultCharacter;
57 
58  void MissionServer()
59  {
60  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(this.UpdatePlayersStats, 30000, true);
61 
62  m_DeadPlayersArray = new array<ref CorpseData>;
63  UpdatePlayersStats();
64  m_Players = new array<Man>;
65 
66  m_LogoutPlayers = new map<PlayerBase, ref LogoutInfo>;
67  m_NewLogoutPlayers = new map<PlayerBase, ref LogoutInfo>;
68  m_RainProcHandler = new RainProcurementHandler(this);
69  }
70 
71  void ~MissionServer()
72  {
73  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Remove(this.UpdatePlayersStats);
74  }
75 
76  override void OnInit()
77  {
78  super.OnInit();
79  CfgGameplayHandler.LoadData();
80  PlayerSpawnHandler.LoadData();
81  UndergroundAreaLoader.SpawnAllTriggerCarriers();
82  //Either pass consts in Init.c or insert all desired coords (or do both ;))
83  m_FiringPos = new array<vector>();
84  }
85 
86  override void OnMissionStart()
87  {
88  super.OnMissionStart();
89 
90  // We will load the Effect areas on Default mission start
91  EffectAreaLoader.CreateZones();
92  }
93 
94  override void OnUpdate(float timeslice)
95  {
96  UpdateDummyScheduler();
97  TickScheduler(timeslice);
98  UpdateLogoutPlayers();
99  m_WorldData.UpdateBaseEnvTemperature(timeslice); // re-calculate base enviro temperature
100  m_RainProcHandler.Update(timeslice);
101 
102  RandomArtillery(timeslice);
103 
104  super.OnUpdate(timeslice);
105  }
106 
107  override void OnGameplayDataHandlerLoad()
108  {
109  m_RespawnMode = CfgGameplayHandler.GetDisableRespawnDialog();
110  GetGame().SetDebugMonitorEnabled(GetGame().ServerConfigGetInt("enableDebugMonitor"));
111 
112  InitialiseWorldData();
113  }
114 
115 
116  void RandomArtillery(float deltaTime)
117  {
118  // ARTY barrage
119  if (m_PlayArty)
120  {
121  // We only perform timer checks and increments if we enabled the artillery barrage
122  if (m_ArtyBarrageTimer > m_ArtyDelay)
123  {
124  //We clamp to guarantee 1 and never have multiple shots on same pos, even in case of entry error
125  m_MaxSimultaneousStrikes = Math.Clamp(m_MaxSimultaneousStrikes, 1, m_FiringPos.Count());
126  m_MinSimultaneousStrikes = Math.Clamp(m_MinSimultaneousStrikes, 1, m_MaxSimultaneousStrikes);
127 
128  // Variables to be used in this scope
129  int randPos; // Select random position
130  Param1<vector> pos; // The value to be sent through RPC
131  array<ref Param> params; // The RPC params
132 
133  if (m_MaxSimultaneousStrikes == 1)
134  {
135  // We only have one set of coordinates to send
136  randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
137  pos = new Param1<vector>(m_FiringPos[randPos]);
138  params = new array<ref Param>;
139  params.Insert(pos);
140  GetGame().RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
141  }
142  else
143  {
144  //We will do some extra steps to
145  /*
146  1. Send multiple coords (Send one RPC per coord set)
147  2. Ensure we don't have duplicates
148  */
149  array<int> usedIndices = new array<int>; // Will store all previusly fired upon indices
150 
151  // We determine how many positions fire between MIN and MAX
152  int randFireNb = Math.RandomIntInclusive(m_MinSimultaneousStrikes, m_MaxSimultaneousStrikes);
153  for (int i = 0; i < randFireNb; i++)
154  {
155  randPos = Math.RandomIntInclusive(0, m_FiringPos.Count() - 1);
156 
157  if (usedIndices.Count() <= 0 || usedIndices.Find(randPos) < 0) //We do not find the index or array is empty
158  {
159  // We prepare to send the message
160  pos = new Param1<vector>(m_FiringPos[randPos]);
161  params = new array<ref Param>;
162 
163  // We send the message with this set of coords
164  params.Insert(pos);
165  GetGame().RPC(null, ERPCs.RPC_SOUND_ARTILLERY, params, true);
166 
167  // We store the last used value
168  usedIndices.Insert(randPos);
169  }
170  }
171  }
172 
173  // Reset timer for new loop
174  m_ArtyBarrageTimer = 0.0;
175  }
176 
177  m_ArtyBarrageTimer += deltaTime;
178  }
179  }
180 
181  override bool IsServer()
182  {
183  return true;
184  }
185 
186  override bool IsPlayerDisconnecting(Man player)
187  {
188  return (m_LogoutPlayers && m_LogoutPlayers.Contains(PlayerBase.Cast(player))) || (m_NewLogoutPlayers && m_NewLogoutPlayers.Contains(PlayerBase.Cast(player)));
189  }
190 
191  void UpdatePlayersStats()
192  {
193  PluginLifespan moduleLifespan;
194  Class.CastTo(moduleLifespan, GetPlugin(PluginLifespan));
195  array<Man> players = new array<Man>();
196  GetGame().GetPlayers(players);
197 
198  foreach (Man man : players)
199  {
200  PlayerBase player;
201  if (Class.CastTo(player, man))
202  {
203  player.StatUpdateByTime(AnalyticsManagerServer.STAT_PLAYTIME);
204  player.StatUpdateByPosition(AnalyticsManagerServer.STAT_DISTANCE);
205 
206  moduleLifespan.UpdateLifespan(player);
207  }
208  }
209 
210  UpdateCorpseStatesServer();
211  }
212 
213  protected void AddNewPlayerLogout(PlayerBase player, notnull LogoutInfo info)
214  {
215  m_LogoutPlayers.Insert(player, info);
216  m_NewLogoutPlayers.Remove(player);
217  }
218 
219  // check if logout finished for some players
220  void UpdateLogoutPlayers()
221  {
222  for (int i = 0; i < m_LogoutPlayers.Count();)
223  {
224  LogoutInfo info = m_LogoutPlayers.GetElement(i);
225 
226  if (GetGame().GetTime() >= info.param1)
227  {
228  PlayerIdentity identity;
229  PlayerBase player = m_LogoutPlayers.GetKey(i);
230  if (player)
231  {
232  identity = player.GetIdentity();
233  m_LogoutPlayers.Remove(player);
234  }
235  else
236  {
237  m_LogoutPlayers.RemoveElement(i);
238  }
239 
240  // disable reconnecting to old char
241  // GetGame().RemoveFromReconnectCache(info.param2);
242 
243  PlayerDisconnected(player, identity, info.param2);
244  }
245  else
246  {
247  ++i;
248  }
249  }
250  }
251 
252  override void OnEvent(EventType eventTypeId, Param params)
253  {
254  PlayerIdentity identity;
255  PlayerBase player;
256  int counter = 0;
257 
258  switch (eventTypeId)
259  {
261  ClientPrepareEventParams clientPrepareParams;
262  Class.CastTo(clientPrepareParams, params);
263  CfgGameplayHandler.SyncDataSendEx(clientPrepareParams.param1);
264  UndergroundAreaLoader.SyncDataSend(clientPrepareParams.param1);
265  OnClientPrepareEvent(clientPrepareParams.param1, clientPrepareParams.param2, clientPrepareParams.param3, clientPrepareParams.param4, clientPrepareParams.param5);
266  break;
267 
269  ClientNewEventParams newParams;
270  Class.CastTo(newParams, params);
271  player = OnClientNewEvent(newParams.param1, newParams.param2, newParams.param3);
272  if (!player)
273  {
274  Debug.Log("ClientNewEvent: Player is empty");
275  return;
276  }
277  identity = newParams.param1;
278  InvokeOnConnect(player,identity);
279  SyncEvents.SendPlayerList();
280 
281  ControlPersonalLight(player);
282  SyncGlobalLighting(player);
283 
284  break;
285 
287  ClientReadyEventParams readyParams;
288  Class.CastTo(readyParams, params);
289  identity = readyParams.param1;
290  Class.CastTo(player, readyParams.param2);
291  if (!player)
292  {
293  Debug.Log("ClientReadyEvent: Player is empty");
294  return;
295  }
296 
297  OnClientReadyEvent(identity, player);
298  InvokeOnConnect(player, identity);
299  // Send list of players at all clients
300  SyncEvents.SendPlayerList();
301  ControlPersonalLight(player);
302  SyncGlobalLighting(player);
303  break;
304 
306  ClientRespawnEventParams respawnParams;
307  Class.CastTo(respawnParams, params);
308  identity = respawnParams.param1;
309  Class.CastTo(player, respawnParams.param2);
310  if (!player)
311  {
312  Debug.Log("ClientRespawnEvent: Player is empty");
313  return;
314  }
315 
316  OnClientRespawnEvent(identity, player);
317  break;
318 
320  ClientReconnectEventParams reconnectParams;
321  Class.CastTo(reconnectParams, params);
322 
323  identity = reconnectParams.param1;
324  Class.CastTo(player, reconnectParams.param2);
325  if (!player)
326  {
327  Debug.Log("ClientReconnectEvent: Player is empty");
328  return;
329  }
330 
331  OnClientReconnectEvent(identity, player);
332  break;
333 
335  ClientDisconnectedEventParams discoParams;
336  Class.CastTo(discoParams, params);
337 
338  identity = discoParams.param1;
339  Class.CastTo(player, discoParams.param2);
340  int logoutTime = discoParams.param3;
341  bool authFailed = discoParams.param4;
342 
343  if (!player)
344  {
345  Debug.Log("ClientDisconnectenEvent: Player is empty");
346  return;
347  }
348 
349  OnClientDisconnectedEvent(identity, player, logoutTime, authFailed);
350  break;
351 
353  LogoutCancelEventParams logoutCancelParams;
354 
355  Class.CastTo(logoutCancelParams, params);
356  Class.CastTo(player, logoutCancelParams.param1);
357  identity = player.GetIdentity();
358  if (identity)
359  {
360  // disable reconnecting to old char
361  // GetGame().RemoveFromReconnectCache(identity.GetId());
362  Print("[Logout]: Player " + identity.GetId() + " cancelled");
363  }
364  else
365  {
366  Print("[Logout]: Player cancelled");
367  }
368  m_LogoutPlayers.Remove(player);
369  m_NewLogoutPlayers.Remove(player);
370  break;
371  }
372  }
373 
374  void InvokeOnConnect(PlayerBase player, PlayerIdentity identity)
375  {
376  Debug.Log("InvokeOnConnect:"+this.ToString(),"Connect");
377  if (player)
378  player.OnConnect();
379  }
380 
381  void InvokeOnDisconnect(PlayerBase player)
382  {
383  Debug.Log("InvokeOnDisconnect:"+this.ToString(),"Connect");
384  if (player)
385  player.OnDisconnect();
386  }
387 
388  void OnClientPrepareEvent(PlayerIdentity identity, out bool useDB, out vector pos, out float yaw, out int preloadTimeout)
389  {
390  if (GetHive())
391  {
392  // use character from database
393  useDB = true;
394  }
395  else
396  {
397  // use following data without database
398  useDB = false;
399  pos = "1189.3 0.0 5392.48";
400  yaw = 0;
401  }
402  }
403 
404  // Enables/Disables personal light on the given player.
405  void ControlPersonalLight(PlayerBase player)
406  {
407  if (player)
408  {
409  bool is_personal_light = ! GetGame().ServerConfigGetInt("disablePersonalLight");
410  Param1<bool> personal_light_toggle = new Param1<bool>(is_personal_light);
411  GetGame().RPCSingleParam(player, ERPCs.RPC_TOGGLE_PERSONAL_LIGHT, personal_light_toggle, true, player.GetIdentity());
412  }
413  else
414  {
415  Error("Error! Player was not initialized at the right time. Thus cannot send RPC command to enable or disable personal light!");
416  }
417  }
418 
419  // syncs global lighting setup from the server (lightingConfig server config parameter)
420  void SyncGlobalLighting(PlayerBase player)
421  {
422  if (player)
423  {
424  int lightingID = GetGame().ServerConfigGetInt("lightingConfig");
425  Param1<int> lightID = new Param1<int>(lightingID);
426  GetGame().RPCSingleParam(player, ERPCs.RPC_SEND_LIGHTING_SETUP, lightID, true, player.GetIdentity());
427  }
428  }
429 
431  bool ProcessLoginData(ParamsReadContext ctx)
432  {
433  //creates temporary server-side structure for handling default character spawn
434  return GetGame().GetMenuDefaultCharacterData(false).DeserializeCharacterData(ctx);
435  }
436 
437  //
438  PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
439  {
440  Entity playerEnt;
441  playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
442  Class.CastTo(m_player, playerEnt);
443 
444  GetGame().SelectPlayer(identity, m_player);
445 
446  return m_player;
447  }
448 
450  void EquipCharacter(MenuDefaultCharacterData char_data)
451  {
452  int slot_ID;
453  string attachment_type;
454  for (int i = 0; i < DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Count(); i++)
455  {
456  slot_ID = DefaultCharacterCreationMethods.GetAttachmentSlotsArray().Get(i);
457  attachment_type = "";
458  if (m_RespawnMode != GameConstants.RESPAWN_MODE_CUSTOM || !char_data.GetAttachmentMap().Find(slot_ID,attachment_type) || !VerifyAttachmentType(slot_ID,attachment_type)) //todo insert verification fn here
459  {
460  //randomize
461  if (DefaultCharacterCreationMethods.GetConfigArrayCountFromSlotID(slot_ID) > 0)
462  {
463  attachment_type = DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).GetRandomElement();
464  }
465  else //undefined, moving on
466  continue;
467  }
468 
469  if (attachment_type != "")
470  {
471  m_player.GetInventory().CreateAttachmentEx(attachment_type,slot_ID);
472  }
473  }
474 
475  StartingEquipSetup(m_player, true);
476  }
477 
479  void StartingEquipSetup(PlayerBase player, bool clothesChosen)
480  {
481  }
482 
483  bool VerifyAttachmentType(int slot_ID, string attachment_type)
484  {
485  return DefaultCharacterCreationMethods.GetConfigAttachmentTypes(slot_ID).Find(attachment_type) > -1;
486  }
487 
488  PlayerBase OnClientNewEvent(PlayerIdentity identity, vector pos, ParamsReadContext ctx)
489  {
490  string characterType = GetGame().CreateRandomPlayer();
491  bool generateRandomEquip = false;
492 
493  // get login data for new character
494  if (ProcessLoginData(ctx) && (m_RespawnMode == GameConstants.RESPAWN_MODE_CUSTOM) && !GetGame().GetMenuDefaultCharacterData(false).IsRandomCharacterForced())
495  {
496  if (GetGame().ListAvailableCharacters().Find(GetGame().GetMenuDefaultCharacterData().GetCharacterType()) > -1)
497  characterType = GetGame().GetMenuDefaultCharacterData().GetCharacterType();
498  }
499  else
500  {
501  generateRandomEquip = true;
502  }
503 
504  if (PlayerSpawnHandler.IsInitialized())
505  {
506  PlayerSpawnPreset presetData = PlayerSpawnHandler.GetRandomCharacterPreset();
507  if (presetData && presetData.IsValid())
508  {
509  string presetCharType = presetData.GetRandomCharacterType();
510  if (presetCharType == string.Empty)
511  presetCharType = characterType;
512  if (CreateCharacter(identity, pos, ctx, presetCharType) != null)
513  {
514  PlayerSpawnHandler.ProcessEquipmentData(m_player,presetData);
515  return m_player;
516  }
517  else
518  {
519  ErrorEx("Failed to create character from type: " + presetCharType + ", using default spawning method");
520  }
521  }
522  else
523  {
524  ErrorEx("Failed to load PlayerSpawnPreset data properly, using default spawning method");
525  }
526  }
527 
528  if (CreateCharacter(identity, pos, ctx, characterType))
529  {
530  if (generateRandomEquip)
531  GetGame().GetMenuDefaultCharacterData().GenerateRandomEquip();
532  EquipCharacter(GetGame().GetMenuDefaultCharacterData());
533  }
534 
535  return m_player;
536  }
537 
538  void OnClientReadyEvent(PlayerIdentity identity, PlayerBase player)
539  {
540  GetGame().SelectPlayer(identity, player);
541 
542  #ifdef DIAG_DEVELOPER
543  if (FeatureTimeAccel.m_CurrentTimeAccel)
544  {
545  GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel, true, identity);
546  }
547  #endif
548  }
549 
550  void OnClientRespawnEvent(PlayerIdentity identity, PlayerBase player)
551  {
552  if (player)
553  {
554  if (player.IsUnconscious() || player.IsRestrained())
555  {
556  // kill character
557  player.SetHealth("", "", 0.0);
558  }
559  }
560 
561  #ifdef DIAG_DEVELOPER
562  if (FeatureTimeAccel.m_CurrentTimeAccel)
563  {
564  GetGame().RPCSingleParam(player, ERPCs.DIAG_TIMEACCEL_CLIENT_SYNC, FeatureTimeAccel.m_CurrentTimeAccel, true, identity);
565  }
566  #endif
567  }
568 
569  void OnClientReconnectEvent(PlayerIdentity identity, PlayerBase player)
570  {
571  if (player)
572  {
573  player.OnReconnect();
574  }
575  }
576 
577  void OnClientDisconnectedEvent(PlayerIdentity identity, PlayerBase player, int logoutTime, bool authFailed)
578  {
579  bool disconnectNow = true;
580 
581  // TODO: get out of vehicle
582  // using database and no saving if authorization failed
583  if (GetHive() && !authFailed)
584  {
585  if (player.IsAlive())
586  {
587  if (!m_LogoutPlayers.Contains(player) && !m_NewLogoutPlayers.Contains(player))
588  {
589  Print("[Logout]: New player " + identity.GetId() + " with logout time " + logoutTime.ToString());
590 
591  // send statistics to client
592  player.StatSyncToClient();
593 
594  // inform client about logout time
595  GetGame().SendLogoutTime(player, logoutTime);
596 
597  // wait for some time before logout and save
598  LogoutInfo params = new LogoutInfo(GetGame().GetTime() + logoutTime * 1000, identity.GetId());
599 
600  m_NewLogoutPlayers.Insert(player, params);
601  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(AddNewPlayerLogout, 0, false, player, params);
602 
603  // allow reconnecting to old char only if not in cars, od ladders etc. as they cannot be properly synchronized for reconnect
604  //if (!player.GetCommand_Vehicle() && !player.GetCommand_Ladder())
605  //{
606  // GetGame().AddToReconnectCache(identity);
607  //}
608  // wait until logout timer runs out
609  disconnectNow = false;
610  }
611  return;
612  }
613  }
614 
615  if (disconnectNow)
616  {
617  Print("[Logout]: New player " + identity.GetId() + " with instant logout");
618 
619  // inform client about instant logout
620  GetGame().SendLogoutTime(player, 0);
621 
622  PlayerDisconnected(player, identity, identity.GetId());
623  }
624  }
625 
626  void PlayerDisconnected(PlayerBase player, PlayerIdentity identity, string uid)
627  {
628  // Note: At this point, identity can be already deleted
629  if (!player)
630  {
631  Print("[Logout]: Skipping player " + uid + ", already removed");
632  return;
633  }
634 
635  // disable reconnecting to old char
636  //GetGame().RemoveFromReconnectCache(uid);
637 
638  // now player can't cancel logout anymore, so call everything needed upon disconnect
639  InvokeOnDisconnect(player);
640 
641  Print("[Logout]: Player " + uid + " finished");
642 
643  if (GetHive())
644  {
645  // save player
646  player.Save();
647 
648  // unlock player in DB
649  GetHive().CharacterExit(player);
650  }
651 
652  // handle player's existing char in the world
653  player.ReleaseNetworkControls();
654  HandleBody(player);
655 
656  // remove player from server
657  GetGame().DisconnectPlayer(identity, uid);
658  // Send list of players at all clients
659  GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(SyncEvents.SendPlayerList, 1000);
660  }
661 
662  bool ShouldPlayerBeKilled(PlayerBase player)
663  {
664  if (player.IsUnconscious() || player.IsRestrained())
665  {
666  switch (player.GetKickOffReason())
667  {
668  case EClientKicked.SERVER_EXIT:
669  return false;
670  case EClientKicked.KICK_ALL_ADMIN:
671  return false;
672  case EClientKicked.KICK_ALL_SERVER:
673  return false;
674  case EClientKicked.SERVER_SHUTDOWN:
675  return false;
676  default:
677  return true;
678  }
679  }
680 
681  return false;
682  }
683 
684  void HandleBody(PlayerBase player)
685  {
686  if (player.IsAlive())
687  {
688  if (ShouldPlayerBeKilled(player))
689  {
690  player.SetHealth("", "", 0.0);//kill
691  }
692  else
693  {
694  player.Delete();// remove the body
695  }
696  }
697  }
698 
699  void TickScheduler(float timeslice)
700  {
701  GetGame().GetWorld().GetPlayerList(m_Players);
702  int players_count = m_Players.Count();
703  int tick_count_max = Math.Min(players_count, SCHEDULER_PLAYERS_PER_TICK);
704 
705  for (int i = 0; i < tick_count_max; i++)
706  {
707  if (m_currentPlayer >= players_count)
708  {
709  m_currentPlayer = 0;
710  }
711 
712  PlayerBase currentPlayer = PlayerBase.Cast(m_Players.Get(m_currentPlayer));
713 
714  if (currentPlayer)
715  currentPlayer.OnTick();
716  m_currentPlayer++;
717  }
718  }
719 
720  //--------------------------------------------------
721  override bool InsertCorpse(Man player)
722  {
723  CorpseData corpse_data = new CorpseData(PlayerBase.Cast(player),GetGame().GetTime());
724  return m_DeadPlayersArray.Insert(corpse_data) >= 0;
725  }
726 
727  void UpdateCorpseStatesServer()
728  {
729  if (m_DeadPlayersArray.Count() == 0)//nothing to process, abort
730  return;
731  int current_time = GetGame().GetTime();
732  array<int> invalid_corpses = new array<int>;
733  CorpseData corpse_data;
734 
735  for (int i = 0; i < m_DeadPlayersArray.Count(); i++)
736  {
737  corpse_data = m_DeadPlayersArray.Get(i);
738  if (!corpse_data || (corpse_data && (!corpse_data.m_Player || !corpse_data.m_bUpdate)))
739  {
740  invalid_corpses.Insert(i);
741  }
742  else if (corpse_data.m_bUpdate && current_time - corpse_data.m_iLastUpdateTime >= 30000)
743  {
744  corpse_data.UpdateCorpseState();
745  corpse_data.m_iLastUpdateTime = current_time;
746  }
747  }
748 
749  //cleanup
750  if (invalid_corpses.Count() > 0)
751  {
752  for (i = invalid_corpses.Count() - 1; i > -1; i--)
753  {
754  m_DeadPlayersArray.Remove(invalid_corpses.Get(i));
755  }
756  }
757  }
758  //--------------------------------------------------
759 
760  override void SyncRespawnModeInfo(PlayerIdentity identity)
761  {
762  ScriptRPC rpc = new ScriptRPC();
763  rpc.Write(m_RespawnMode);
764  rpc.Send(null, ERPCs.RPC_SERVER_RESPAWN_MODE, true, identity);
765  }
766 
767  override RainProcurementHandler GetRainProcurementHandler()
768  {
769  return m_RainProcHandler;
770  }
771 }
772 
Param2
Definition: ppeconstants.c:66
GetGame
proto native CGame GetGame()
ClientReadyEventTypeID
const EventType ClientReadyEventTypeID
params: ClientReadyEventParams
Definition: gameplay.c:504
EClientKicked
EClientKicked
Definition: clientkickedmodule.c:1
CALL_CATEGORY_SYSTEM
const int CALL_CATEGORY_SYSTEM
Definition: tools.c:8
m_player
DayZPlayer m_player
Definition: randomgeneratorsyncmanager.c:15
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
CorpseData
Definition: corpsedata.c:1
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
LogoutInfo
Param2< int, string > LogoutInfo
int time of the logout end
Definition: missionserver.c:3
ClientDisconnectedEventParams
Param4< PlayerIdentity, Man, int, bool > ClientDisconnectedEventParams
PlayerIdentity, Man, LogoutTime, AuthFailed.
Definition: gameplay.c:415
AnalyticsManagerServer
Definition: analyticsmanagerserver.c:1
Print
proto void Print(void var)
Prints content of variable to console/log.
ClientNewEventTypeID
const EventType ClientNewEventTypeID
params: ClientNewEventParams
Definition: gameplay.c:496
ClientPrepareEventParams
Param5< PlayerIdentity, bool, vector, float, int > ClientPrepareEventParams
PlayerIdentity, useDB, pos, yaw, preloadTimeout (= additional time in seconds to how long server wait...
Definition: gameplay.c:403
Param3
Definition: entityai.c:95
ToString
proto string ToString()
ErrorEx
enum ShapeType ErrorEx
GetPlugin
PluginBase GetPlugin(typename plugin_type)
Definition: pluginmanager.c:316
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
ClientReconnectEventTypeID
const EventType ClientReconnectEventTypeID
params: ClientReconnectEventParams
Definition: gameplay.c:502
OnEvent
override void OnEvent(EventType eventTypeId, Param params)
Handles VON-related events.
Definition: connecterrorscriptmodule.c:35
EffectAreaLoader
Definition: contaminatedarealoader.c:2
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
EventType
TypeID EventType
Definition: enwidgets.c:55
PlayerBase
Definition: playerbaseclient.c:1
map
map
Definition: controlsxboxnew.c:3
MenuDefaultCharacterData
Definition: gameplay.c:960
vector
Definition: enconvert.c:105
PluginLifespan
void PluginLifespan()
Definition: pluginlifespan.c:45
LogoutCancelEventParams
Param1< Man > LogoutCancelEventParams
Player.
Definition: gameplay.c:424
OnUpdate
proto native void OnUpdate()
Definition: tools.c:349
ScriptRPC
Definition: gameplay.c:104
UndergroundAreaLoader
Definition: undergroundarealoader.c:47
ClientDisconnectedEventTypeID
const EventType ClientDisconnectedEventTypeID
params: ClientDisconnectedEventParams
Definition: gameplay.c:506
CfgGameplayHandler
Definition: cfggameplayhandler.c:1
array< Man >
Empty
Empty
Definition: hand_states.c:3
SyncEvents
Definition: syncevents.c:1
RainProcurementHandler
Definition: rainprocurementhandler.c:1
GameConstants
Definition: constants.c:612
Debug
Definition: debug.c:13
Entity
Definition: camera.c:1
ERPCs
ERPCs
Definition: erpcs.c:1
OnInit
void OnInit()
Definition: aibehaviour.c:49
GetTime
float GetTime()
Definition: notificationsystem.c:35
LogoutCancelEventTypeID
const EventType LogoutCancelEventTypeID
params: LogoutCancelEventParams
Definition: gameplay.c:516
PlayerSpawnHandler
Definition: cfgplayerspawnhandler.c:1
ClientRespawnEventTypeID
const EventType ClientRespawnEventTypeID
params: ClientRespawnEventParams
Definition: gameplay.c:500
Math
Definition: enmath.c:6
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
MissionBase
Definition: missiongameplay.c:1
GetHive
proto native Hive GetHive()
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
PlayerSpawnPreset
Definition: cfgplayerspawndatajson.c:16
ClientPrepareEventTypeID
const EventType ClientPrepareEventTypeID
params: ClientPrepareEventParams
Definition: gameplay.c:494