Advertisement
Guest User

server_playerSetup.sqf

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