Advertisement
Guest User

Untitled

a guest
Sep 19th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 7.35 KB | None | 0 0
  1. /**
  2.  * Exile Mod
  3.  * www.exilemod.com
  4.  * © 2015 Exile Mod Team
  5.  *
  6.  * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
  7.  * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
  8.  *
  9.  * Modified by eraser1
  10.  */
  11.  
  12. private["_data","_oldPlayerObject","_playerUID","_sessionID","_position","_resetPosAboveObj","_intersectingObjs","_intersectingObj","_intersectingObjTopPos","_direction","_player","_clanID","_clanName","_headgear","_goggles","_binocular","_uniform","_vest","_backpack","_uniformContainer","_vestContainer","_backpackContainer","_loadObject","_primaryWeapon","_handgunWeapon","_secondaryWeapon","_currentWeapon","_assigned"];
  13. _data = _this select 0;
  14. _oldPlayerObject = _this select 1;
  15. _playerUID = _this select 2;
  16. _sessionID = _this select 3;
  17. _name = name _oldPlayerObject;
  18. _position = [_data select 16, _data select 17, _data select 18];
  19.  
  20. _resetPosAboveObj = false;
  21. if ((_position select 2)>2.5) then
  22. {
  23.     _intersectingObjs = lineIntersectsWith [ATLtoASL _position, [_position select 0,_position select 1,0], objNull, objNull, true];
  24.  
  25.     if (_intersectingObjs isEqualTo []) then
  26.     {
  27.         diag_log format ["Resetting player altitude to 0; Pos of %1 (%2) is above 2.5 meters, but there's nothing below the player!",_name,_playerUID];
  28.         _position set [2,0];
  29.     }
  30.     else
  31.     {
  32.         _intersectingObj = _intersectingObjs select ((count _intersectingObjs)-1);
  33.         _intersectingObjTopPos = ((getPosATL _intersectingObj) select 2)+((boundingBoxReal _intersectingObj) select 1 select 2);
  34.  
  35.         if (((_position select 2)-_intersectingObjTopPos)>2.5) then
  36.         {
  37.             diag_log format ["Resetting player altitude above intersecting object; It is more than 2.5 meters below the player position | %1 (%2) | type: %3.",_name,_playerUID,typeOf _intersectingObj];
  38.             _resetPosAboveObj = true;
  39.         };
  40.     };
  41. };
  42.  
  43. _direction = _data select 15;
  44. _group = createGroup independent;
  45. _player = _group createUnit ["Exile_Unit_Player", _position, [], 0, "CAN_COLLIDE"];
  46. _player setVariable ["ExileSessionID",_sessionID];
  47. _player setDir _direction;
  48. _player setPosATL _position;
  49. if (_resetPosAboveObj) then
  50. {
  51.     _position set [2, vectorMagnitude ((ATLToASL _position) vectorDiff getPos _player)];
  52.     _player setPosASL _position;
  53. };
  54. _player disableAI "FSM";
  55. _player disableAI "MOVE";
  56. _player disableAI "AUTOTARGET";
  57. _player disableAI "TARGET";
  58. _clanID = (_data select 47);
  59. _clanName = (_data select 48);
  60. if !((typeName _clanID) isEqualTo "SCALAR") then
  61. {
  62.     _clanID = -1;
  63.     _clanName = "";
  64. };
  65. _player setDamage (_data select 4);
  66. _player setFatigue (_data select 5);
  67. _player setName _name;
  68. _player setVariable ["ExileMoney", (_data select 43)];
  69. _player setVariable ["ExileScore", (_data select 44)];
  70. _player setVariable ["ExileKills", (_data select 45)];
  71. _player setVariable ["ExileDeaths", (_data select 46)];
  72. _player setVariable ["ExileClanID", _clanID];
  73. _player setVariable ["ExileClanName", _clanName];
  74. _player setVariable ["ExileName", _name];
  75. _player setVariable ["ExileOwnerUID", _playerUID];
  76. _player setVariable ["ExileDatabaseID", _data select 0];
  77. _player setVariable ["ExileHunger", _data select 6];
  78. _player setVariable ["ExileThirst", _data select 7];
  79. _player setVariable ["ExileAlcohol", _data select 8];
  80. _player setVariable ["ExileIsBambi", false];
  81. _player setVariable ["ExileXM8IsOnline", false, true];
  82. _player setOxygenRemaining (_data select 9);
  83. _player setBleedingRemaining (_data select 10);
  84. _player setHitPointDamage ["hitHead", _data select 11];
  85. _player setHitPointDamage ["hitBody", _data select 12];
  86. _player setHitPointDamage ["hitHands", _data select 13];
  87. _player setHitPointDamage ["hitLegs", _data select 14];
  88. _player call ExileClient_util_playerCargo_clear;
  89. _headgear = _data select 28;
  90. if (_headgear != "") then
  91. {
  92.     _player addHeadgear _headgear;
  93. };
  94. _goggles = _data select 25;
  95. if (_goggles != "") then
  96. {
  97.     _player addGoggles _goggles;
  98. };
  99. _binocular = _data select 29;
  100. if (_binocular != "") then
  101. {
  102.     _player addWeaponGlobal _binocular;
  103. };
  104. _uniform = _data select 35;
  105. _vest = _data select 39;
  106. _backpack = _data select 20;
  107. if (_uniform != "") then
  108. {
  109.     _player addUniform _uniform;
  110. };
  111. if (_vest != "") then
  112. {
  113.     _player addVest _vest;
  114. };
  115. if (_backpack != "") then
  116. {
  117.     _player addBackpack _backpack;
  118. };
  119. _uniformContainer = uniformContainer _player;
  120. if !(isNil "_uniformContainer") then
  121. {
  122.     {
  123.         _uniformContainer addWeaponCargoGlobal _x;
  124.     }
  125.     forEach (_data select 38);
  126.     {
  127.         _uniformContainer addMagazineAmmoCargo [_x select 0, 1, _x select 1];
  128.     }
  129.     forEach (_data select 37);
  130.     {
  131.         _uniformContainer addItemCargoGlobal _x;
  132.     }
  133.     forEach (_data select 36);
  134. };
  135. _vestContainer = vestContainer _player;
  136. if !(isNil "_vestContainer") then
  137. {
  138.     {
  139.         _vestContainer addWeaponCargoGlobal _x;
  140.     }
  141.     forEach (_data select 42);
  142.     {
  143.         _vestContainer addMagazineAmmoCargo [_x select 0, 1, _x select 1];
  144.     }
  145.     forEach (_data select 41);
  146.     {
  147.         _vestContainer addItemCargoGlobal _x;
  148.     }
  149.     forEach (_data select 40);
  150. };
  151. _backpackContainer = backpackContainer _player;
  152. if !(isNil "_backpackContainer") then
  153. {
  154.     {
  155.         _backpackContainer addWeaponCargoGlobal _x;
  156.     }
  157.     forEach (_data select 23);
  158.     {
  159.         _backpackContainer addMagazineAmmoCargo [_x select 0, 1, _x select 1];
  160.     }
  161.     forEach (_data select 22);
  162.     {
  163.         _backpackContainer addItemCargoGlobal _x;
  164.     }
  165.     forEach (_data select 21);
  166. };
  167. _loadObject = nil;
  168. switch (true) do
  169. {
  170.     case (_uniform != ""):  { _loadObject = _uniformContainer; };
  171.     case (_vest != ""):     { _loadObject = _vestContainer; };
  172.     case (_backpack != ""): { _loadObject = _backpackContainer; };
  173. };
  174. if !(isNil "_loadObject") then
  175. {
  176.     {
  177.         _loadObject addMagazineAmmoCargo [_x select 0, 1, _x select 1];
  178.     }
  179.     forEach (_data select 30);
  180. };
  181. _primaryWeapon = _data select 31;
  182. if (_primaryWeapon != "") then
  183. {
  184.     _player addWeapon _primaryWeapon;
  185.     removeAllPrimaryWeaponItems _player;
  186.     {
  187.         if (_x != "") then
  188.         {
  189.             _player addPrimaryWeaponItem _x;
  190.         };
  191.     }
  192.     forEach (_data select 32);
  193. };
  194. _handgunWeapon = _data select 27;
  195. if (_handgunWeapon != "") then
  196. {
  197.     _player addWeapon _handgunWeapon;
  198.     removeAllHandgunItems _player;
  199.     {
  200.         if (_x != "") then
  201.         {
  202.             _player addHandgunItem _x;
  203.         };
  204.     }
  205.     forEach (_data select 26);
  206. };
  207. _secondaryWeapon = _data select 33;
  208. if (_secondaryWeapon != "") then
  209. {
  210.     _player addWeapon _secondaryWeapon;
  211.     {
  212.         if (_x != "") then
  213.         {
  214.             _player addSecondaryWeaponItem _x;
  215.         };
  216.     }
  217.     forEach (_data select 34);
  218. };
  219.  _currentWeapon = _data select 24;
  220. if (_currentWeapon != "") then
  221. {
  222.      _player selectWeapon _currentWeapon;
  223. };
  224. _assigned_items = _data select 19;
  225. if !(_assigned_items isEqualTo []) then
  226. {
  227.     {
  228.         _player linkItem _x;
  229.     }
  230.     forEach _assigned_items;
  231. };
  232. _player addMPEventHandler ["MPKilled", {_this call ExileServer_object_player_event_onMpKilled}];
  233. [
  234.     _sessionID,
  235.     "loadPlayerResponse",
  236.     [
  237.         (netId _player),
  238.         str (_player getVariable ["ExileMoney", 0]),
  239.         str (_player getVariable ["ExileScore", 0]),
  240.         (_player getVariable ["ExileKills", 0]),
  241.         (_player getVariable ["ExileDeaths", 0]),
  242.         (_player getVariable ["ExileHunger", 100]),
  243.         (_player getVariable ["ExileThirst", 100]),
  244.         (_player getVariable ["ExileAlcohol", 0]),
  245.         (_player getVariable ["ExileClanName", ""])
  246.     ]
  247. ]
  248. call ExileServer_system_network_send_to;
  249. [_sessionID, _player] call ExileServer_system_session_updatePlayerObject;
  250. true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement