Home   Help Search Login Register  

Author Topic: Createvehicle and if-then-else  (Read 554 times)

0 Members and 1 Guest are viewing this topic.

dertn

  • Guest
Createvehicle and if-then-else
« on: 23 Apr 2003, 17:45:33 »
Hello all :) I'm working on a mission where you command a squad  and have to defend a base from incoming enemies... I've added actions to the player with the addaction command so the player can put out three t72 tanks and to use them to defend the base...

But I have a problem with my script: It creates the tanks ok, but the player can create dozens of tanks and I want the script to limit this to 3 tanks..

Here's the code from the init.sqs and the tank.sqs

Init.sqs:

_t = 0;
savevar "_t";


tank.sqs:


#starthere
? _t >= 3 : goto "ending";

_pos = [getpos ap select 0, (getpos ap select 1) +6, (getpos ap select 2) +200];
_tank = "T72" CreateVehicle _pos;
_tank SetPos _pos;
_tank SetDir (GetDir ap);
_t = _t + 1;
savevar "_t";
exit

#ending
ap removeaction _tank;
hint "3 tanks placed. . .";
exit

Any script aces here??

Any help appreciated...

And by the way..

I know it's supposed to be very easy... But I never get if-then-(else) to work in my scripts... Anyone who want to explain me (as the retard I am) how to construct and use if-then-else sentences in OFP..

1000's of thnx in advance

Me Out

jojojoni

  • Guest
Re:Createvehicle and if-then-else
« Reply #1 on: 23 Apr 2003, 18:18:33 »
In the init.sqs, write this:
    tanksdeployed = false

Then add this at the begining of your tank.sqs script:
    ?(tanksdeployed): "goto ending"

And in the same script, just after "#ending" line, write this:
    tanksdeployed = true

Good luck :).
« Last Edit: 23 Apr 2003, 18:31:36 by jojojoni »

dertn

  • Guest
Re:Createvehicle and if-then-else
« Reply #2 on: 23 Apr 2003, 18:51:07 »
I tried it with the triggers but no luck ...

This is the code:

Init.sqs

_t = 0;
savevar "_t";
tanksdeployed=false;


and

tank.sqs:

#start
? _t >= 3 : "goto ending";
?(tanksdeployed): "goto ending"

_pos = [getpos ap select 0, (getpos ap select 1) +6, (getpos ap select 2) +200];
_tank = "T72" CreateVehicle _pos;
_tank SetPos _pos;
_tank SetDir (GetDir ap);
_t = _t + 1;
savevar "_t";
exit

#ending
;ap removeaction _tank;
tanksdeployed=true;
hint "3 Used up . . .";
exit


*tearing my hair out..."

Offline Black_Feather

  • Former Staff
  • ****
  • I'll never forget you Daisey.
Re:Createvehicle and if-then-else
« Reply #3 on: 24 Apr 2003, 01:01:25 »
change _t to t  in your init.sqs and the script and it will probably work, its because _t is local. And the if else thing works like this

if (getDammage guy >0) then {hint "injured"} else {hint "ok"}
« Last Edit: 24 Apr 2003, 01:06:37 by Black_Feather »

dertn

  • Guest
Re:Createvehicle and if-then-else
« Reply #4 on: 24 Apr 2003, 20:14:47 »
Thaaaank you Black Feather..

This is a solvy...

 8)