OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: OFPfreak on 10 Dec 2005, 13:04:41

Title: Trying to make simple checking script work
Post by: OFPfreak on 10 Dec 2005, 13:04:41
Hey guys, haven't been playing ofp or checking the forums for a long while. That's propably why I got this problem too. I am trying to make a script that checks a specific unit. Please tell me what I've done wrong. I tried it with the []s and ()s and used them differently. I don't know :(!

Code: [Select]
#loop

_damage = getdammage car1
_canfire = canfire car1
_isdestroyed = 0
_behaves = behaviour car1
_exists IsNull car1

if _canfire == 1 then (set [_canfire, can]) else (set [_canfire, cannot])

if _damage == 1 then (set [_isdestroyed, 1]) else (set [_isdestroyed, 0])

if _isdestroyed == 1 then (set [_isdestroyed, destroyed]) else (set [_isdestroyed, alive])

if _exists == 1 then (set [_exists, does not exist]) else (set [_exists, exists])

hint format ["the vehicle has %1 damage \n the vehicle %2 fire \n the vehicle is %3 \n the vehicle's behaviour is %4 \n the vehicle %5",_damage, _canfire, _isdestroyed, _behaves, _exists]

~5

goto "loop"

exit
Title: Re:Trying to make simple checking script work
Post by: bedges on 10 Dec 2005, 13:12:00
canfire is a boolean expression, i.e. either true or false, therefore the variable _canfire will never be 1.

also not sure what you mean by using set. why not just use the old =?
Title: Re:Trying to make simple checking script work
Post by: LoTekK on 10 Dec 2005, 13:19:24
As far as I can see, set is used to change or add elements to an array. The variables you're using are not arrays.

So in addition to what bedges said about booleans (I had actually gotten used to "true" also equating to "1" in other languages), you'll want to use = instead of set. At least that's what it looks like.
Title: Re:Trying to make simple checking script work
Post by: hardrock on 10 Dec 2005, 14:45:28
Try this one:

Code: [Select]
#loop

; XX% damage
_damage = format ["%1%",(damage car1)*100]
_canfire = if(canfire car1) then {"can"} else {"cannot"}
_isdestroyed = if(alive car1) then {"alive"} else {"destroyed"}
_behaves = behaviour car1
_exists = if(isNull car1) then {"does not exist"} else {"exists"}

hint format ["the vehicle has %1 damage \n the vehicle %2 fire \n the vehicle is %3 \n the vehicle's behaviour is %4 \n the vehicle %5",_damage, _canfire, _isdestroyed, _behaves, _exists]

~5

goto "loop"

exit
Title: Re:Trying to make simple checking script work
Post by: OFPfreak on 10 Dec 2005, 23:56:15
I tried set because = didn't work and I didn't know how to actually SET variables to another number/word other than variable = variable + number. I'll try what you guys got for me now. Thanks.

Oh and P.S. if possible just a small camcreate script that zooms in to the front, left, top view or side :D.