Home   Help Search Login Register  

Author Topic: script distance prob [solved]  (Read 1710 times)

0 Members and 1 Guest are viewing this topic.

Offline schuler

  • Contributing Member
  • **
script distance prob [solved]
« on: 23 Apr 2009, 04:57:51 »
can someone fix this script so i works
h is a man hh is a vehicle

Code: [Select]
#loop
h distance hh < 30 (hh setdamage 0)
thanks
« Last Edit: 24 Apr 2009, 13:16:35 by schuler »
Semper Fi

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: script distance prob
« Reply #1 on: 23 Apr 2009, 07:20:55 »
.oO( Never write a line of code without a spec! )

What is this script supposed to do? Wild guess: make a guy repair a vehicle as soon as it is closer than 30 meters. Open question: should this happen only once or every time the condition is met?
try { return true; } finally { return false; }

Offline schuler

  • Contributing Member
  • **
Re: script distance prob
« Reply #2 on: 23 Apr 2009, 07:26:59 »
make a guy repair a vehicle as soon as it is closer than 30 meters. yes
and everytime
Semper Fi

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: script distance prob
« Reply #3 on: 23 Apr 2009, 07:57:27 »
Mean as I am I used the variables guy and car instead of h and hh. To prevent the car from being invulnerable when within the distance it takes the guy five seconds to fix it. If this is not what you wanted simply remove the "~5". The script will stop running as soon as the guy is dead.

Code: [Select]
[] exec "repair.sqs"
Code: (repair.sqs) [Select]
#loop

@ ((car distance guy < 30) and (getDammage car != 0))

?! alive guy : goto "exit"
~5
car setDamage 0
goto "loop"

#exit

try { return true; } finally { return false; }

Offline schuler

  • Contributing Member
  • **
Re: script distance prob
« Reply #4 on: 23 Apr 2009, 10:27:53 »
but i can change it to h and hh right?
Semper Fi

Offline JamesF1

  • Editors Depot Staff
  • *****
    • JamesBurgess.co.uk
Re: script distance prob
« Reply #5 on: 23 Apr 2009, 18:12:39 »
Changing the variable names won't make a difference, as long as you change them all.

Offline schuler

  • Contributing Member
  • **
Re: script distance prob
« Reply #6 on: 23 Apr 2009, 23:35:35 »
thanks James and Worldeater , i have the script like this but its not working. m1 is a man and he is in a vehicle.

Code: [Select]
HEIGHT: 0  WEIDTH: 0
ACTIVATION: West - Present
TYPE: NONE
CONDITION: this
ON ACTIVATION: [] exec "repair.sqs"


Code: [Select]
#loop

@ ((stryker distance m1 < 30) and (getDammage stryker != 0))

?! alive m1 : goto "exit"
~5
stryker setDamage 0
goto "loop"

#exit
Semper Fi

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: script distance prob
« Reply #7 on: 24 Apr 2009, 10:33:55 »
I haven't checked if it also works if the guy is inside a vehicle but I'll check that later today.

You know that the script can't "resurrect" destroyed vehicles?
try { return true; } finally { return false; }

Offline Sparticus76

  • Members
  • *
Re: script distance prob
« Reply #8 on: 24 Apr 2009, 10:58:38 »

HEIGHT: 0  WEIDTH: 0



The problem is if the trigger has no size, it wont be tripped because west will never be present.

Offline schuler

  • Contributing Member
  • **
Re: script distance prob
« Reply #9 on: 24 Apr 2009, 13:15:47 »
Quote
The problem is if the trigger has no size, it wont be tripped because west will never be present.
thanks for pointing out my blundering stupidity  Sparticus  :-[
Semper Fi