Advertisement
Pritchard

drop.sqf

Nov 15th, 2016
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.31 KB | None | 0 0
  1. //drop.sqf by Pritchard
  2.  
  3. _player = _this select 0;
  4. _currentMag = currentMagazine _player;
  5. _magCount = {_x == _currentMag} count magazines _player;
  6. _pWeap = primaryWeapon _player;
  7.  
  8. //Don't run on players with no primary weapon
  9. if !(_pWeap isEqualTo "") then {
  10.  
  11. //1.8m in front of the unit seems like a good distance - could be changed to a user-input variable
  12. _objPosition = _player modelToWorld [0,1.8,0];
  13. //Creates a groundWeaponHolder at precisely the desired position with random rotation
  14. _box = createVehicle ["groundWeaponHolder", _objPosition, [], 0, "CAN_COLLIDE"];
  15. _box setDir random(360);
  16. //Snaps the gWH to the terrain as best as possible - doesn't match angle
  17. _box setPosATL [getPosATL _box select 0, getPosATL _box select 1, 0];
  18.  
  19. //Adds a temporary item to prevent the gWH from despawning while the player drops the weapon
  20. _box addItemCargoGlobal ["ItemWatch",1];
  21.  
  22. //Makes the player drop their primary weapon and sleeps until they are probably done
  23. _player action ["DropWeapon", _box, _pWeap];
  24. sleep 3;
  25. //Restores the ammunition that they dropped
  26. _player addMagazines [_currentMag, _magCount];
  27. //Clears all items and magazines (placeholder watch, dropped ammo)
  28. clearItemCargoGlobal _box;
  29. clearMagazineCargoGlobal _box;
  30. //Makes sure the player can always interact with gWH
  31. _player reveal _box;
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement