OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: XTimmy on 31 Dec 2008, 18:32:05
-
Hey.
I've been working on my 'first' mission for a few days now and it's beginning to grind ever so slightly. I've reached a point where I need a function rather than a script.
Then I decided a Trigger would work just as well.
Basically I've got a helicopter rising in the distance. And when it hits a certain height (10) Crossroads says something to the affect of 'oh no'
I simply cannot get this to work.
My current set up (which dosen't return an error, it simply returns nothing is thus)
A trigger, axis a/b = 0/0,
Condition:
(getpos testheli select 2) >= 10
On Act
[sidefriendly, "HQ"] Sidechat "oh no"
I've tried variations of everything [side, "HQ"] Sidechat "oh no" etc etc but it simply dosen't pop up. Any thoughts?
(If someone could also make this into a .sqf so I've got an example function to learn the syntax for a looping script off that'd be great)
-
Try this:
HQ = [west, "HQ"]; HQ sideChat "Oh no!";
Here's the SQF:
while {alive testheli} do //loop as long as testheli is alive
{
if ((getPos testheli select 2) >= 10) then //check if testheli's height is greater or equal 10
{
HQ = [west, "HQ"];
HQ sideChat "Oh no!";
};
sleep 1; //wait 1 second before continuing - always sleep if the loop runs for extended amount of time or the game will freeze!
};
-
Sleep is exactly the command I've been looking for!
Thanks for the help in both threads Deadfast! :D
-
You're much welcome :)
I wish you good luck in learning SQF ;)
-
There is also waitUntil
which is equivalent to @ in SQS scripts if you're interested
-
IIRC waitUntil eats up more resources so I'd personally avoid it in this case ;)
BTW Timmy, I just realized you might want to have the message display only once.
In that case use exitWith instead of then with the if condition (it's similar to break in C-like languages):
while {alive testheli} do
{
if ((getPos testheli select 2) >= 10) exitWith //if the condition is true execute the code and then exit the while cycle scope
{
HQ = [west, "HQ"];
HQ sideChat "Oh no!";
};
sleep 1;
};
-
Nice to know but it only needs to execute once.
-
Yep, that's why you need exitWith ;)