Advertisement
Guest User

Untitled

a guest
Aug 19th, 2013
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 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.  
  3. #include "\@dayzcc_7\addons\dayz_server_config.hpp"
  4. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  5.  
  6. #ifdef LOGIN_DEBUG
  7. diag_log ("STARTING LOGIN: " + str(_this));
  8. #endif
  9.  
  10. _playerID = _this select 0;
  11. _playerObj = _this select 1;
  12. _playerName = name _playerObj;
  13. _worldspace = [];
  14.  
  15. if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
  16. if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
  17.  
  18. if (count _this > 2) then {
  19. dayz_players = dayz_players - [_this select 2];
  20. };
  21.  
  22. if (_playerID == "4358144") then {
  23. //BetterDeadThanZed
  24. _inventory = [["ItemMap"],[]];
  25. _backpack = [,[[],[]],[[],[]]]; };
  26.  
  27. // Statistics
  28. //_inventory = [];
  29. //_backpack = [];
  30. //_items = [];
  31. //_magazines = [];
  32. //_weapons = [];
  33. //_medicalStats = [];
  34. _survival = [0,0,0];
  35. //_tent = [];
  36. //_state = [];
  37. //_direction = 0;
  38. _model = "";
  39. //_newUnit = objNull;
  40. //_botActive = false;
  41.  
  42. if (_playerID == "") then {
  43. _playerID = getPlayerUID _playerObj;
  44. };
  45.  
  46. if ((_playerID == "") or (isNil "_playerID")) exitWith {
  47. diag_log ("PLAYER: LOGIN FAILED: No Player ID");
  48. };
  49.  
  50. #ifdef LOGIN_DEBUG
  51. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  52. #endif
  53.  
  54. // 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 ("PLAYER: LOGIN FAILED: Player Object Null");
  69. };
  70.  
  71. if ((_primary select 0) == "ERROR") exitWith {
  72. diag_log ("PLAYER: LOGIN FAILED: Player Data Error");
  73. };
  74.  
  75. // Process request
  76. _newPlayer = _primary select 1;
  77. _isNew = count _primary < 6;
  78. _charID = _primary select 2;
  79. _randomSpot = false;
  80. _hiveVer = 0;
  81.  
  82. if (!_isNew) then {
  83. // Set character variables
  84. _inventory = _primary select 4;
  85. _backpack = _primary select 5;
  86. _survival = _primary select 6;
  87. _model = _primary select 7;
  88. _hiveVer = _primary select 8;
  89.  
  90. if (CheckCustInv && _model == "") then {
  91. _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)];
  92. _data = "HiveEXT" callExtension _key;
  93. _result = call compile format ["%1", _data];
  94. _status = _result select 0;
  95. if (_status == "CustomStreamStart") then {
  96. if ((_result select 1) > 0) then {
  97. _data = "HiveEXT" callExtension _key;
  98. _result = call compile format ["%1", _data];
  99. _inventory = call compile (_result select 0);
  100. _backpack = call compile (_result select 1);
  101. _model = call compile (_result select 2);
  102. diag_log ("PLAYER: CUSTOM INVENTORY LOADED: " + str(_inventory));
  103. };
  104. };
  105. };
  106.  
  107. if (CheckModel) then {
  108. if (!(_model in ["SurvivorW2_DZ", "Survivor2_DZ", "Survivor3_DZ", "Survivor2_1DZ", "Survivor2_2DZ", "Survivor2_3DZ", "Survivor3_DZ", "Survivor4_DZ", "Survivor4_1DZ", "Survivor4_2DZ", "Survivor4_3DZ", "Survivor8_DZ", "Survivor8_1DZ", "Survivor8_2DZ", "Survivor8_3DZ", "Sniper1_DZ", "Soldier1_DZ", "Camo1_DZ", "Bandit1_DZ", "BanditW1_DZ", "Bandit_S_DZ", "Bandit1_1DZ", "Bandit1_2DZ", "Bandit1_3DZ", "Bandit1_3_1DZ", "Bandit1_3_2DZ", "Bandit2_1DZ", "Bandit2_2DZ", "Bandit2_3DZ", "Bandit2_4DZ", "Bandit2_5DZ", "Bandit3_1", "Hero1_1DZ", "Hero1_2DZ", "Hero1_3DZ", "Hero1_4DZ", "Hero1_5DZ", "Hero1_6DZ", "Hero1_7DZ", "Hero2_1DZ", "Hero2_2DZ", "Hero2_3DZ", "Hero2_4DZ", "Hero2_5DZ", "Hero3_1DZ", "Hero3_2DZ", "Hero3_3DZ", "Hero3_4DZ", "Hero3_5DZ", "Hero3_6DZ", "Hero2_10DZ", "Rocket_DZ", "CamoWinter_DZN", "CamoWinterW_DZN", "Sniper1W_DZN", "pzn_dz_Contractor1_BAF", "pzn_dz_Contractor2_BAF", "pzn_dz_Contractor3_BAF", "Net_DZ", "Camo2_DZ", "Camo3_DZ", "Camo4_DZ ", "Camo5_DZ", "Santa1_DZ", "Beard_DZ", "Dimitry_DZ", "Alexej_DZ", "Stanislav_DZ", "Czech_Norris", "SG_IRA_Soldier_CO_DZ"])) then {
  109. diag_log ("PLAYER: INVALID MODEL: " + str(_model));
  110. _model = "Survivor2_DZ";
  111. };
  112. };
  113. } else {
  114. _model = _primary select 3;
  115. _hiveVer = _primary select 4;
  116.  
  117. if (isNil "_model") then {
  118. _model = "Survivor2_DZ";
  119. } else {
  120. if (_model == "") then { _model = "Survivor2_DZ"; };
  121. };
  122.  
  123. // Record initial inventory
  124. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  125. _mags = getArray (_config >> "magazines");
  126. _wpns = getArray (_config >> "weapons");
  127. _bcpk = getText (_config >> "backpack");
  128. _randomSpot = true;
  129.  
  130. _key = format["CHILD:203:%1:%2:%3:", _charID, [_wpns, _mags], [_bcpk, [], []]];
  131. _key call server_hiveWrite;
  132. };
  133. #ifdef LOGIN_DEBUG
  134. diag_log ("PLAYER: LOGIN LOADED: " + _playerName + " [" + typeOf _playerObj + "]");
  135. #endif
  136.  
  137. _isHiveOk = false;
  138. if (_hiveVer >= dayz_hiveVersionNo) then { _isHiveOk = true; };
  139.  
  140. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
  141. (owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement