Advertisement
Guest User

Rusty

a guest
Aug 24th, 2014
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.07 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. _playerObj setVariable ["moneychanged",0,true];
  144. _playerObj setVariable ["bankchanged",0,true];
  145. _playerObj setVariable["AsReMixhud", true,true];
  146.  
  147.  
  148. //Save Score
  149. _score = score _playerObj;
  150. _playerObj addScore ((_stats select 0) - _score);
  151.  
  152. //record for Server JIP checks
  153. _playerObj setVariable["zombieKills_CHK",(_stats select 0)];
  154. _playerObj setVariable["headShots_CHK",(_stats select 1)];
  155. _playerObj setVariable["humanKills_CHK",(_stats select 2)];
  156. _playerObj setVariable["banditKills_CHK",(_stats select 3)];
  157. if (count _stats > 4) then {
  158. if (!(_stats select 3)) then {
  159. _playerObj setVariable["selectSex",true,true];
  160. };
  161. } else {
  162. _playerObj setVariable["selectSex",true,true];
  163. };
  164. } else {
  165. //Save initial loadout
  166. //register stats
  167. _playerObj setVariable["zombieKills",0,true];
  168. _playerObj setVariable["humanKills",0,true];
  169. _playerObj setVariable["banditKills",0,true];
  170. _playerObj setVariable["headShots",0,true];
  171. _playerObj setVariable ["moneychanged",0,true];
  172. _playerObj setVariable ["bankchanged",0,true];
  173. _playerObj setVariable ["friendlies",[],true];
  174. _playerObj setVariable["AsReMixhud", true,true];
  175.  
  176. //record for Server JIP checks
  177. _playerObj setVariable["zombieKills_CHK",0,true];
  178. _playerObj setVariable["humanKills_CHK",0,true];
  179. _playerObj setVariable["banditKills_CHK",0,true];
  180. _playerObj setVariable["headShots_CHK",0,true];
  181. };
  182.  
  183. if (_randomSpot) then {
  184. private["_counter","_position","_isNear","_isZero","_mkr"];
  185. if (!isDedicated) then {
  186. endLoadingScreen;
  187. };
  188.  
  189. //Spawn modify via mission init.sqf
  190. if(isnil "spawnArea") then {
  191. spawnArea = 1500;
  192. };
  193. if(isnil "spawnShoremode") then {
  194. spawnShoremode = 1;
  195. };
  196.  
  197. //
  198. _spawnMC = actualSpawnMarkerCount;
  199.  
  200. //spawn into random
  201. _findSpot = true;
  202. _mkr = "";
  203. while {_findSpot} do {
  204. _counter = 0;
  205. while {_counter < 20 && _findSpot} do {
  206. // switched to floor
  207. _mkr = "spawn" + str(floor(random _spawnMC));
  208. _position = ([(getMarkerPos _mkr),0,spawnArea,10,0,2000,spawnShoremode] call BIS_fnc_findSafePos);
  209. _isNear = count (_position nearEntities ["Man",100]) == 0;
  210. _isZero = ((_position select 0) == 0) && ((_position select 1) == 0);
  211. //Island Check //TeeChange
  212. _pos = _position;
  213. _isIsland = false; //Can be set to true during the Check
  214. for [{_w=0},{_w<=150},{_w=_w+2}] do {
  215. _pos = [(_pos select 0),((_pos select 1) + _w),(_pos select 2)];
  216. if(surfaceisWater _pos) exitWith {
  217. _isIsland = true;
  218. };
  219. };
  220.  
  221. if ((_isNear && !_isZero) || _isIsland) then {_findSpot = false};
  222. _counter = _counter + 1;
  223. };
  224. };
  225. _isZero = ((_position select 0) == 0) && ((_position select 1) == 0);
  226. _position = [_position select 0,_position select 1,0];
  227. if (!_isZero) then {
  228. //_playerObj setPosATL _position;
  229. _worldspace = [0,_position];
  230. };
  231. };
  232.  
  233. //Record player for management
  234. dayz_players set [count dayz_players,_playerObj];
  235.  
  236. //record player pos locally for server checking
  237. _playerObj setVariable["CharacterID",_characterID,true];
  238. _playerObj setVariable["humanity",_humanity,true];
  239. _playerObj setVariable["humanity_CHK",_humanity];
  240. //_playerObj setVariable["worldspace",_worldspace,true];
  241. //_playerObj setVariable["state",_state,true];
  242. _playerObj setVariable["lastPos",getPosATL _playerObj];
  243.  
  244. dayzPlayerLogin2 = [_worldspace,_state];
  245.  
  246. // PVDZE_obj_Debris = DZE_LocalRoadBlocks;
  247. _clientID = owner _playerObj;
  248. if (!isNull _playerObj) then {
  249. _clientID publicVariableClient "dayzPlayerLogin2";
  250.  
  251. if (isNil "PVDZE_plr_SetDate") then {
  252. call server_timeSync;
  253. };
  254. _clientID publicVariableClient "PVDZE_plr_SetDate";
  255. };
  256. //record time started
  257. _playerObj setVariable ["lastTime",time];
  258. //_playerObj setVariable ["model_CHK",typeOf _playerObj];
  259.  
  260. // ------------ ZUPA - Single Currency - Get Bank Value ----------------
  261.  
  262. _playerIDzupa = getPlayerUID _playerObj;
  263. _bankingstart = 0;
  264. if(_playerIDzupa != "")then{
  265. _key = format["CHILD:999:SELECT `PlayerMorality` FROM `player_data` WHERE `PlayerUID` = '%1':[0]:",_playerIDzupa];
  266. _result = _key call server_hiveReadWrite;
  267. _status = _result select 0; // get the status of the result
  268. if (_status == "CustomStreamStart") then { //check if the stream coming from the hive was opened
  269. _val = _result select 1; // get the number of entries that will be coming in the stream
  270. if(_val > 0) then {
  271. _result = _key call server_hiveReadWrite;
  272. _bankingstart = _result select 0;
  273. };
  274. };
  275. _playerObj setVariable["bank",_bankingstart,true];
  276. };
  277.  
  278. // ------------ ZUPA - END ----------------
  279.  
  280. //diag_log ("LOGIN PUBLISHING: " + str(_playerObj) + " Type: " + (typeOf _playerObj));
  281.  
  282. PVDZE_plr_Login = nil;
  283. PVDZE_plr_Login2 = nil;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement