Jump to content
Sign in to follow this  
thetrooper

Delete AI waypoint by name

Recommended Posts

Hi all, I know how to use the following below, but can get tedious working out the the actual waypoint if you have a lot of them.

deleteWaypoint [_grp, 2]

You can name your waypoints, wondered if fit works by deleting it by a name as opposed to a number?

ie

deleteWaypoint [_grp, mywaypoint]

?

(I did try this, it doesn't work)

Edited by TheTrooper

Share this post


Link to post
Share on other sites

I can't test but it says the name is a string so try that

Syntax:

waypoint setWaypointName name

Parameters:

waypoint: Waypoint

name: String

Return Value:

Nothing

deleteWaypoint [_grp, "mywaypoint"]

Share this post


Link to post
Share on other sites

As usual they give us new commands but instead of being easy they make it tricky to use

Looks like you need to run through the waypoint array and search for the name and then delete it.

{if (waypointName _x == "test") then { deletewaypoint _x;}} foreach (waypoints group player)

it needs making in to a function then you could just pass the group and waypoint name to it.

I don't have time right now.

Share this post


Link to post
Share on other sites

sorry mobile input fail post. see no way to delete it. just wanted to copy the function to delete wps ;0) thanks

Sent from mobile

Share this post


Link to post
Share on other sites

Still kind of stuck on this one. It would sole a lot of problems. If anyone could help.

Share this post


Link to post
Share on other sites

I'd forgotten about this, I did end up making it into a function to make it easier for me to use.

Save an init.sqf file containg this line

call compile preprocessFile "delWP_name.sqf";

Next save the function delWP_name.sqf

// in init.sqf put the next line.
//call compile preprocessFile "delWP_name.sqf";
// 
//next line used to call the function
//[unit or group name,["waypoint name","waypoint name"]] call FNC_WP_Name

private ["_caller","_wp_grp","_wp_names_array"];

FNC_WP_Name = {
_wp_grp = _this select 0;
_wp_names_array  = _this select 1;
if (typename _caller  != "GROUP") then {_wp_grp  = group _caller} else {_wp_grp = _caller};
{
  _loop = _x;
 {
if (waypointName _loop ==  _x) then {
 deletewaypoint _loop;
   };
} foreach _wp_names_array;
} foreach (waypoints _wp_grp);
};

the when you want to delete a waypoint or waypoints for a group or unit use

[unit or group name,["waypoint name","waypoint name"]] call FNC_WP_Name

it will accept multiple waypoint names for deletion just add them to the array.

Share this post


Link to post
Share on other sites

Oof, just had a go but got some errors in my report.

by the looks of it I got to change something in the following? (delWP_name.sqf)

private ["_caller","_wp_grp","_wp_names_array"];

Share this post


Link to post
Share on other sites

I just started a clean map and used the code above by copying and pasting and it works fine.

Share this post


Link to post
Share on other sites

Yeah it works fine now. Nice one!. Only thing is the report file shows a couple of errors. Don't know what the effect of it is if any, but just so you know.

Error in expression <s_array  = _this select 1;
if (typename _caller  != "GROUP") then {_wp_grp  = gr>
 Error position: <_caller  != "GROUP") then {_wp_grp  = gr>
 Error Undefined variable in expression: _caller

Share this post


Link to post
Share on other sites

Your right, I made a last minute change and as it was working I missed something.

// in init.sqf put the next line.
//call compile preprocessFile "delWP_name.sqf";
// 
//next line used to call the function
//[unit or group name,["waypoint name","waypoint name"]] call FNC_WP_Name

FNC_WP_Name = {

private ["_caller","_wp_grp","_wp_names_array"];

_caller = _this select 0;

_wp_names_array  = _this select 1;

if (typename _caller  != "GROUP") then {_wp_grp  = group _caller} else {_wp_grp = _caller};
{
  _loop = _x;
 {
if (waypointName _loop ==  _x) then {
    deletewaypoint _loop;
   };
   } foreach _wp_names_array;
} foreach (waypoints _wp_grp);
};

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  

×