Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
syncplayerlist.c
Go to the documentation of this file.
2 {
3  ref array<ref SyncPlayer> m_PlayerList;
4 
5  void CreatePlayerList()
6  {
7  if (GetGame().IsServer())
8  {
9  m_PlayerList = new array<ref SyncPlayer>();
10 
12  GetGame().GetPlayerIndentities(identities);
13 
14  foreach (auto identity : identities)
15  {
16  SyncPlayer sync_player = new SyncPlayer;
17  sync_player.m_Identity = identity;
18  sync_player.m_UID = identity.GetPlainId();
19  sync_player.m_PlayerName = identity.GetPlainName();
20  m_PlayerList.Insert(sync_player);
21  }
22  }
23  }
24 
25  static SyncPlayerList Compare(SyncPlayerList a, SyncPlayerList b)
26  {
27  SyncPlayerList new_list = new SyncPlayerList;
28  new_list.m_PlayerList = new array<ref SyncPlayer>;
29 
30  if (!a && b && b.m_PlayerList)
31  {
32  foreach (SyncPlayer player3 : b.m_PlayerList)
33  {
34  new_list.m_PlayerList.Insert(player3);
35  }
36  }
37  else if (a && a.m_PlayerList && !b)
38  {
39  foreach (SyncPlayer player4 : a.m_PlayerList)
40  {
41  new_list.m_PlayerList.Insert(player4);
42  }
43  }
44  else if (a && a.m_PlayerList && b && b.m_PlayerList)
45  {
46  array<ref SyncPlayer> array_a = a.m_PlayerList;
47  array<ref SyncPlayer> array_b = b.m_PlayerList;
48 
49  foreach (SyncPlayer player : array_b)
50  {
51  bool found = false;
52  foreach (SyncPlayer player2 : array_a)
53  {
54  if (player.m_UID == player2.m_UID)
55  {
56  found = true;
57  break;
58  }
59  }
60 
61  if (!found)
62  {
63  new_list.m_PlayerList.Insert(player);
64  }
65  }
66  }
67  return new_list;
68  }
69 }
GetGame
proto native CGame GetGame()
SyncPlayerList
Definition: syncplayerlist.c:1
array< ref SyncPlayer >
SyncPlayer
Definition: syncplayer.c:1