Jump to content
Sign in to follow this  
Reezo

SafeWeapon Script - Lower your weapon automatically when pointed at allied units

Recommended Posts

SR5 Tactical



GunSafety Script

sr5banner11.jpg

by Reezo - v1.0 - March 12th, 2001

This is quite a simple yet effective script.

This script will automatically lower a player's weapon at the beginning of a mission and will also lower it when the player is pointing his weapon at an allied unit. The weapon will be lowered only when your aim is kept on an allied for some seconds.

Put this in the init.sqf field of your mission:

nul0 = [] execVM "scripts\gearing\safeweapon.sqf";

Create an empty safeweapon.sqf file in your mission folder and paste the following in it:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: Reezo and Demonized
// This script makes sure the player lowers his weapon at the beginning of the mission
// and when pointing his weapon to allied units.
// You stupid noobs will now stop pointing your freaking gun at everyone's face
//////////////////////////////////////////////////////////////////

if (isDedicated) exitWith{};
if !(local player) exitWith{};

waitUntil {!(isNull player)};
waitUntil {player==player};

player action ["WEAPONONBACK", player];

while {alive player} do {
 if (side cursorTarget == side player AND (cursorTarget distance player) < 50) then {
   _aimAt = cursorTarget;
   _cntTime = 0;
   while {cursorTarget == _aimAt} do {
     sleep 1;
     _cntTime = _cntTime +1;
   };
  if (_cntTime >= 5) then {
     player action ["WEAPONONBACK", player];
     if (cameraView == "Gunner") then { player switchCamera "Internal" };
   } else {
     sleep 5;
   };
 };  
};

if (true) exitWith{};

if you want to download it:

Please do not mirror this file.

Edited by Reezo

Share this post


Link to post
Share on other sites

cool enough, maybe an idea to have a distance check on the cursortarget?

So as to avoid certain mishaps ;)

Share this post


Link to post
Share on other sites
cool enough, maybe an idea to have a distance check on the cursortarget?

So as to avoid certain mishaps ;)

Fantastic idea! You would think this should apply when < 50, let's say..

UPDATED with Demonized suggestion!

Edited by Reezo

Share this post


Link to post
Share on other sites

yeah probably.

if (side cursorTarget == side player AND (cursorTarget distance player) < 50) then {

also maybe add a continus check as to determine if aim is at cursor target for the whole 5 secs else do not lower weapon.

This because if i point at you for a second and then points away not getting any new cursor targets i would still lower my gun, wich could potentially be hasardous to my healt, and yours after :)

if (side cursorTarget == side player AND (cursorTarget distance player) < 50) then {
  _aimAt = cursorTarget;
  _cntTime = 0;
  while {cursorTarget == _aimAt AND _cntTime != 5} do {
     sleep 1;
     _cntTime = _cntTime +1;
  };
  if (_cntTime >= 5) then {
     player action ["WEAPONONBACK", player];
     if (cameraView == "Gunner") then { player switchCamera "Internal" };
  } else {
     sleep 5;
  };
};

Edited by Demonized

Share this post


Link to post
Share on other sites

Exactly my though, thanks for having written it.

Script updated!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×