OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Pilot on 15 Jan 2005, 04:34:56

Title: Script Returns Generic Error
Post by: Pilot on 15 Jan 2005, 04:34:56
I have been working on a script of mine for awhile, and have run across a problem I can't solve.

Here's my Script:
Code: [Select]
;HeightCheck by Student Pilot

_car = _this select 0
_height = _this select 1
_crew=crew _car

_i=0
_c = _crew select _i

#Loop
;Check if vehicle is above specified height, if yes, goto #Fall
?(getpos _car select 2) > _height: goto "Fall"
goto "Loop"

#Fall
;Check if vehicle is back on the ground, if yes, kill vehicle and goto #Die
?(getpos _car select 2) < 3: _car setdammage 1 and goto "Die"
goto "Fall"

#Die
;Kill Vehicle Crew
_c setdammage 1
_i = _i + 1
?_i = _crew: exit
goto "Die"

This is the error I keep getting:
Quote
_i = _i + 1#: Error Generic error in expresion

What's the problem?
Title: Re:Script Returns Generic Error
Post by: Triggerhappy on 15 Jan 2005, 05:14:03
not sure what is causing your error, but i do see some problems with it:
Code: [Select]
#Die
;Kill Vehicle Crew
_c setdammage 1
_i = _i + 1
?_i = _crew: exit
goto "Die"

you never redefine _c
you should move this
Code: [Select]
_c = _crew select _iand you're going to kill one guy endlessly. the loop won't end
_i is a number and _crew is an array
also, for conditions you use == not =
= is used to assign values


here is the correct loop

into your loop
Code: [Select]
#Die
;Kill Vehicle Crew
_c = _crew select _i
_c setdammage 1
_i = _i + 1
?_i == (count _crew): exit
goto "Die"

although i don't think you need to kill crew members if you kill the vehicle. they should all die...
Title: Re:Script Returns Generic Error
Post by: Fragorl on 15 Jan 2005, 05:15:54
# Edit
Title: Re:Script Returns Generic Error
Post by: Pilot on 15 Jan 2005, 05:27:06
Quote
you never redefine _c

Oh, now that I look at it, you're absoblutely right. (I feel real stupid about now) ::)

Quote
also, for conditions you use == not =
= is used to assign values

Really?!  I never knew that!

Quote
although i don't think you need to kill crew members if you kill the vehicle. they should all die...


That's the strange part.  I was experimenting, and there were a few rare instances when another crewmember or I was able to escape.  Hence the need for this part of the script.

Anyway, I implemented your suggestion into my script, and it works!  Many thanks Triggerhappy! :)

Topic Solved