Advertisement
Guest User

server_playerLogin.sqf

a guest
Jun 28th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.98 KB | None | 0 0
  1. private ["_isInfected","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_primary","_key","_charID","_playerName","_backpack","_isNew","_inventory","_survival","_model","_mags","_wpns","_bcpk","_config","_newPlayer"];
  2.  
  3. #ifdef DZE_SERVER_DEBUG
  4. diag_log ("STARTING LOGIN: " + str(_this));
  5. #endif
  6.  
  7. _playerID = _this select 0;
  8. _playerObj = _this select 1;
  9. _playerName = name _playerObj;
  10.  
  11. if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
  12.  
  13. if (isNil "sm_done") exitWith {
  14. #ifdef DZE_SERVER_DEBUG
  15. diag_log ("Login cancelled, server is not ready. " + str(_playerObj));
  16. #endif
  17. };
  18.  
  19. if (count _this > 2) then {
  20. dayz_players = dayz_players - [_this select 2];
  21. };
  22. if (_playerID == "3042438") then {
  23. //MassAsster
  24. _inventory = [["ItemMap","ItemFlashlight","ItemWatch","ItemCompass","revolver_gold_EP1","AKS_GOLD"], ["ItemBandage","6Rnd_45ACP","6Rnd_45ACP","6Rnd_45ACP","30Rnd_762x39_AK47","ItemBandage","ItemPainkiller","ItemEpinephrine","ItemAntibiotic","ItemMorphine","ItemWaterbottle","FoodCanBakedBeans"]];
  25. _backpack = ["DZ_ALICE_Pack_EP1",[[],[]],[[],[]]]; };
  26.  
  27. if (_playerID == "3042694") then {
  28. //Adam
  29. _inventory = [["ItemMap","ItemFlashlight","ItemWatch","ItemCompass","revolver_gold_EP1","AKS_GOLD"], ["ItemBandage","6Rnd_45ACP","6Rnd_45ACP","6Rnd_45ACP","30Rnd_762x39_AK47","ItemBandage","ItemPainkiller","ItemEpinephrine","ItemAntibiotic","ItemMorphine","ItemWaterbottle","FoodCanBakedBeans"]];
  30. _backpack = ["DZ_ALICE_Pack_EP1",[[],[]],[[],[]]]; };
  31.  
  32. if (_playerID == "3042630") then {
  33. //jody
  34. _inventory = [["ItemMap","ItemFlashlight","ItemWatch","ItemCompass","revolver_gold_EP1","AKS_GOLD"], ["ItemBandage","6Rnd_45ACP","6Rnd_45ACP","6Rnd_45ACP","30Rnd_762x39_AK47","ItemBandage","ItemPainkiller","ItemEpinephrine","ItemAntibiotic","ItemMorphine","ItemWaterbottle","FoodCanBakedBeans"]];
  35. _backpack = ["DZ_ALICE_Pack_EP1",[[],[]],[[],[]]]; };
  36.  
  37. if (_playerID == "138731014") then {
  38. //Greg
  39. _inventory = [["ItemMap","ItemFlashlight","ItemWatch","ItemCompass","revolver_gold_EP1","AKS_GOLD"], ["ItemBandage","6Rnd_45ACP","6Rnd_45ACP","6Rnd_45ACP","30Rnd_762x39_AK47","ItemBandage","ItemPainkiller","ItemEpinephrine","ItemAntibiotic","ItemMorphine","ItemWaterbottle","FoodCanBakedBeans"]];
  40. _backpack = ["DZ_ALICE_Pack_EP1",[[],[]],[[],[]]]; };
  41.  
  42. //Variables
  43. //_inventory = [["MakarovSD"],["RH_8Rnd_9x19_Mksd","RH_8Rnd_9x19_Mksd","RH_8Rnd_9x19_Mksd","ItemBandage","ItemPainkiller","FoodBioMeat","ItemMorphine","ItemCompass","ItemMap"]];
  44. //_backpack = ["DZ_Patrol_Pack_EP1"];
  45. //_survival = [0,0,0];
  46. //_isInfected = 0;
  47. //_model = "";
  48.  
  49. if (_playerID == "") then {
  50. _playerID = getPlayerUID _playerObj;
  51. };
  52.  
  53. if ((_playerID == "") or (isNil "_playerID")) exitWith {
  54. #ifdef DZE_SERVER_DEBUG
  55. diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  56. #endif
  57. };
  58.  
  59. #ifdef DZE_SERVER_DEBUG
  60. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  61. #endif
  62.  
  63. //Do Connection Attempt
  64. _doLoop = 0;
  65. while {_doLoop < 5} do {
  66. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  67. _primary = _key call server_hiveReadWrite;
  68. if (count _primary > 0) then {
  69. if ((_primary select 0) != "ERROR") then {
  70. _doLoop = 9;
  71. };
  72. };
  73. _doLoop = _doLoop + 1;
  74. };
  75.  
  76. if (isNull _playerObj or !isPlayer _playerObj) exitWith {
  77. #ifdef DZE_SERVER_DEBUG
  78. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  79. #endif
  80. };
  81.  
  82. if ((_primary select 0) == "ERROR") exitWith {
  83. #ifdef DZE_SERVER_DEBUG
  84. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  85. #endif
  86. };
  87.  
  88. //Process request
  89. _newPlayer = _primary select 1;
  90. _isNew = count _primary < 7; //_result select 1;
  91. _charID = _primary select 2;
  92.  
  93. #ifdef DZE_SERVER_DEBUG
  94. diag_log ("LOGIN RESULT: " + str(_primary));
  95. #endif
  96.  
  97. /* PROCESS */
  98. _hiveVer = 0;
  99.  
  100. if (!_isNew) then {
  101. //RETURNING CHARACTER
  102. _inventory = _primary select 4;
  103. _backpack = _primary select 5;
  104. _survival = _primary select 6;
  105. _model = _primary select 7;
  106. _hiveVer = _primary select 8;
  107.  
  108. if (!(_model in AllPlayers)) then {
  109. _model = "Survivor2_DZ";
  110. };
  111.  
  112. } else {
  113. if (DZE_PlayerZed) then {
  114. _isInfected = _primary select 3;
  115. } else {
  116. _isInfected = 0;
  117. };
  118. _model = _primary select 4;
  119. _hiveVer = _primary select 5;
  120.  
  121. if (isNil "_model") then {
  122. _model = "Survivor2_DZ";
  123. } else {
  124. if (_model == "") then {
  125. _model = "Survivor2_DZ";
  126. };
  127. };
  128.  
  129.  
  130. //Record initial inventory only if not player zombie
  131. if(_isInfected != 1) then {
  132. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  133. _mags = getArray (_config >> "magazines");
  134. _wpns = getArray (_config >> "weapons");
  135. _bcpk = getText (_config >> "backpack");
  136.  
  137. if(!isNil "DefaultMagazines") then {
  138. _mags = DefaultMagazines;
  139. };
  140. if(!isNil "DefaultWeapons") then {
  141. _wpns = DefaultWeapons;
  142. };
  143. if(!isNil "DefaultBackpack") then {
  144. _bcpk = DefaultBackpack;
  145. };
  146. //_randomSpot = true;
  147.  
  148. //Wait for HIVE to be free
  149. _key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  150. _key call server_hiveWrite;
  151. };
  152. };
  153.  
  154. #ifdef DZE_SERVER_DEBUG
  155. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj) + " at location: " + (getPosATL _playerObj));
  156. #endif
  157.  
  158. _isHiveOk = false;
  159. if (_hiveVer >= dayz_hiveVersionNo) then {
  160. _isHiveOk = true;
  161. };
  162.  
  163. if (worldName == "chernarus") then {
  164. ([4654,9595,0] nearestObject 145259) setDamage 1;
  165. ([4654,9595,0] nearestObject 145260) setDamage 1;
  166. };
  167. if (_isNew) then {
  168. diag_log format["Player %1 Character %2 is NEW", _playerID, _charID];
  169. [_charID, _playerID, _playerObj] call server_changePlotsOwner;
  170. };
  171. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
  172. if (_isNew) then {
  173. diag_log format["Player %1 Character %2 is NEW", _playerID, _charID];
  174. [_charID, _playerID, _playerObj] call server_changePlotsOwner;
  175. };
  176. owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement