Dusty_Nuttles

server_playerLogin

May 27th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 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. diag_log ("STARTING LOGIN: " + str(_this));
  5.  
  6. _playerID = _this select 0;
  7. _playerObj = _this select 1;
  8. _playerName = name _playerObj;
  9. _worldspace = [];
  10.  
  11. if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
  12.  
  13. if (count _this > 2) then {
  14. dayz_players = dayz_players - [_this select 2];
  15. };
  16.  
  17. //Variables
  18. _inventory = [];
  19. _backpack = [];
  20. _items = [];
  21. _magazines = [];
  22. _weapons = [];
  23. _medicalStats = [];
  24. _survival = [0,0,0];
  25. _tent = [];
  26. _state = [];
  27. _direction = 0;
  28. _model = "";
  29. _newUnit = objNull;
  30. _botActive = false;
  31.  
  32. if (_playerID == "") then {
  33. _playerID = getPlayerUID _playerObj;
  34. };
  35.  
  36. if ((_playerID == "") or (isNil "_playerID")) exitWith {
  37. diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  38. };
  39.  
  40. //??? endLoadingScreen;
  41. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  42.  
  43. //Do Connection Attempt
  44. _doLoop = 0;
  45. while {_doLoop < 5} do {
  46. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  47. _primary = _key call server_hiveReadWrite;
  48. if (count _primary > 0) then {
  49. if ((_primary select 0) != "ERROR") then {
  50. _doLoop = 9;
  51. };
  52. };
  53. _doLoop = _doLoop + 1;
  54. };
  55.  
  56. if (isNull _playerObj or !isPlayer _playerObj) exitWith {
  57. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  58. };
  59.  
  60. if ((_primary select 0) == "ERROR") exitWith {
  61. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  62. };
  63.  
  64. //Process request
  65. _newPlayer = _primary select 1;
  66. _isNew = count _primary < 6; //_result select 1;
  67. _charID = _primary select 2;
  68. _randomSpot = false;
  69.  
  70. //diag_log ("LOGIN RESULT: " + str(_primary));
  71.  
  72. /* PROCESS */
  73. _hiveVer = 0;
  74.  
  75. if (!_isNew) then {
  76. //RETURNING CHARACTER
  77. _inventory = _primary select 4;
  78. _backpack = _primary select 5;
  79. _survival = _primary select 6;
  80. _model = _primary select 7;
  81. _hiveVer = _primary select 8;
  82.  
  83. if (_model == "") then {
  84. _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)];
  85. _data = "HiveEXT" callExtension _key;
  86.  
  87. //Process result
  88. _result = call compile format ["%1", _data];
  89. _status = _result select 0;
  90.  
  91. if (_status == "CustomStreamStart") then {
  92. if ((_result select 1) > 0) then {
  93. _data = "HiveEXT" callExtension _key;
  94. _result = call compile format ["%1", _data];
  95. _inventory = call compile (_result select 0);
  96. _backpack = call compile (_result select 1);
  97. _model = call compile (_result select 2);
  98. };
  99. };
  100. };
  101.  
  102. if (!(_model in ["SurvivorW2_DZ","Survivor2_DZ","Sniper1_DZ","Soldier1_DZ","Camo1_DZ","BanditW1_DZ",
  103. "Bandit1_DZ","SurvivorW2_DZ","Rocket_DZ","US_Soldier_EP1","BAF_Soldier_DDPM",
  104. "BAF_Soldier_Officer_DDPM","BAF_Soldier_MTP","BAF_Soldier_L_DDPM","GUE_Villager4","Ins_Soldier_Base","Ins_Commander","Ins_Soldier_Medic","Ins_Worker2","Ins_Woodlander1","Ins_Woodlander2","CZ_Soldier_DES_EP1"])) then {
  105. _model = "Survivor2_DZ";
  106. };
  107.  
  108. } else {
  109. _model = _primary select 3;
  110. _hiveVer = _primary select 4;
  111. if (isNil "_model") then {
  112. _model = "Survivor2_DZ";
  113. } else {
  114. if (_model == "") then {
  115. _model = "Survivor2_DZ";
  116. };
  117. };
  118.  
  119. //Record initial inventory
  120. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  121. _mags = getArray (_config >> "magazines");
  122. _wpns = getArray (_config >> "weapons");
  123. _bcpk = getText (_config >> "backpack");
  124. _randomSpot = true;
  125.  
  126. //Wait for HIVE to be free
  127. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  128. _key call server_hiveWrite;
  129.  
  130. };
  131. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  132.  
  133. _isHiveOk = false; //EDITED
  134. if (_hiveVer >= dayz_hiveVersionNo) then {
  135. _isHiveOk = true;
  136. };
  137. //diag_log ("SERVER RESULT: " + str("X") + " " + str(dayz_hiveVersionNo));
  138.  
  139. //Server publishes variable to clients and WAITS
  140. //_playerObj setVariable ["publish",[_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer],true];
  141.  
  142. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
  143. (owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment