Advertisement
Guest User

server_playerSetup

a guest
Mar 7th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.68 KB | None | 0 0
  1. private ["_characterID","_playerObj","_playerID","_dummy","_worldspace","_state","_doLoop","_key","_primary","_medical","_stats","_humanity","_lastinstance","_friendlies","_randomSpot","_position","_debug","_distance","_hit","_fractures","_score","_findSpot","_pos","_isIsland","_w","_clientID","_spawnMC","_namespace"];
  2.  
  3. //diag_log ("SETUP: attempted with " + str(_this));
  4.  
  5. _characterID = _this select 0;
  6. _playerObj = _this select 1;
  7. _playerID = getPlayerUID _playerObj;
  8.  
  9. if (isNull _playerObj) exitWith {
  10. diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
  11. };
  12.  
  13. //Add MPHit event handler
  14. // diag_log("Adding MPHit EH for " + str(_playerObj));
  15. _playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];
  16.  
  17. if (_playerID == "") then {
  18. _playerID = getPlayerUID _playerObj;
  19. };
  20.  
  21. if (_playerID == "") exitWith {
  22. diag_log ("SETUP INIT FAILED: Exiting, no player ID: " + str(_playerObj));
  23. };
  24.  
  25. private["_dummy"];
  26. _dummy = getPlayerUID _playerObj;
  27. if ( _playerID != _dummy ) then {
  28. diag_log format["DEBUG: _playerID miscompare with UID! _playerID:%1",_playerID];
  29. _playerID = _dummy;
  30. };
  31.  
  32. //Variables
  33. _worldspace = [];
  34.  
  35. _state = [];
  36.  
  37. //Do Connection Attempt
  38. _doLoop = 0;
  39. while {_doLoop < 5} do {
  40. _key = format["CHILD:102:%1:",_characterID];
  41. _primary = _key call server_hiveReadWrite;
  42. if (count _primary > 0) then {
  43. if ((_primary select 0) != "ERROR") then {
  44. _doLoop = 9;
  45. };
  46. };
  47. _doLoop = _doLoop + 1;
  48. };
  49.  
  50. if (isNull _playerObj || !isPlayer _playerObj) exitWith {
  51. diag_log ("SETUP RESULT: Exiting, player object null: " + str(_playerObj));
  52. };
  53.  
  54. //Wait for HIVE to be free
  55. //diag_log ("SETUP: RESULT: Successful with " + str(_primary));
  56.  
  57. _medical = _primary select 1;
  58. _stats = _primary select 2;
  59. _state = _primary select 3;
  60. _worldspace = _primary select 4;
  61. _humanity = _primary select 5;
  62. _lastinstance = _primary select 6;
  63.  
  64. //Set position
  65. _randomSpot = false;
  66.  
  67. if (count _worldspace > 0) then {
  68.  
  69. _position = _worldspace select 1;
  70. if (count _position < 3) then {
  71. //prevent debug world!
  72. _randomSpot = true;
  73. };
  74. _debug = getMarkerpos "respawn_west";
  75. _distance = _debug distance _position;
  76. if (_distance < 2000) then {
  77. _randomSpot = true;
  78. };
  79.  
  80. _distance = [0,0,0] distance _position;
  81. if (_distance < 500) then {
  82. _randomSpot = true;
  83. };
  84.  
  85. // Came from another server force random spawn
  86. if (_lastinstance != dayZ_instance) then {
  87. _randomSpot = true;
  88. };
  89.  
  90. //_playerObj setPosATL _position;
  91. } else {
  92. _randomSpot = true;
  93. };
  94.  
  95. //diag_log ("LOGIN: Location: " + str(_worldspace) + " doRnd?: " + str(_randomSpot));
  96.  
  97. //set medical values
  98. if (count _medical > 0) then {
  99. _playerObj setVariable["USEC_isDead",(_medical select 0),true];
  100. _playerObj setVariable["NORRN_unconscious", (_medical select 1), true];
  101. _playerObj setVariable["USEC_infected",(_medical select 2),true];
  102. _playerObj setVariable["USEC_injured",(_medical select 3),true];
  103. _playerObj setVariable["USEC_inPain",(_medical select 4),true];
  104. _playerObj setVariable["USEC_isCardiac",(_medical select 5),true];
  105. _playerObj setVariable["USEC_lowBlood",(_medical select 6),true];
  106. _playerObj setVariable["USEC_BloodQty",(_medical select 7),true];
  107. _playerObj setVariable["unconsciousTime",(_medical select 10),true];
  108.  
  109. //Add Wounds
  110. {
  111. _playerObj setVariable[_x,true,true];
  112. //["usecBleed",[_playerObj,_x,_hit]] call broadcastRpcCallAll;
  113. usecBleed = [_playerObj,_x,_hit];
  114. publicVariable "usecBleed";
  115. } count (_medical select 8);
  116.  
  117. //Add fractures
  118. _fractures = (_medical select 9);
  119. _playerObj setVariable ["hit_legs",(_fractures select 0),true];
  120. _playerObj setVariable ["hit_hands",(_fractures select 1),true];
  121.  
  122. if (count _medical > 11) then {
  123. //Additional medical stats
  124. _playerObj setVariable ["messing",(_medical select 11),true];
  125. };
  126.  
  127. } else {
  128. //Reset Fractures
  129. _playerObj setVariable ["hit_legs",0,true];
  130. _playerObj setVariable ["hit_hands",0,true];
  131. _playerObj setVariable ["USEC_injured",false,true];
  132. _playerObj setVariable ["USEC_inPain",false,true];
  133. _playerObj setVariable ["messing",[0,0],true];
  134. };
  135.  
  136. if (count _stats > 0) then {
  137. //register stats
  138. _playerObj setVariable["zombieKills",(_stats select 0),true];
  139. _playerObj setVariable["headShots",(_stats select 1),true];
  140. _playerObj setVariable["humanKills",(_stats select 2),true];
  141. _playerObj setVariable["banditKills",(_stats select 3),true];
  142. _playerObj addScore (_stats select 1);
  143.  
  144. //Save Score
  145. _score = score _playerObj;
  146. _playerObj addScore ((_stats select 0) - _score);
  147.  
  148. //record for Server JIP checks
  149. _playerObj setVariable["zombieKills_CHK",(_stats select 0)];
  150. _playerObj setVariable["headShots_CHK",(_stats select 1)];
  151. _playerObj setVariable["humanKills_CHK",(_stats select 2)];
  152. _playerObj setVariable["banditKills_CHK",(_stats select 3)];
  153. if (count _stats > 4) then {
  154. if (!(_stats select 3)) then {
  155. _playerObj setVariable["selectSex",true,true];
  156. };
  157. } else {
  158. _playerObj setVariable["selectSex",true,true];
  159. };
  160. } else {
  161. //Save initial loadout
  162. //register stats
  163. _playerObj setVariable["zombieKills",0,true];
  164. _playerObj setVariable["humanKills",0,true];
  165. _playerObj setVariable["banditKills",0,true];
  166. _playerObj setVariable["headShots",0,true];
  167.  
  168. //record for Server JIP checks
  169. _playerObj setVariable["zombieKills_CHK",0];
  170. _playerObj setVariable["humanKills_CHK",0,true];
  171. _playerObj setVariable["banditKills_CHK",0,true];
  172. _playerObj setVariable["headShots_CHK",0];
  173. };
  174.  
  175. if (_randomSpot) then {
  176. if (!isDedicated) then {endLoadingScreen;};
  177. _debug = getMarkerpos "respawn_west";
  178. _worldspace = [0,[_debug select 0,_debug select 1,0.3]];
  179. };
  180.  
  181. //Record player for management
  182. dayz_players set [count dayz_players,_playerObj];
  183.  
  184. //record player pos locally for server checking
  185. _playerObj setVariable["CharacterID",_characterID,true];
  186. _playerObj setVariable["humanity",_humanity,true];
  187. _playerObj setVariable["humanity_CHK",_humanity];
  188. //_playerObj setVariable["worldspace",_worldspace,true];
  189. //_playerObj setVariable["state",_state,true];
  190. _playerObj setVariable["lastPos",getPosATL _playerObj];
  191.  
  192. dayzPlayerLogin2 = [_worldspace,_state,_randomSpot];
  193.  
  194. // PVDZE_obj_Debris = DZE_LocalRoadBlocks;
  195. _clientID = owner _playerObj;
  196. if (!isNull _playerObj) then {
  197. _clientID publicVariableClient "dayzPlayerLogin2";
  198.  
  199. if (isNil "PVDZE_plr_SetDate") then {
  200. call server_timeSync;
  201. };
  202. _clientID publicVariableClient "PVDZE_plr_SetDate";
  203. };
  204. //record time started
  205. _playerObj setVariable ["lastTime",time];
  206. //_playerObj setVariable ["model_CHK",typeOf _playerObj];
  207.  
  208. //diag_log ("LOGIN PUBLISHING: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  209.  
  210. PVDZE_plr_Login = nil;
  211. PVDZE_plr_Login2 = nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement