Jump to content
Sign in to follow this  
Rejn

Check if group has waypoint

Recommended Posts

Im trying to find a way to check if a group has no waypoint so that i can add a waypoint as sometimes merging squads and selecting the leader of another squad to lead removes the waypoints (sometimes).

Im looking at the following:

Quote[/b] ]

WaypointList = waypoints Unit

Does anyone know if this works?

Quote[/b] ]

waypointlist = waypoints player

?(waypointslist==isnil): do whatever

Share this post


Link to post
Share on other sites

As the command "waypoints _unit" will return an array with all (or no) waypoints of the selected unit, a isnil check won't work.

But as it is an array, a "count" might do the trick.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if (count (waypoints _unit) == 0) then {

.....code

Although i don't know if waypoints already passed are deleted or if they remain inside this array. If they remain, it could be tricky to check if a unit already has passed all WP's or not.

But at first i guess this is worth a try.

Share this post


Link to post
Share on other sites

Thanks mate smile_o.gif I will give your suggestion a try and see if it works. Will let you know smile_o.gif

Share this post


Link to post
Share on other sites

Didn't seem to work even for a unit/group that had no waypoints sad_o.gif

I may have to work around this another way.

Share this post


Link to post
Share on other sites

Now that you've got the array of waypoints, use the in command to search the array for your token. You might have to play around a little bit to get exactly what you want, but the in command works great whenever I've needed to use it. Also, parseNumber and parseText are really handy for searching through arrays of multiple data types, but I don't think that's your issue here.

I would suggest you save a waypoint position as a variable named _token or something like that, then use _token as the search variable.

Share this post


Link to post
Share on other sites

I might even be able to use the find command as that can quickly and easily search for anything in the array as far as I know. So if the result comes up as 0 I can go from there.

Share this post


Link to post
Share on other sites

That's another good command I forgot to mention. Yeah, find is great if you want to know which waypoint it is, for example. Just remember that arrays start at 0, and waypoint 0 is the initial starting position for the group. biggrin_o.gif

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  

×