OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Akbar on 09 Jun 2006, 02:34:02
-
I was wondering if there is a way to delete shells/missles after they are shot and reach 1,300 meters... it would prevent long range shooting which is a problem in the map. If possible i dont want it to affect missles shot from choppers.
. 8)
-
You can use a "fired" eventhandler to initiate a script which would then monitor the distance between the fired projectile and the vehicle that fired it, when the distance reached > 1300 the shell would be deleted.
In the init feild of the vehicle (or form a script) put:
this addEventHandler ["fired", {_this exec "deleteShell.sqs"}]
Then in your mission folder put a script called "deleteShell.sqs". That script will look like this:
_unit = _this select 0
_shell = nearestObject [_unit, _this select 4]
@ _shell distance _unit > 1300 || typeOf _shell != _this select 4
deleteVehicle _shell
exit
the @ _shell distance _unit > 1300 || typeOf _shell != _this select 4 line waits for the shell to be at least 1300 m from the unit that fired it or if it explodes/hits the ground. After either of those conditions are fullfilled the script deletes the _shell.