Home   Help Search Login Register  

Author Topic: Heli Transport  (Read 1617 times)

0 Members and 1 Guest are viewing this topic.

Offline Delta83_DK

  • Members
  • *
Heli Transport
« on: 30 Apr 2011, 02:51:33 »
Hi Guys

I have a problem with a fairly simple script.
I have seen some good examples here in forum, and I have tried to make my own.

When I arrive at the helipad the script is activated, and then the sidechat just keeps going "Loop".
I have inserted all the sidechats, just to see where the script gets stuck.
But as I can see, the condition to get to the "Pickup" has been met, but nothing happens.
I have tried to input the line "Helo_1 distance H_1 < 20" in the condition-field of the trigger, and the script still gets activated, so the condition to go futher in the script must be met?

It is most likely a rookie-mistake, but can someone see the problem?


I have this in a trigger right at the Helipad :

Code: [Select]
Condition : ((vehicle Helo_1) in thisList) and ((getPos (vehicle Helo_1) select 2) < 2) && Helo_1 Distance H_1<10
On Act. : [] exec "Chopper_Transport.sqs"


Chopper_Transport.sqs

Code: [Select]
; Helo transport

;Unit = Player_1
;Chopper = Helo_1
;Helipad = H_1
;Group = Grp_1


Player_1 Sidechat "Boardingscript activated"

#Loop

~3

Player_1 Sidechat "Loop"

? Helo_1 distance H_1 < 20 Then Goto "Pickup"

~3

Goto "Loop"

#Pickup

Player_1 Sidechat "Helo reached Pickup point"

Player_1 sidechat "(Grp_1) Group 1 Boarding Chopper"

~3

{_x AssignAsCargo helo_1} forEach units group grp_1

units group grp_1 orderGetIn true

?{{_x in helo_1} count units group grp_1 == count units group grp_1} then titleText["Lets go home", "PLAIN DOWN"] and goto "Exit"

#Exit

~1

Player_1 Sidechat "Exit boarding script"

~3

Exit

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Heli Transport
« Reply #1 on: 30 Apr 2011, 11:14:14 »
Code: [Select]
? Helo_1 distance H_1 < 20 Then Goto "Pickup"
Needs to be:

Code: [Select]
? Helo_1 distance H_1 < 20: Goto "Pickup"
Edit:
Also the later line should look like this:
Code: [Select]
?{{_x in helo_1} count (units group grp_1) == count (units group grp_1)}: titleText["Lets go home", "PLAIN DOWN"] ; goto "Exit"
Edit2:
Its also good to use "(" and ")" as much as possible. If there is long lines the system may not count it right without those. Here is whole script fixed:
Code: [Select]
; Helo transport
;Unit = Player_1
;Chopper = Helo_1
;Helipad = H_1
;Group = Grp_1
Player_1 Sidechat "Boardingscript activated";
#Loop
~3
Player_1 Sidechat "Loop";
? Helo_1 distance H_1 < 20: Goto "Pickup"
~3
Goto "Loop"
#Pickup
Player_1 Sidechat "Helo reached Pickup point";
Player_1 sidechat "(Grp_1) Group 1 Boarding Chopper";
~3
{_x AssignAsCargo helo_1;} forEach (units grp_1);
(units (grp_1)) orderGetIn true;
#WaitCargo
~2
?{{_x in helo_1} count (units grp_1) == count (units grp_1)}: titleText["Lets go home", "PLAIN DOWN"];goto "Exit";
goto "WaitCargo"
#Exit
~1
Player_1 Sidechat "Exit boarding script";
~3
Exit
« Last Edit: 30 Apr 2011, 11:22:57 by SaOk »

Offline Delta83_DK

  • Members
  • *
Re: Heli Transport
« Reply #2 on: 30 Apr 2011, 14:54:04 »
Great!. Thx a lot  :)
Very nice to see people taking time to help others.
One more question : What is the difference between "()" and "{}"

Offline SaOk

  • Missions Depot Staff
  • *****
    • My youtube profile
Re: Heli Transport
« Reply #3 on: 04 May 2011, 10:31:27 »
With "()", you determine in what order things are calculated. Like in math (2*2+1=5 2*(2+1)=6). Sometime if "()" are not used, the game may try to count complex things in wrong order giving an error.

"{}" outline code/functions. E.g. to commit function, that adds M16, for each unit in group that have a member unitname1.

Code: [Select]
{_x addweapon "M16";} foreach (units (group unitname1));