Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
clientdata.c
Go to the documentation of this file.
1 class ClientData
2 {
3  static ref ScriptInvoker SyncEvent_OnPlayerListUpdate = new ScriptInvoker();
4  static ref ScriptInvoker SyncEvent_OnEntityKilled = new ScriptInvoker();
5  static ref ScriptInvoker SyncEvent_OnPlayerIgnitedFireplace = new ScriptInvoker();
6 
7  static ref array<Man> m_PlayerBaseList = new array<Man>;
8  static ref SyncPlayerList m_PlayerList;
9  static ref SyncPlayerList m_LastNewPlayers;
10 
11  static ref OnlineServices m_OnlineServices;
12 
13  static void ResetClientData()
14  {
15  if ( m_PlayerBaseList )
16  m_PlayerBaseList.Clear();
17  if ( m_PlayerList && m_PlayerList.m_PlayerList )
18  m_PlayerList.m_PlayerList.Clear();
19  if ( m_LastNewPlayers && m_LastNewPlayers.m_PlayerList )
20  m_LastNewPlayers.m_PlayerList.Clear();
21  }
22 
23  static void AddPlayerBase( Man player )
24  {
25  if ( m_PlayerBaseList && player != GetGame().GetPlayer() )
26  m_PlayerBaseList.Insert( player );
27  }
28 
29  static void RemovePlayerBase( Man player )
30  {
31  if ( m_PlayerBaseList )
32  m_PlayerBaseList.RemoveItem( player );
33  }
34 
35  static void SyncEvent_PreprocessPlayerList(SyncPlayerList player_list)
36  {
37  foreach (auto sync_player : player_list.m_PlayerList)
38  {
39  PlayerIdentity identity = sync_player.m_Identity;
40  if (!identity)
41  {
42  ErrorEx("PlayerIdentity not synchronized before SyncPlayer", ErrorExSeverity.WARNING);
43  continue;
44  }
45 
46  sync_player.m_UID = identity.GetPlainId();
47  sync_player.m_PlayerName = identity.GetPlainName();
48  }
49  }
50 
51  static void SyncEvent_OnRecievedPlayerList( SyncPlayerList player_list )
52  {
53  if (m_PlayerList && m_PlayerList.m_PlayerList)
54  {
55  //Print("SyncEvent_OnRecievedPlayerList | " + m_PlayerList.m_PlayerList.Count());
56  }
57 
58  SyncPlayerList new_players = SyncPlayerList.Compare(m_PlayerList, player_list);
59 
60  if ( !m_LastNewPlayers )
61  {
62  m_LastNewPlayers = player_list;
63  }
64  else
65  {
66  m_LastNewPlayers = SyncPlayerList.Compare( m_LastNewPlayers, new_players );
67  }
68 
69  m_PlayerList = SyncPlayerList.Compare(player_list, null);
70 
71  #ifdef PLATFORM_CONSOLE
72  #ifndef PLATFORM_WINDOWS // if app is not on Windows with -XBOX parameter
73  array<string> newPlayersSimple = GetSimplePlayerList( new_players );
74  OnlineServices.LoadPermissions( newPlayersSimple );
75  OnlineServices.m_ClientServices.GetSessionService().OnSessionPlayerListUpdate(newPlayersSimple);
76 
77  if ( new_players.m_PlayerList.Count() > 0 )
78  {
79  OnlineServices.LoadFriends();
80  }
81 
82  if ( g_Game.GetGameState() == DayZGameState.IN_GAME )
83  {
84  OnlineServices.SetMultiplayState(OnlineServices.GetMultiplayState());
85  }
86  #endif
87  #endif
88 
89  SyncEvent_OnPlayerListUpdate.Invoke( player_list );
90  }
91 
92  static array<string> GetSimplePlayerList()
93  {
94  array<string> ids = new array<string>;
95  if ( m_PlayerList && m_PlayerList.m_PlayerList )
96  {
97  for ( int i = 0; i < m_PlayerList.m_PlayerList.Count(); i++ )
98  {
99  SyncPlayer player = m_PlayerList.m_PlayerList.Get( i );
100  ids.Insert( player.m_UID );
101  }
102  }
103 
104  return ids;
105  }
106 
107  static array<string> GetSimplePlayerList( SyncPlayerList list )
108  {
109  array<string> ids = new array<string>;
110  if ( list )
111  {
112  for ( int i = 0; i < list.m_PlayerList.Count(); i++ )
113  {
114  SyncPlayer player = list.m_PlayerList.Get( i );
115  ids.Insert( player.m_UID );
116  }
117  }
118 
119  return ids;
120  }
121 
122  static void SyncEvent_OnEntityKilled( SyncEntityKillInfo entity_killed_data )
123  {
124  SyncEvent_OnEntityKilled.Invoke(entity_killed_data.m_EntityVictim, entity_killed_data.m_EntityKiller, entity_killed_data.m_EntitySource, entity_killed_data.m_IsHeadShot );
125  }
126 
127  static void SyncEvent_OnPlayerIgnitedFireplace( EFireIgniteType igante_type )
128  {
129  SyncEvent_OnPlayerIgnitedFireplace.Invoke(igante_type);
130  }
131 }
GetGame
proto native CGame GetGame()
ClientData
Definition: clientdata.c:1
ErrorEx
enum ShapeType ErrorEx
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
SyncEntityKillInfo
Definition: syncentitykill.c:1
g_Game
DayZGame g_Game
Definition: dayzgame.c:3727
ErrorExSeverity
ErrorExSeverity
Definition: endebug.c:61
EFireIgniteType
EFireIgniteType
Definition: efireignitetype.c:1
SyncPlayerList
Definition: syncplayerlist.c:1
array< Man >
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
SyncPlayer
Definition: syncplayer.c:1
OnlineServices
Definition: onlineservices.c:1
ScriptInvoker
ScriptInvoker Class provide list of callbacks usage:
Definition: tools.c:115