Advertisement
Guest User

gender/zombie server_playerLogin.sqf

a guest
Sep 28th, 2014
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.27 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.  
  23. //Variables
  24. _inventory = [];
  25. _backpack = [];
  26. _survival = [0,0,0];
  27. _isInfected = 0;
  28. _model = "";
  29.  
  30. if (_playerID == "") then {
  31. _playerID = getPlayerUID _playerObj;
  32. };
  33.  
  34. if ((_playerID == "") || (isNil "_playerID")) exitWith {
  35. #ifdef DZE_SERVER_DEBUG
  36. diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
  37. #endif
  38. };
  39.  
  40. #ifdef DZE_SERVER_DEBUG
  41. diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
  42. #endif
  43.  
  44. //Do Connection Attempt
  45. _doLoop = 0;
  46. while {_doLoop < 5} do {
  47. _key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
  48. diag_log (_key);
  49. _key = format["\cache\players\%1\%2.sqf", MyPlayerCounter, toLower(_playerID)];
  50. diag_log ("LOAD PLAYER: "+_key);
  51. _res = preprocessFile _key;
  52. diag_log ("PLAYER CACHE: "+_res);
  53.  
  54. if ((_res == "") or (isNil "_res")) then {
  55. _key = format["\cache\players\%1\%2.sqf", (MyPlayerCounter-1), toLower(_playerID)];
  56. diag_log ("BACKLOAD PLAYER: "+_key);
  57. _res = preprocessFile _key;
  58. diag_log ("PLAYER CACHE: "+_res);
  59. };
  60. if ((_res == "") or (isNil "_res")) then {
  61. _res = preprocessFile "\cache\players\default.sqf";
  62. diag_log ("PLAYER DEFAULT CACHE: "+_res);
  63. if ((_res == "") or (isNil "_res")) then {
  64. _primary = ["PASS",false,"1",[],[["ItemFlashlight","ItemMap","ItemGPS"],["ItemBandage"]],["DZ_Patrol_Pack_EP1",[],[]],[0,0,0],"Survivor2_DZ",0.96,0];
  65. } else {
  66. _primary = call compile _res;
  67. };
  68. } else {
  69. _primary = call compile _res;
  70. };
  71. _res = nil;
  72.  
  73. MyPlayerCounter = MyPlayerCounter + 1;
  74. diag_log format["CHILD:11:%1:", MyPlayerCounter];
  75.  
  76. if (count _primary > 0) then {
  77. if ((_primary select 0) != "ERROR") then {
  78. _doLoop = 9;
  79. };
  80. };
  81. _doLoop = _doLoop + 1;
  82. };
  83.  
  84. if (isNull _playerObj || !isPlayer _playerObj) exitWith {
  85. #ifdef DZE_SERVER_DEBUG
  86. diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
  87. #endif
  88. };
  89.  
  90. if ((_primary select 0) == "ERROR") exitWith {
  91. #ifdef DZE_SERVER_DEBUG
  92. diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
  93. #endif
  94. };
  95.  
  96. //Process request
  97. _newPlayer = _primary select 1;
  98. ///// jahan (gender select/play as zombie)
  99. /////_isNew = count _primary < 7; //_result select 1;
  100. _isNew = false;
  101. _isNew = count (_primary select 3) < 1;
  102.  
  103. _charID = _primary select 2;
  104.  
  105. #ifdef DZE_SERVER_DEBUG
  106. diag_log ("LOGIN RESULT: " + str(_primary));
  107. #endif
  108.  
  109. /* PROCESS */
  110. _hiveVer = 0;
  111.  
  112. if (!_isNew) then {
  113. //RETURNING CHARACTER
  114. _inventory = _primary select 4;
  115. _backpack = _primary select 5;
  116. _survival = _primary select 6;
  117. _model = _primary select 7;
  118. _hiveVer = _primary select 8;
  119.  
  120. if (!(_model in AllPlayers)) then {
  121. _model = "Survivor2_DZ";
  122. };
  123.  
  124. } else {
  125.  
  126. if (DZE_PlayerZed) then {
  127. ///// jahan (gender select/play as zombie)
  128. _isInfected = _primary select 9;
  129. } else {
  130. _isInfected = 0;
  131. };
  132. ///// jahan (gender select/play as zombie)
  133. _model = _primary select 7;
  134. _hiveVer = _primary select 8;
  135.  
  136.  
  137. if (isNil "_model") then {
  138. _model = "Survivor2_DZ";
  139. } else {
  140. if (_model == "") then {
  141. _model = "Survivor2_DZ";
  142. };
  143. };
  144.  
  145. //Record initial inventory only if not player zombie
  146. if(_isInfected != 1) then {
  147. _config = (configFile >> "CfgSurvival" >> "Inventory" >> "Default");
  148. _mags = getArray (_config >> "magazines");
  149. _wpns = getArray (_config >> "weapons");
  150. _bcpk = getText (_config >> "backpack");
  151.  
  152. if(!isNil "DefaultMagazines") then {
  153. _mags = DefaultMagazines;
  154. };
  155. if(!isNil "DefaultWeapons") then {
  156. _wpns = DefaultWeapons;
  157. };
  158. if(!isNil "DefaultBackpack") then {
  159. _bcpk = DefaultBackpack;
  160. };
  161. //_randomSpot = true;
  162.  
  163. //Wait for HIVE to be free
  164. diag_log format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
  165. };
  166. };
  167.  
  168. #ifdef DZE_SERVER_DEBUG
  169. diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj) + " at location: " + (getPosATL _playerObj));
  170. #endif
  171.  
  172. _isHiveOk = false;
  173. if (_hiveVer >= dayz_hiveVersionNo) then {
  174. _isHiveOk = true;
  175. };
  176.  
  177. if (worldName == "chernarus") then {
  178. ([4654,9595,0] nearestObject 145259) setDamage 1;
  179. ([4654,9595,0] nearestObject 145260) setDamage 1;
  180. };
  181.  
  182. dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
  183. (owner _playerObj) publicVariableClient "dayzPlayerLogin";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement