Home   Help Search Login Register  

Author Topic: Trying to make simple checking script work  (Read 794 times)

0 Members and 1 Guest are viewing this topic.

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Trying to make simple checking script work
« 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
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re:Trying to make simple checking script work
« Reply #1 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 =?
« Last Edit: 10 Dec 2005, 13:12:31 by bedges »

LoTekK

  • Guest
Re:Trying to make simple checking script work
« Reply #2 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.

Offline hardrock

  • Members
  • *
  • Title? What's that?
    • Operation FlightSim
Re:Trying to make simple checking script work
« Reply #3 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

Offline OFPfreak

  • Members
  • *
  • Who is da operation flashpoint freak now, freak?!
    • OFP NFS mod
Re:Trying to make simple checking script work
« Reply #4 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.
« Last Edit: 11 Dec 2005, 00:01:19 by OFPfreak »
ofp nfs REBORN! All new nitro, neon, customized cars, off-road, on-road, rally, bikes, racer models and more!
ofp nfs's homepage