OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: stalker336 on 23 Feb 2004, 00:50:37
-
hello all new to this forum ive searched for hours in here now! looking for a heli fuel script . pretty basic all i want is a heli to loose or use fuel while in flight !!
-
Something like this then;
_chopper = _this select 0
#drain
_amount = fuel _chopper
_amount = _amount - 0.01
_chopper setfuel _amount
? _amount <= 0 : goto "exit"
~0.5
goto "drain"
#exit
exit
Copy and paste this in to a new .sqs file, give it a name, eg. drainfuel.sqs And then call the script with;
[ChopperName]exec "drainfuel.sqs"
Ive also submitted a commented version of this script to the editors depot for any future use. Aren't I nice! ;D
-
hmm i tried it out and get a _chopper=_this select 0# error select: type object ,expected Array ? then i tried to change chopper with heli name h1 and still got same thing ?
-
Firstly, head over to the Editors Depot and read both
snYpir's Friendly Intro to Code Snippets
Johan Gustafson's Scripting Guide
Done that? Good. ;) Now you will understand how to solve your problem.
For the avoidance of doubt, here's the answer again ...
As per Icarus' instructions, name your chopper h1 (or whatever you like) and call the script with
[h1] exec "drainfuel.sqs"
Oh, and
Welcome to the forum!
-
Great thnx for yur posts [icarus_uk] and macguba ! ;)
post closed::
-
Realised just now that I updated the script for the ed depot, but didnt update it here. It still worked, just not as well. Ive modified my above post to the lastest, and perfectly working, version.
-
ok well after pulling some hair out and trying to convince my self
that this isnt that that hard ! is fuel being used yes but it strts being used right off the start even with nobody in heli how can i get this to work only when heli engine is on ?
beleive me i have been reading and looking for the answer the script i have right now looks like this . but im getting errors now
_chopper = _this select 0
_chopperheight = _this select 1
#Update
_chopperheight = getpos chopper
_chopperheight < 2 : goto "Update"
~2
#drain
_amount = fuel _chopper
_amount = _amount - 0.01
_chopper setfuel _amount
? _amount == 0 : goto "exit"
~1.5
goto "drain"
#exit
exit
-
You've got a dash more reading to do I'm afraid. ;D In the command reference read the section on array types.
A getPos command returns an array with three elements. So this
_chopperheight < 2
doesn't make sense.
Try this:- (no promises)
_chopper = _this select 0
#Update
~2
_chopperheight = getpos chopper select 2
_chopperheight < 2 : goto "Update"
#drain
etc
When you've got script that doesn't work, post the script by all means (as you did). However, you should also post the means by which the script is called. Also, tell us more about how it doesn't work. What happens exactly? If you get error messages post them: it can be hard to catch them so repeat the error several times till you can write it down.
Don't worry about getting bogged down - what's happening to you happened to all of us at the same stage. It's a kind of rite of passage into ofp editing. It only lasts a few days, then as as you gather knowledge and the different bits start to relate to each other it begins to fall into place.
Instead of testing the chopper's height, you could test its speed using the command speed.
-
Aye - maybe these two functions (added during 1.90 patch)
come in handy here:
isEngineOn, engineOn
I can't test it right now, but as far as i remember the syntax
has to look like:
isEngineOn vehiclename
engineOn vehiclename
Just make a simple test trigger with such a condition to check
it's functionality ;)
~S~ CD
-
Well from a realism standpoint it really doesn't matter if the engine is on.
If you have a leak, fuel will run through it, even if the engine is off.
I would also change the script to this:
; This script simulates a fuel leak
; it runs till there is no fuel left.
; starting this script will start the leak
_chopper = _this select 0
_drain = _this select 1
_chopperheight = _this select 1
~2
#drain
~1.5
_chopper setfuel ((fuel _chopper) - _drain)
;YOU_Fuel_drain_end is a global variable used to end this script
?(fuel _chopper > 0) : goto "drain"
What's the difference?
It doesn't need the detour with the _amout, and makes all in one step...
Also you don't need the exit If-Statement...
Though I don't know what takes more time, the 3 lines with private
variables, or 2 times calling the fuel function, probably the first....
ahhh I guess I'm just confusing people...
Here is a little way to randomly start a leak if shot at:
;---------- INIT
;get Helo
_chopper = _this select 0
;get proportionally faktor
_deri = 1
;get Chopper dammage
_dam = Getdammage _chopper
;difference between Chopper dammage and last cycle
_dif = 0
;----------- INIT END
#loop
;get differenc
_dif = (GetDammage _Chopper) - _dam
?(_dif == 0):goto "end_loop"
;start drain script with amount proportional to dammage
?(random _deri < _dif)):[_chopper, 0.01] exec "your_drain_script.sqs"
#end_loop
~2
goto "loop"
It should make the possibility that you take a leak proportional to the
dammage you absorbed during the last cycle (if you are hit by AAA you'd
be more likely to get a leak, than being hit by an AK, though it's still possible to get a leak by an AK-Hit)
It's untested though...
-Fishion
-
Well from a realism standpoint it really doesn't matter if the engine is on.
If you have a leak, fuel will run through it, even if the engine is off.
But then again this may vary from case to case, depending
on: where the leak is located ;D
But generally you're right ;)
~S~ CD
-
ok ive tried this ;
_chopper =_this select 0
#Update
_chopperheight = getpos chopper select 2
_chopperheight < 2 : goto "Update"
~2
#drain
_amount = fuel _chopper
_amount = _amount - 0.01
_chopper setfuel _amount
? _amount == 0 : goto "exit"
~1.5
goto "drain"
#exit
exit
still getting _chopperheight <2 #: goto"Update": Error : unknown operator
called script with : [h1] exec fuel.sqs //and i trried this// [h1,2] exec fuel.sqs ?
ive tried vehicle velocity & command speed and engineOn but i thinkim missing some other syntex
i dont understand how fishion was calling 2 parameters the same
ie. drain=_this select 1
chopperheight=_this select 1
-
still getting _chopperheight <2 #: goto"Update": Error : unknown operator
Try
_chopperheight = getpos _chopper select 2
_chopperheight < 2 : goto "Update"
You missed an underscore ( _ ) in your _chopperheight line.
-
still getting _chopperheight <2 #: goto"Update": Error : unknown operator
Try
_chopperheight = getpos _chopper select 2
_chopperheight < 2 : goto "Update"
You missed an underscore ( _ ) in your _chopperheight line.
YES still getting it even with _
even i dont get this i hope someone can wright a good fuel script i havent
seen one in opec !!dont take me wrong the fuel leak scripts you men have posted are great !
-
Oh yes. When you wantt he script to check something, ie. that _chopperheight < 2 you need to have a question mark infront of it.
So.
_chopperheight = getpos _chopper select 2
?_chopperheight < 2 : goto "Update"
While this will work. I think a better way of doing it, would be to have the script wait for _chopperheight to be greater than 2, instead of having the script loop around constantly.
_chopperheight = getpos _chopper select 2
@_chopperheight > 2
then carry on the rest of your script.
-
wohoo ok its working as long as chopper is on ground no fuel is used
as soon as its height is over 2 meters fuel starts being used
i no this script will seem very rough to some of you with the looping
but im just glad i got it working just in time with only 3 hairs left on my head ! its so easy but yet so hard . thnx for all yur help!
;fuel.sqs
_chopper =_this select 0
#Update
_chopperheight = getpos _chopper select 2
?_chopperheight < 2 : goto "Update"
~2
#drain
_amount = fuel _chopper
_amount = _amount - 0.01
_chopper setfuel _amount
_chopperheight = getpos _chopper select 2
?_chopperheight < 2 : goto "Update"
? _amount == 0 : goto "exit"
~1.5
goto "drain"
#exit
exit
-
i dont understand how fishion was calling 2 parameters the same
ie. drain=_this select 1
chopperheight=_this select 1
Ahhh you are right about this mate, forgot to delete the _chopperheight.
As you might notice, it's not used.
-Fishion