Advertisement
Guest User

Untitled

a guest
Oct 27th, 2013
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. private ["_isInfected","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_primary","_key","_charID","_playerName","_backpack","_isNew","_inventory","_survival","_model","_mags","_wpns","_bcpk","_config","_newPlayer"];
  2.  
  3. #ifdef DZE_SERVER_DEBUG
  4. diag_log ("STARTING LOGIN: " + str(_this));
  5. #endif
  6.  
  7. _playerID = _this select 0;
  8. _playerObj = _this select 1;
  9. _playerName = name _playerObj;
  10.  
  11. if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
  12.  
  13. if (isNil "sm_done") exitWith {
  14. #ifdef DZE_SERVER_DEBUG
  15. diag_log ("Login cancelled, server is not ready. " + str(_playerObj));
  16. #endif
  17. };
  18.  
  19. if (count _this > 2) then {
  20. dayz_players = dayz_players - [_this select 2];
  21. };
  22.  
  23. //Variables
  24. _inventory = [];
  25. _backpack = [];
  26. _survival = [0,0,0];
  27. _isInfected = 0;
  28. _model = "";
  29.  
  30. if (_playerID == "") then {
  31. _playerID = getPlayerUID _playerObj;
  32. };
  33.  
  34. if ((_playerID == "") or (isNil "_playerID")) exitWith {
  35. #ifdef DZE_SERVER_DEBUG
  36. diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  37. #endif
  38. };
  39.  
  40. #ifdef DZE_SERVER_DEBUG
  41. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  42. #endif
  43.  
  44. //Do Connection Attempt
  45. _doLoop = 0;
  46. while {_doLoop < 5} do {
  47. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  48. _primary = _key call server_hiveReadWrite;
  49. if (count _primary > 0) then {
  50. if ((_primary select 0) != "ERROR") then {
  51. _doLoop = 9;
  52. };
  53. };
  54. _doLoop = _doLoop + 1;
  55. };
  56.  
  57. if (isNull _playerObj or !isPlayer _playerObj) exitWith {
  58. #ifdef DZE_SERVER_DEBUG
  59. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  60. #endif
  61. };
  62.  
  63. if ((_primary select 0) == "ERROR") exitWith {
  64. #ifdef DZE_SERVER_DEBUG
  65. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  66. #endif
  67. };
  68.  
  69. //Process request
  70. _newPlayer = _primary select 1;
  71. _isNew = count _primary < 7; //_result select 1;
  72. _charID = _primary select 2;
  73.  
  74. #ifdef DZE_SERVER_DEBUG
  75. diag_log ("LOGIN RESULT: " + str(_primary));
  76. #endif
  77.  
  78. /* PROCESS */
  79. _hiveVer = 0;
  80.  
  81. if (!_isNew) then {
  82. //RETURNING CHARACTER
  83. _inventory = _primary select 4;
  84. _backpack = _primary select 5;
  85. _survival = _primary select 6;
  86. _model = _primary select 7;
  87. _hiveVer = _primary select 8;
  88.  
  89. if (!(_model in AllPlayers)) then {
  90. _model = "Survivor2_DZ";
  91. };
  92.  
  93. } else {
  94. _isInfected = _primary select 3;
  95. _model = _primary select 4;
  96. _hiveVer = _primary select 5;
  97.  
  98. if (isNil "_model") then {
  99. _model = "Survivor2_DZ";
  100. } else {
  101. if (_model == "") then {
  102. _model = "Survivor2_DZ";
  103. };
  104. };
  105.  
  106. //Record initial inventory only if not player zombie
  107. if(_isInfected != 1) then {
  108. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  109. _mags = getArray (_config >> "magazines");
  110. _wpns = getArray (_config >> "weapons");
  111. _bcpk = getText (_config >> "backpack");
  112.  
  113. if(!isNil "DefaultMagazines") then {
  114. _mags = DefaultMagazines;
  115. };
  116. if(!isNil "DefaultWeapons") then {
  117. _wpns = DefaultWeapons;
  118. };
  119. if(!isNil "DefaultBackpack") then {
  120. _bcpk = DefaultBackpack;
  121. };
  122. //_randomSpot = true;
  123. if (true) then {
  124. _key = format["CHILD:999:select replace(`inventory`, '""', '\'') `inventory`, replace(`backpack`, '""', '\'') `backpack` from `instance` where `id` = ?:[%1]:",dayZ_instance];
  125. _data = "HiveEXT" callExtension _key;
  126. //Process result
  127. _result = call compile format ["%1", _data];
  128. _status = _result select 0;
  129. if (_status == "CustomStreamStart") then {
  130. if ((_result select 1) > 0) then {
  131. _data = "HiveEXT" callExtension _key;
  132. _result = call compile _data;
  133. _inventory = call compile (_result select 0);
  134. _backpack = call compile (_result select 1);
  135. //_isNew = false;
  136. };
  137. };
  138. };
  139.  
  140. if (true) then {
  141. _key = format["CHILD:999:select replace(cl.`inventory`, '""', '\'') inventory, replace(cl.`backpack`, '""', '\'') backpack, replace(coalesce(cl.`model`, 'Survivor2_DZ'), '""', '\'') model from `cust_loadout` cl join `cust_loadout_profile` clp on clp.`cust_loadout_id` = cl.`id` where clp.`unique_id` = '?':[%1]:",str(_playerID)];
  142. _data = "HiveEXT" callExtension _key;
  143. //Process result
  144. _result = call compile format ["%1", _data];
  145. _status = _result select 0;
  146. if (_status == "CustomStreamStart") then {
  147. if ((_result select 1) > 0) then {
  148. _data = "HiveEXT" callExtension _key;
  149. _result = call compile format ["%1", _data];
  150. _inventory = call compile (_result select 0);
  151. _backpack = call compile (_result select 1);
  152. _model = call compile (_result select 2);
  153. //_isNew = false;
  154. };
  155. };
  156. };
  157.  
  158. //Wait for HIVE to be free
  159. if (_isNew) then {
  160. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  161. } else {
  162. _key = format["CHILD:203:%1:%2:%3:",_charID,_inventory,_backpack];
  163. };
  164. _key call server_hiveWrite;
  165. };
  166. };
  167.  
  168. #ifdef DZE_SERVER_DEBUG
  169. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  170. #endif
  171.  
  172. _isHiveOk = false;
  173. if (_hiveVer >= dayz_hiveVersionNo) then {
  174. _isHiveOk = true;
  175. };
  176.  
  177. ([4654,9595,0] nearestObject 145259) setDamage 1;
  178. ([4654,9595,0] nearestObject 145260) setDamage 1;
  179.  
  180. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
  181. (owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement