Guest User

server_playerlogin

a guest
Aug 30th, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 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. #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 in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ","Bandit1_DZ","Survivor3_DZ","CamoWinter_DZN","CamoWinterW_DZN","Sniper1W_DZN"])) then {
  96. _model = "Survivor2_DZ";
  97. };
  98.  
  99. } else {
  100. if (isNil "_model" || _model == "") then {
  101. _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)];
  102. _data = "HiveEXT" callExtension _key;
  103. //Process result
  104. _result = call compile format ["%1", _data];
  105. _status = _result select 0;
  106. if (_status == "CustomStreamStart") then {
  107. if ((_result select 1) > 0) then {
  108. _data = "HiveEXT" callExtension _key;
  109. _result = call compile format ["%1", _data];
  110. _inventory = call compile (_result select 0);
  111. _backpack = call compile (_result select 1);
  112. _model = call compile (_result select 2);
  113. _isNew = false; // new line
  114. };
  115. };
  116. };
  117.  
  118. _hiveVer = _primary select 4;
  119. if (isNil "_model") then {
  120. _model = "Survivor2_DZ";
  121. } else {
  122. if (_model == "") then {
  123. _model = "Survivor2_DZ";
  124. };
  125. };
  126.  
  127.  
  128. //Record initial inventory
  129. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  130. _mags = getArray (_config >> "magazines");
  131. _wpns = getArray (_config >> "weapons");
  132. _bcpk = getText (_config >> "backpack");
  133. _randomSpot = true;
  134.  
  135. //Wait for HIVE to be free
  136. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  137. _key call server_hiveWrite;
  138.  
  139. };
  140. #ifdef LOGIN_DEBUG
  141. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  142. #endif
  143.  
  144. _isHiveOk = false; //EDITED
  145. if (_hiveVer >= dayz_hiveVersionNo) then {
  146. _isHiveOk = true;
  147. };
  148. //diag_log ("SERVER RESULT: " + str("X") + " " + str(dayz_hiveVersionNo));
  149.  
  150. //Server publishes variable to clients and WAITS
  151. //_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer],true];
  152.  
  153. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,dayzNam_versionNo,_model,_isHiveOk,_newPlayer];
  154. (owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment