Jump to content
Sign in to follow this  
NGagedFX

addWaypoint problems

Recommended Posts

I'm trying to create a script that allows pilots to add a waypoint for themselves with a mapclick. I'm experiencing some weird problems though.

init of airplane

this addAction ["Create Waypoint", "addWaypoint.sqf"];

addWaypoint.sqf - this piece of code works

onMapSingleClick {(group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]};

addWaypoint.sqf - while this doesn't :confused:

private ["_grpp"];
_grpp = group player;
onMapSingleClick {_grpp addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]};

Since the waypoint disappears at about 1km distance when in an airplane, I want to set the completion radius to 0, but this doesn't do anything:

onMapSingleClick {(group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]};
[(group player), 1] setWaypointCompletionRadius 0;

Share this post


Link to post
Share on other sites

But I declared _grpp private so it can be used in the onMapSingleClick scope right? Or what would be the solution for that? I can't find anything about the setWaypointCompletionRadius bug, is it something that should be fixed by BIS in the next patch? Cause else I can never get this to work properly.

The whole idea behind this is for infantry to put a marker on the map and then the pilot can create a waypoint by clicking on the map so he has an arrow on his HUD pointing at the target. This way he won't have to constantly look at his map where he's going and it would make non-laser-guided weapons a lot more effective.

Share this post


Link to post
Share on other sites

I agree it is rather ridiculous pilots have to continually check their maps to find where they are going. Good idea.

Share this post


Link to post
Share on other sites

Why do u define the group? You can use group player...I don't get it...

onMapSingleClick {group player addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]};

or if u want to define it:

onMapSingleClick {private ["_grpp"];_grpp = group player;_grpp addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1]};

Share this post


Link to post
Share on other sites
I agree it is rather ridiculous pilots have to continually check their maps to find where they are going. Good idea.

Because this isn't the way they do it in an A10 :p

Pilot-Cockpit-Map-1323373.jpg

Giallustio, I automatically define local variables and even though (vehicle player) worked, I was quite confused as to why _grpp didn't.

PvPscene, simple but solid solution. :) I came up with this:

onMapSingleClick {
   _waypoint = (group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1];
};
_waypoint setWaypointStatements ["!(Alive player)", "deleteWaypoint [(group player), 1]"];

However, the waypoint still gets deleted when I get close. I tried global variables (without the _ ) and I tried every combination of the private command. :confused:

Share this post


Link to post
Share on other sites

The setWaypointStatements is outside the scope of the onMapSingleClick area.

onMapSingleClick
{
_waypoint = (group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1];
_waypoint setWaypointStatements ["!(alive player)", "deleteWaypoint [(group player), 1]"];
};

Or

onMapSingleClick
{
My_waypoint = (group player) addWaypoint [[_pos select 0, _pos select 1, -8], 0, 1];
};
waitUntil {(!(isNil "My_waypoint"))};
My_waypoint setWaypointStatements ["!(alive player)", "deleteWaypoint [(group player), 1]"];

Share this post


Link to post
Share on other sites

I see! So right now I kinda got it working. I haven't tested it in MP yet, but in the editor it works solid.

plane_1 init

this addEventHandler ["GetIn", {plane_1 addAction ["Create Waypoint", "test2.sqf"]}];

addWaypoint.sqf

onMapSingleClick { 
_waypoint = (group player) addWaypoint [[_pos select 0, _pos select 1, -6], 0, 1];
_waypoint setWaypointStatements ["!(Alive player)", "deleteWaypoint [(group player), 1]"];
}; 

_id = _this select 2;
(vehicle player) removeAction _id;
_action = (vehicle player) addAction ["Delete Waypoint", "deleteWaypoint.sqf"];
_delete = false;
_plane = vehicle player;

while {!(_delete)} do {
_grpp = group player;
if (!(Alive player) OR !(Alive vehicle player) OR (vehicle player == player)) then {
	deleteWaypoint [_grpp, 1];
	_delete = true;
	_plane removeAction _action;
};
sleep 1;
};

deleteWaypoint.sqf

_id = _this select 2;

deleteWaypoint [(group player), 1];
(vehicle player) removeAction _id;
(vehicle player) addAction ["Create Waypoint", "test2.sqf"];

However, there are some thing I can't get to work.

1. In the eventHandler in the init of plane_1, I have to attach it specifically to plane_1. addEventHandler ["GetIn", {this addAction ["Create Waypoint", "test2.sqf"]}]; does not work. :confused:

2. Right now the actions are added to the vehicle and I don't want an action to pop up for people standing next to it, so I rather have the action added to the player. But no matter what I try, player addAction does nothing.

3. I don't want to add the eventHandler to each vehicle in the editor, I want it to be more general. So I was thinking of adding this to the init.sqf:

{_x addEventhandler ["GetIn", {_x addAction ["Create Waypoint", "test2.sqf"]}];} forEach listObjects "Air"; //forEach *vehicle that isKindOf "Air";*

Edited by NGagedFX

Share this post


Link to post
Share on other sites

For now I simply created an array of all vehicles followed by a forEach by putting this in the init.sqf:

_varray = vehicles;
hintSilent format ["vehicles = %1", _varray];
{_x addEventhandler ["GetIn", {_x addAction ["Create Waypoint", "pilotWaypoint2.sqf"]}];} forEach _varray;

This however does nothing, not even when I change it {player addAction... :(

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  

×