Home   Help Search Login Register  

Author Topic: heli fuel script  (Read 1975 times)

0 Members and 2 Guests are viewing this topic.

stalker336

  • Guest
heli fuel script
« 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 !!

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:heli fuel script
« Reply #1 on: 23 Feb 2004, 01:05:02 »
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
« Last Edit: 23 Feb 2004, 02:50:54 by [icarus_uk] »

stalker336

  • Guest
Re:heli fuel script
« Reply #2 on: 23 Feb 2004, 01:31:33 »
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 ?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:heli fuel script
« Reply #3 on: 23 Feb 2004, 02:00:23 »
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!
« Last Edit: 23 Feb 2004, 02:02:33 by macguba »
Plenty of reviewed ArmA missions for you to play

stalker336

  • Guest
Re:heli fuel script
« Reply #4 on: 23 Feb 2004, 02:28:48 »
Great thnx for yur posts [icarus_uk] and macguba ! ;)



 post closed::

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:heli fuel script
« Reply #5 on: 23 Feb 2004, 02:52:29 »
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.

stalker336

  • Guest
Re:heli fuel script
« Reply #6 on: 23 Feb 2004, 10:32:38 »
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
« Last Edit: 23 Feb 2004, 10:33:43 by stalker336 »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:heli fuel script
« Reply #7 on: 23 Feb 2004, 13:01:04 »
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.


Plenty of reviewed ArmA missions for you to play

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:heli fuel script
« Reply #8 on: 23 Feb 2004, 13:21:03 »
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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Fishion

  • Guest
Re:heli fuel script
« Reply #9 on: 23 Feb 2004, 16:16:25 »
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:

Code: [Select]
; 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:

Code: [Select]

;---------- 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

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:heli fuel script
« Reply #10 on: 23 Feb 2004, 18:01:33 »
Quote
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
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

stalker336

  • Guest
Re:heli fuel script
« Reply #11 on: 23 Feb 2004, 21:46:14 »
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
 
« Last Edit: 23 Feb 2004, 21:56:12 by stalker336 »

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:heli fuel script
« Reply #12 on: 23 Feb 2004, 22:03:14 »
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.
« Last Edit: 23 Feb 2004, 22:04:26 by [icarus_uk] »

stalker336

  • Guest
Re:heli fuel script
« Reply #13 on: 23 Feb 2004, 23:12:23 »
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 !
« Last Edit: 23 Feb 2004, 23:16:27 by stalker336 »

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:heli fuel script
« Reply #14 on: 23 Feb 2004, 23:28:35 »
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.