OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: AE7THSF on 17 Jan 2003, 09:26:05

Title: addaction
Post by: AE7THSF on 17 Jan 2003, 09:26:05
im making a mission  where u have to kill this officer and he has a map of the area,to see the map u have to use action menu but i dont want u to see the action till u get 4 feet from him.


ty in advanced
Title: Re:addaction
Post by: uiox on 17 Jan 2003, 13:35:30
If you really want 4 feet you can't use addaction to objects, cause the detect area is biggest than 4 ft.

A method:
U need :

In init.sqs

ObjectBodyvar addEventHandler ["killed",{_this exec "detectScript.sqs"}]



DetectScript.sqs

runScript = true
ActionIsInstall = false
Onarea = false

#Loop
~0.001
? !(runscript) : exit
if (ObjectBodyvar distance player < 4) then {Onarea = true} else {Onarea = false}
? Onarea &&  !(ActionIsInstall ) : ActionIsInstall = true;_ID = player addaction ["Take map", "Map.sqs"]
? !(Onarea) && ActionIsInstall :ActionIsInstall = false; player removeAction _ID
Goto "Loop"

Map.sqs
player removeAction _This select 2
hint "Yep! a map!"
runscript = false
showMap true

Not test.