Advertisement
Guest User

Adjusted server_playerLogin.sqf

a guest
Dec 7th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. private ["_botActive","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_randomSpot","_primary","_key","_charID","_playerName","_items","_magazines","_weapons","_backpack","_worldspace","_direction","_newUnit","_isNew","_inventory","_survival","_state","_model","_config","_mags","_wpns","_bcpk","_medicalStats","_tent","_newPlayer"];
  2. //Set Variables
  3.  
  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.  
  17. // Cancel any login until server_monitor terminates.
  18. // This is mandatory since all vehicles must be spawned before the first players spawn on the map.
  19. // Otherwise, all vehicle event handlers won't be created on players' client side.
  20. if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
  21.  
  22.  
  23. if (count _this > 2) then {
  24. dayz_players = dayz_players - [_this select 2];
  25. };
  26.  
  27. //Variables
  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 ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  48. };
  49.  
  50. //??? endLoadingScreen;
  51. #ifdef LOGIN_DEBUG
  52. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  53. #endif
  54.  
  55. //Do Connection Attempt
  56. _doLoop = 0;
  57. while {_doLoop < 5} do {
  58. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  59. _primary = _key call server_hiveReadWrite;
  60. if (count _primary > 0) then {
  61. if ((_primary select 0) != "ERROR") then {
  62. _doLoop = 9;
  63. };
  64. };
  65. _doLoop = _doLoop + 1;
  66. };
  67.  
  68. if (isNull _playerObj or !isPlayer _playerObj) exitWith {
  69. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  70. };
  71.  
  72. if ((_primary select 0) == "ERROR") exitWith {
  73. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  74. };
  75.  
  76. //Process request
  77. _newPlayer = _primary select 1;
  78. _isNew = count _primary < 6; //_result select 1;
  79. _charID = _primary select 2;
  80. _randomSpot = false;
  81.  
  82. //diag_log ("LOGIN RESULT: " + str(_primary));
  83.  
  84. /* PROCESS */
  85. _hiveVer = 0;
  86.  
  87. if (!_isNew) then {
  88. //RETURNING CHARACTER
  89. _inventory = _primary select 4;
  90. _backpack = _primary select 5;
  91. _survival = _primary select 6;
  92. _model = _primary select 7;
  93. _hiveVer = _primary select 8;
  94.  
  95. if (_model == "") then {
  96. _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)];
  97. _data = "HiveEXT" callExtension _key;
  98. //Process result
  99. _result = call compile format ["%1", _data];
  100. _status = _result select 0;
  101. if (_status == "CustomStreamStart") then {
  102. if ((_result select 1) > 0) then {
  103. _data = "HiveEXT" callExtension _key;
  104. _result = call compile format ["%1", _data];
  105. _inventory = call compile (_result select 0);
  106. _backpack = call compile (_result select 1);
  107. _model = call compile (_result select 2);
  108. };
  109. };
  110. };
  111. //if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","SurvivorW2_DZ","US_Soldier_EP1"])) then {
  112. // _model = "Survivor2_DZ";
  113. //};
  114.  
  115. } else {
  116. _model = _primary select 3;
  117. _hiveVer = _primary select 4;
  118. if (isNil "_model") then {
  119. _model = "Survivor2_DZ";
  120. } else {
  121. if (_model == "") then {
  122. _model = "Survivor2_DZ";
  123. };
  124. };
  125.  
  126. switch (_playerID) do {
  127. case "24817414": { _model = "US_Soldier_EP1"; }; //Rick
  128. case "112994822": { _model = "US_Soldier_EP1"; }; //Walker
  129. case "103659014": { _model = "US_Soldier_EP1"; }; //Cody
  130. case "130451206": { _model = "US_Soldier_EP1"; }; //Blue
  131. default {};
  132. };
  133.  
  134. //Record initial inventory
  135. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  136. _mags = getArray (_config >> "magazines");
  137. _wpns = getArray (_config >> "weapons");
  138. _bcpk = getText (_config >> "backpack");
  139. _randomSpot = true;
  140.  
  141. //Wait for HIVE to be free
  142. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  143. _key call server_hiveWrite;
  144.  
  145. };
  146. #ifdef LOGIN_DEBUG
  147. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  148. #endif
  149.  
  150. _isHiveOk = false; //EDITED
  151. if (_hiveVer >= dayz_hiveVersionNo) then {
  152. _isHiveOk = true;
  153. };
  154. //diag_log ("SERVER RESULT: " + str("X") + " " + str(dayz_hiveVersionNo));
  155.  
  156. //Server publishes variable to clients and WAITS
  157. //_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer],true];
  158. ([4654,9595,0] nearestObject 145259) setDamage 1;
  159. ([4654,9595,0] nearestObject 145260) setDamage 1;
  160.  
  161. PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
  162. (owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement