Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. private ["_playerID","_endMission","_0","_1","_timeleft","_doLoop","_key","_primary","_model","_inventory","_backpack","_survival","_CharacterCoins","_group","_playerCoins","_BankCoins","_hiveVer","_mags","_wpns","_bcpk","_config","_isInfected","_remaining","_playerObj","_playerName","_newPlayer","_isNew","_charID","_isHiveOk"];
  2.  
  3. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  4.  
  5. _playerID = _this select 0;
  6. _playerObj = _this select 1;
  7. _playerName = name _playerObj;
  8. if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
  9.  
  10. // Cancel any login until server_monitor terminates.
  11. // This is mandatory since all vehicles must be spawned before the first players spawn on the map.
  12. // Otherwise, all vehicle event handlers won't be created on players' client side.
  13. if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
  14.  
  15. _inventory = [];
  16. _backpack = [];
  17. _survival = [0,0,0];
  18. _model = "";
  19. _isInfected = 0;
  20. _CharacterCoins = 0;
  21. _group = [];
  22. _playerCoins = 0;
  23. _BankCoins = 0;
  24.  
  25. if (_playerID == "") then {
  26. _playerID = getPlayerUID _playerObj;
  27. };
  28.  
  29. if ((_playerID == "") or (isNil "_playerID")) exitWith {
  30. diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  31. };
  32.  
  33. _endMission = false;
  34. _timeleft = 0;
  35. {
  36. //if ((_playerID select _i) in activePlayers) exitWith { diag_log ("Login cancelled, player has logged out within the past 2 mins. " + str(_playerObj)); };
  37. _0 = _x select 0;
  38. _1 = _x select 1;
  39. _timeleft = diag_ticktime - _1;
  40.  
  41. if (_playerID == _0) then {
  42. //If players last logoff is about the ghost timer remove player from ghost que.
  43. if ((_timeleft > dayz_ghostTimer) or (_timeleft < 0)) then {
  44. dayz_ghostPlayers = dayz_ghostPlayers - [_0];
  45. dayz_activePlayers set [_forEachIndex, _0];
  46. dayz_activePlayers = dayz_activePlayers - [_0];
  47. } else {
  48. //if player is in died allow them passage.
  49. if (_playerID in dayz_died) then {
  50. dayz_died = dayz_died - [_playerID];
  51. dayz_ghostPlayers = dayz_ghostPlayers - [_0];
  52. dayz_activePlayers set [_forEachIndex, _0];
  53. dayz_activePlayers = dayz_activePlayers - [_0];
  54. } else {
  55. // Logoff time is not beyond ghost time and player didn't die
  56. _endMission = true;
  57. };
  58. };
  59. };
  60. } forEach dayz_activePlayers;
  61.  
  62. //Do Connection Attempt
  63. _doLoop = 0;
  64. while {_doLoop < 5} do {
  65. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  66. _primary = _key call server_hiveReadWrite;
  67. if (count _primary > 0) then {
  68. if ((_primary select 0) != "ERROR") then {
  69. _doLoop = 9;
  70. };
  71. };
  72. _doLoop = _doLoop + 1;
  73. };
  74.  
  75. if (isNull _playerObj or !isPlayer _playerObj) exitWith {
  76. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  77. };
  78.  
  79. if ((_primary select 0) == "ERROR") exitWith {
  80. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  81. };
  82.  
  83. //Process request
  84. _newPlayer = _primary select 1;
  85. _isNew = count _primary < 10; //_result select 1;
  86. _charID = _primary select 2;
  87. //diag_log ("LOGIN RESULT: " + str(_primary));
  88. /* PROCESS */
  89. _hiveVer = 0;
  90.  
  91. if (!_isNew) then {
  92. //RETURNING CHARACTER
  93. _inventory = _primary select 4;
  94. _backpack = _primary select 5;
  95. _survival = _primary select 6;
  96. _CharacterCoins = _primary select 7;
  97. _model = _primary select 8;
  98. _group = _primary select 9;
  99. _playerCoins = _primary select 10;
  100. _BankCoins = _primary select 11;
  101. _hiveVer = _primary select 12;
  102. if !(_model in AllPlayers) then {_model = "Survivor2_DZ";};
  103. } else {
  104. _isInfected = if (DZE_PlayerZed) then {_primary select 3} else {0};
  105. _model = _primary select 4;
  106. _group = _primary select 5;
  107. _playerCoins = _primary select 6;
  108. _BankCoins = _primary select 7;
  109. _hiveVer = _primary select 8;
  110. if (isNil "_model") then {
  111. _model = "Survivor2_DZ";
  112. } else {
  113. if (_model == "") then {_model = "Survivor2_DZ";};
  114. };
  115.  
  116. //Record initial inventory only if not player zombie
  117. if (_isInfected != 1) then {
  118. _config = configFile >> "CfgSurvival" >> "Inventory" >> "Default";
  119. _mags = getArray (_config >> "magazines");
  120. _wpns = getArray (_config >> "weapons");
  121. _bcpk = getText (_config >> "backpack");
  122. if (!isNil "DefaultMagazines") then {_mags = DefaultMagazines;};
  123. if (!isNil "DefaultWeapons") then {_wpns = DefaultWeapons;};
  124. if (!isNil "DefaultBackpack") then {_bcpk = DefaultBackpack;};
  125.  
  126. //Wait for HIVE to be free
  127. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  128. _key call server_hiveWrite;
  129. };
  130. };
  131.  
  132. _isHiveOk = (_hiveVer >= dayz_hiveVersionNo); //EDITED
  133.  
  134. /*
  135. if (count _inventory > 2 && {typeName (_inventory select 2) != "STRING"}) then {
  136. //Pre 1.0.6 character with Zupa 3.0 coins where dayz_onBack should be. Wipe coins and log playerID and amount to RPT.
  137. diag_log format["%1 - Updating pre 1.0.6 character inventory to add dayz_onBack. Coins have been wiped for PlayerID: %2 PreviousCoins:%3",__FILE__,_playerID,(_inventory select 2)];
  138. _inventory set [2,""];
  139. };
  140. */
  141.  
  142. if (_newPlayer) then {_BankCoins = 35000};
  143. PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected,_group,_CharacterCoins,_playerCoins,_BankCoins];
  144. (owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
  145.  
  146. //Make player wait until ghost timer is up.
  147. if (_endMission) exitwith {
  148. _remaining = dayz_ghostTimer - _timeleft;
  149.  
  150. //Log For GhostMode
  151. diag_log format["INFO - Player:%1(UID:%2/CID%3) Status: LOGIN CANCELLED, GHOSTMODE. Time remianing: %4",_playerName,_playerID,_charID,_remaining];
  152.  
  153. PVCDZ_plr_Ghost = [_remaining];
  154. (owner _playerObj) publicVariableClient "PVCDZ_plr_Ghost";
  155. };
  156.  
  157. //Sync chopped trees for JIP player
  158. {_x setDamage 1} count dayz_choppedTrees;
  159.  
  160. //Sync active group invites to JIP player
  161. if (count dayz_activeInvites > 0) then {
  162. (owner _playerObj) publicVariableClient "dayz_activeInvites";
  163. };
  164.  
  165. //Record Player Login/LogOut
  166. [_playerID,_charID,2,(_playerObj call fa_plr2str),((getPosATL _playerObj) call fa_coor2str)] call dayz_recordLogin;
  167.  
  168. PVCDZ_plr_PlayerAccepted = [_playerName,diag_ticktime];
  169. (owner _playerObj) publicVariableClient "PVCDZ_plr_PlayerAccepted";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement