Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2013
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.02 KB | None | 0 0
  1. private["_botActive","_int","_newModel","_doLoop","_wait","_hiveVer","_isHiveOk","_playerID","_playerObj","_randomSpot","_publishTo","_primary","_secondary","_key","_result","_charID","_playerObj","_playerName","_finished","_spawnPos","_spawnDir","_items","_counter","_magazines","_weapons","_group","_backpack","_worldspace","_direction","_newUnit","_score","_position","_isNew","_inventory","_backpack","_medical","_survival","_stats","_state"];
  2. //Set Variables
  3.  
  4.  
  5.  
  6.  
  7. diag_log ("STARTING LOGIN: " + str(_this));
  8.  
  9. _playerID = _this select 0;
  10. _playerObj = _this select 1;
  11. _playerName = name _playerObj;
  12. _worldspace = [];
  13.  
  14. if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
  15.  
  16. // Cancel any login until server_monitor terminates.
  17. // This is mandatory since all vehicles must be spawned before the first players spawn on the map.
  18. // Otherwise, all vehicle event handlers won't be created on players' client side.
  19. if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
  20.  
  21.  
  22. if (count _this > 2) then {
  23. dayz_players = dayz_players - [_this select 2];
  24. };
  25.  
  26. //Variables
  27. _inventory = [];
  28. _backpack = [];
  29. _items = [];
  30. _magazines = [];
  31. _weapons = [];
  32. _medicalStats = [];
  33. _survival = [0,0,0];
  34. _tent = [];
  35. _state = [];
  36. _direction = 0;
  37. _model = "";
  38. _newUnit = objNull;
  39. _botActive = false;
  40.  
  41. if (_playerID == "") then {
  42. _playerID = getPlayerUID _playerObj;
  43. };
  44.  
  45. if ((_playerID == "") or (isNil "_playerID")) exitWith {
  46. diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  47. };
  48.  
  49. //??? endLoadingScreen;
  50.  
  51. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  52.  
  53.  
  54. //Do Connection Attempt
  55. _doLoop = 0;
  56. while {_doLoop < 5} do {
  57. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  58. _primary = _key call server_hiveReadWrite;
  59. if (count _primary > 0) then {
  60. if ((_primary select 0) != "ERROR") then {
  61. _doLoop = 9;
  62. };
  63. };
  64. _doLoop = _doLoop + 1;
  65. };
  66.  
  67. if (isNull _playerObj or !isPlayer _playerObj) exitWith {
  68. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  69. };
  70.  
  71. if ((_primary select 0) == "ERROR") exitWith {
  72. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  73. };
  74.  
  75. //Process request
  76. _newPlayer = _primary select 1;
  77. _isNew = count _primary < 6; //_result select 1;
  78. _charID = _primary select 2;
  79. _randomSpot = false;
  80.  
  81. //diag_log ("LOGIN RESULT: " + str(_primary));
  82.  
  83. /* PROCESS */
  84. _hiveVer = 0;
  85.  
  86. if (!_isNew) then {
  87. //RETURNING CHARACTER
  88. _inventory = _primary select 4;
  89. _backpack = _primary select 5;
  90. _survival = _primary select 6;
  91. _model = _primary select 7;
  92. _hiveVer = _primary select 8;
  93.  
  94. if (_model == "") then {
  95. _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)];
  96. _data = "HiveEXT" callExtension _key;
  97.  
  98. //Process result
  99. _result = call compile format ["%1", _data];
  100. _status = _result select 0;
  101.  
  102. if (_status == "CustomStreamStart") then {
  103. if ((_result select 1) > 0) then {
  104. _data = "HiveEXT" callExtension _key;
  105. _result = call compile format ["%1", _data];
  106. _inventory = call compile (_result select 0);
  107. _backpack = call compile (_result select 1);
  108. _model = call compile (_result select 2);
  109. };
  110. };
  111. };
  112.  
  113. if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Sniper2_DZ","Sniper3_DZ","Sniper4_DZ","Sniper5_DZ","Sniper6_DZ","Soldier1_DZ","Camo1_DZ","Camo2_DZ","Camo3_DZ","Camo4_DZ","Camo5_DZ","Camo6_DZ","Camo7_DZ","Camo8_DZ","Camo9_DZ","Camo10_DZ","Camo11_DZ","Camo12_DZ","Camo13_DZ","Camo14_DZ","Camo15_DZ","Camo16_DZ","Camo17_DZ","Camo18_DZ","Camo19_DZ","Camo20_DZ","Camo21_DZ","Camo22_DZ","Camo23_DZ","Camo24_DZ","BanditW1_DZ","Bandit1_DZ","SurvivorW2_DZ"])) then {
  114. _model = "Survivor2_DZ";
  115. };
  116.  
  117. //if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","Survivor3_DZ"])) then {
  118. // _model = "Survivor2_DZ";
  119. //};
  120.  
  121. } else {
  122. _model = _primary select 3;
  123. _hiveVer = _primary select 4;
  124. if (isNil "_model") then {
  125. _model = "Survivor2_DZ";
  126. } else {
  127. if (_model == "") then {
  128. _model = "Survivor2_DZ";
  129. };
  130. };
  131.  
  132. //Record initial inventory
  133. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  134. _mags = getArray (_config >> "magazines");
  135. _wpns = getArray (_config >> "weapons");
  136. _bcpk = getText (_config >> "backpack");
  137. _randomSpot = true;
  138.  
  139. //Wait for HIVE to be free
  140. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  141. _key call server_hiveWrite;
  142.  
  143. };
  144.  
  145. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  146.  
  147.  
  148. _isHiveOk = false; //EDITED
  149. if (_hiveVer >= dayz_hiveVersionNo) then {
  150. _isHiveOk = true;
  151. };
  152. //diag_log ("SERVER RESULT: " + str("X") + " " + str(dayz_hiveVersionNo));
  153.  
  154. //Server publishes variable to clients and WAITS
  155. //_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer],true];
  156.  
  157. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
  158. (owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement