Jump to content
Sign in to follow this  
cougarxr7

Distance from object error

Recommended Posts

Hello,

I'm am getting an error with this ,

"if((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 300)then"

This is for a Helo evac. When the Helo gets within 300 meters of the Helo pad the condition should go true.

I know the error is caused after the "and".

I believe "Distance" is to be used with an array.

I'd really like to get this to work.

Thanks!

Share this post


Link to post
Share on other sites

if (((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 300))then...

:)

Xeno

Share this post


Link to post
Share on other sites

Xeno, thank you, no more error!

However script still not working.

if(((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 300))then 
{
_pos2 = [_pos select 0,(_pos select 1) - 18,_pos select 2];
esmoke = "SmokeShellGreen" createVehicle _pos2;
};

No smoke got created.

I believe I need to create a trigger for this.

Will figure this out.

Again thanks!

Edited by Cougarxr7

Share this post


Link to post
Share on other sites

Your code only checks the condition once. If I understood correctly you'll to want to run this for some time before the chopper gets even close, then launch the smoke. If this is the case you'll probably want to use something like

waitUntil{condition to throw smoke};
*code to throw smoke here*

Share this post


Link to post
Share on other sites

Thanks for the reply Fincuan.

Here's a better detail of what I am trying to do.

A player can call for an "Evacuation" via radio.

When he does he creates a helo pad at his position and he also creates a marker on the map at his position too.

Also I am trying to get the hint to be read global that says "players name" NEEDS EVAC.

I have a file called "Pevac.sqf" Here it is.

BIS_EVO_EVAC =
	player sidechat "NEEDS IMMEDIATE EVAC!";<<trying to make this for all to see>>
	text ="NEEDS IMMEDIATE EVAC!";
	_txtpasshead = "PLAYER REQUEST";
	_txtpassbody = format["%1 NEEDS EVAC",(name player)];
	["#0000FF",_txtpasshead,_txtpassbody]call BIS_EVO_Message;

_mark = format["%1 NEEDS EVAC",(name player)];

player playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 3.0;
WaitUntil {animationState player != "AinvPknlMstpSlayWrflDnon_medic"};

epad = "HeliH" createVehicle (position player);
_pos = position epad;

waitUntil(((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 300))then 
{
_pos2 = [_pos select 0,(_pos select 1) - 18,_pos select 2];
esmoke = "SmokeShellGreen" createVehicle _pos2;
};

waitUntil (((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 10))then 
{
	deletevehicle esmoke;
	deletevehicle epad;
	deleteMarker _mark;
};
BIS_EVO_EngZone setpos _pos;	

etent addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
ebox addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_mssg = format["%1 NEEDS EVAC",(name player)];
_medmark = createMarker [_mark, _pos];
_medmark setMarkerShape "ICON";
_medmark setMarkerType "b_hq";
_medmark setMarkerColor "ColorRed";
_medmark setMarkerText _mssg;
_medmark setMarkerSize [0.5, 0.5];

Now 2 things need to happend.

1. When helo gets within a certain distance from the helo pad, green smoke should appear.

2. When helo gets within a very very close distance from the helo pad, the helo pad and map marker should get deleted.

The "waituntil" threw an error of which I'm sure it is because of my condition syntax.

Thanks for helping, not giving up until this works.

Back to troubleshooting!

Again thanks!

Share this post


Link to post
Share on other sites

Ok, I have made some changes in the script.

I am now using this one.

pevac.sqf

BIS_EVO_EVAC =
	player sidechat "NEEDS IMMEDIATE EVAC!";
	text ="NEEDS IMMEDIATE EVAC!";
	_txtpasshead = "PLAYER REQUEST";
	_txtpassbody = format["%1 NEEDS EVAC",(name player)];
	["#0000FF",_txtpasshead,_txtpassbody]call BIS_EVO_Message;

deletevehicle esmoke;
deletevehicle epad;
_mark = format["%1 NEEDS EVAC",(name player)];
deleteMarker _mark;

player playMove "AinvPknlMstpSlayWrflDnon_medic";
sleep 3.0;
WaitUntil {animationState player != "AinvPknlMstpSlayWrflDnon_medic"};

epad = "HeliH" createVehicle (position player);
_pos = position epad;
_pos2 = [_pos select 0,(_pos select 1) - 18,_pos select 2];

_trgobj3 = createTrigger ["EmptyDetector", _pos];
_trgobj3 setTriggerActivation ["WEST", "PRESENT", true];
_trgobj3 setTriggerArea [300, 300, 0, false];
_trgobj3 setpos position epad;

_txtpasshead = "pevac.sqf";
_txtpassbody = format["Position = %1",_pos];
["#0000FF",_txtpasshead,_txtpassbody]call BIS_EVO_Message;

if(((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 300))then 
{
esmoke = "SmokeShellGreen" createVehicle _pos2;

_trgobj3 = createTrigger ["EmptyDetector", _pos];
_trgobj3 setTriggerActivation ["WEST", "PRESENT", true];
_trgobj3 setTriggerArea [100, 100, 0, false];
_trgobj3 setpos position _pos;

_txtpasshead = "pevac.sqf";
_txtpassbody = format["Position = %1",_pos2];
["#0000FF",_txtpasshead,_txtpassbody]call BIS_EVO_Message;

if (((vehicle player) isKindOf "Air") and ((vehicle player) distance epad < 30))then 
	{
	deletevehicle esmoke;
	deletevehicle epad;
	deleteMarker _mark;
	};
};
BIS_EVO_EngZone setpos _pos;	

epad addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
esmoke addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_mssg = format["%1 NEEDS EVAC",(name player)];
_medmark = createMarker [_mark, _pos];
_medmark setMarkerShape "ICON";
_medmark setMarkerType "b_hq";
_medmark setMarkerColor "ColorRed";
_medmark setMarkerText _mssg;
_medmark setMarkerSize [0.5, 0.5];

The first trigger is working.

My condition statement is not working,

"if(((vehicle player) isKindOf "Air") and

((vehicle player) distance epad < 300))then "

The second trigger is not firing when the helo is within 300 meters.

If anyone can see why my condition is not working please help.

I am not getting any errors at this time.

Thanks for the help!

Share this post


Link to post
Share on other sites

I just quickly scanned through those, but at least I see why your waitUntil didn't work: wrong syntax.

Example how it should be:

waitUntil{((vehicle player) isKindOf "Air") and ((vehicle player) distance epad) < 300};

It'll just hold there until the condition is true, at which point it continues. No then, do or anything else.

I'm still a bit confused why you have vehicle player here if it's the player who's calling for the chopper. At that point the players should be on the ground and not in a vehicle which isKindOf "air", no?

Edited by Fincuan

Share this post


Link to post
Share on other sites

I thought the vehicle player would be checked to see if that player is in the helo being it says "isKindOf "Air".

Then that player would be in the "Air", in a helo.

Not the one calling for the evac.

Then vehicle player would be checked for distances from the epad, 1 at 300m to create smoke.

then the 2nd one at 50m to delete the map marker and helo pad.

I hope I cleared it up for you.

If there is a better syntax for the triggers to detect the helo, please let me know.

All I'm trying to do now is to get the triggers to detect the helo.

Thanks!

Edited by Cougarxr7

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×