Home   Help Search Login Register  

Author Topic: Script not working well  (Read 2133 times)

0 Members and 2 Guests are viewing this topic.

Offline 00toks

  • Members
  • *
Script not working well
« on: 01 May 2010, 06:01:35 »
My attempt at a script to make my own dynamic transport or map-click transport. Remember im very new to this and from my research this is what ive made up. I dont want to use the BI function/sec ops etc i want to script it for learning purposes.

I have a mission with these;
1. Helicopter named chopper.
2. Trigger, radio alpha activated repeated. It's on act is
Code: [Select]
nul=[] execVM "scripts\heli\dt.sqf";
3. H Pad named pad.
4. Invisible H Pad named loc.
5. My player named toks.
6. Marker named LZ.

dt.sqf is
Code: [Select]
//call chopper commands
dt=true;
titleText ["Indicate LZ on map by map-click","PLAIN DOWN"];
onMapSingleClick "loc setPos _pos;dt=false";
waitUntil {!dt};
"lz" setMarkerPos getPos loc;
chopper move getPos loc;
//land chopper commands
player assignAsCargo chopper;
waitUntil {chopper distance loc < 180};
chopper land "GET IN";
waitUntil {player in chopper};
nul=[] execVM "scripts\heli\repeat.sqf";
repeat.sqf is
Code: [Select]
//repeat
repeat=true;
titleText ["Indicate LZ on map by map-click","PLAIN DOWN"];
onMapSingleClick "loc setPos _pos;repeat=false";
waitUntil {!repeat};
"lz" setMarkerPos getPos loc;
chopper move getPos loc;
nul=[] execVM "scripts\heli\drop.sqf";

drop.sqf is
Code: [Select]
//drop off commands
waitUntil {chopper distance loc < 180};
chopper land "GET OUT";
unassignVehicle toks;
waitUntil {!(player in chopper)};
chopper move getpos pad;
//chopper return to base commands
waitUntil {chopper distance pad < 180};
chopper land "LAND";

Okay BUT THERES PROBLEMS.

1. Helicopter comes to my map-click, starts landing to its hover point then as soon as its near the ground it starts climbing again and then just hovers high above me. It (the helicopter) doesnt listen to my waitUntil commands...
2. I tried to use
Code: [Select]
chopper land "LAND"and i found sometimes the chopper actually lands and waits, sometimes it wont. Its all just too stressfull and inconsistant! During these times it does wait if my player jumps on it actually continues with the script, i click on my next destination and it moves there and goes to land but it then has another problem it wont wait for me to get out! AAAHHHH!!!

Is this a bug in the game engine or is it my bad ammature scripting??

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Script not working well
« Reply #1 on: 04 May 2010, 14:56:07 »
I am a noob when it comes to Sqf but I'll give it a shot.

You mentioned sec ops which is only available in Arma2. Is this for Arma or Arma2?

First of all, it doesn't seem to impede progress but you have not defined the local variable _pos anywhere in the script?

Second, this was an old OFP bug when Synchronization was not used. Try adding a waypoint for chopper and a waypoint for the player at the position of the mapclick.

Code: [Select]
_wayP = groupname addWaypoint [fred, 10] That is from the comref.

Then synchronize the two...
Code: [Select]
[group1, 2] synchronizeWaypoint [[group2, 3]] Also from comref.




Offline eegore

  • Members
  • *
Re: Script not working well
« Reply #2 on: 09 May 2010, 00:46:24 »

  I tried placing the _wayP command in a trigger but it returns:

_wayp # etc. etc.  local variable in global space.

 

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: Script not working well
« Reply #3 on: 16 Jun 2010, 13:05:37 »
Local variables can only be used within scripts. Put the command in a script and then execute the script when needed.