DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
SyncPlayerList.c
Go to the documentation of this file.
2{
4
6 {
7 if (GetGame().IsServer())
8 {
10
11 array<Man> players = new array<Man>;
12 GetGame().GetWorld().GetPlayerList(players);
13
14 for (int i = 0; i < players.Count(); ++i)
15 {
16 Man player = players[i];
17 PlayerIdentity p_identity = player.GetIdentity();
18
19 if (p_identity)
20 {
21 SyncPlayer sync_player = new SyncPlayer;
22 sync_player.m_UID = p_identity.GetPlainId();
23 sync_player.m_PlayerName = p_identity.GetPlainName();
24 m_PlayerList.Insert(sync_player);
25 }
26 else
27 {
28 DebugPrint.LogErrorAndTrace("No Identity in Server Player List");
29 }
30 }
31 }
32 }
33
35 {
36 SyncPlayerList new_list = new SyncPlayerList;
38
39 if (!a && b && b.m_PlayerList)
40 {
41 foreach (SyncPlayer player3 : b.m_PlayerList)
42 {
43 new_list.m_PlayerList.Insert(player3);
44 }
45 }
46 else if (a && a.m_PlayerList && !b)
47 {
48 foreach (SyncPlayer player4 : a.m_PlayerList)
49 {
50 new_list.m_PlayerList.Insert(player4);
51 }
52 }
53 else if (a && a.m_PlayerList && b && b.m_PlayerList)
54 {
57
58 foreach (SyncPlayer player : array_b)
59 {
60 bool found = false;
61 foreach (SyncPlayer player2 : array_a)
62 {
63 if (player.m_UID == player2.m_UID)
64 {
65 found = true;
66 break;
67 }
68 }
69
70 if (!found)
71 {
72 new_list.m_PlayerList.Insert(player);
73 }
74 }
75 }
76 return new_list;
77 }
78}
proto native World GetWorld()
static void LogErrorAndTrace(string msg)
Prints debug message as error message and prints stack trace of calls.
Definition DebugPrint.c:124
proto owned string GetPlainName()
nick without any processing
proto owned string GetPlainId()
plaintext unique id of player (cannot be used in database or logs)
The class that will be instanced (moddable)
Definition gameplay.c:378
string m_UID
Definition SyncPlayer.c:3
string m_PlayerName
Definition SyncPlayer.c:4
static SyncPlayerList Compare(SyncPlayerList a, SyncPlayerList b)
void CreatePlayerList()
ref array< ref SyncPlayer > m_PlayerList
proto native void GetPlayerList(out array< Man > players)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()