Jump to content
Sign in to follow this  
sarogahtyp

[SOLVED] synchonizeWaypoints not working [needs delay]

Recommended Posts

I need to solve this problem for a project (Spawn Script Creator) that deletes all specified units, vehicles and waypoints created with editor and spawns all of it with all needed informations at a later time.

 

Its so long, Ive to do a break here and end that post later. Ill bump the topic if I ve finished this post...

 

Okay guys I ve a problem and I try to solve it since days but I ve no luck.
I checked everything multiple times forwards and backwards but it doesnt work.
I ll give u the code snippet but I think its hard to understand it because of the multiple nested array.
I wrote a description below but if u have questions just aks please.
 

{
 _max_wp_index = (count _x)-1;
 {
  if(_forEachIndex < _max_wp_index) then
  {
   _synced_indexes = (_x select 18);
 
   if ((count (_x select 18)) > 0) then
   {
    _synced_wps = (_x select 18) apply {_all_wps select (_x)};
  
   (_all_wps select (_x select 19)) synchronizeWaypoint _synced_wps;
   };
  };
 } forEach _x;
}forEach _all_wp_info;

decription of process:
 
I ve 2 main arrays _all_wp_info and _all_wps.
_all_wp_info is an array which contains all information about all waypoints it looks like:

[[[pos,name,...],[pos,name,...],..., curWPindx],[[pos,name,...],[pos,name,...],..., curWPindx]]]

the first nested structure is group 1, group2, ...
nested in the groups is wp1, wp2, ... and the last element is not the last WP but the index of the current wp of the group.
nested in each WP is the information as position, name, behavior ...
 
the second array _all_wps is just a straight array containing all already spawned waypoints in waypoint format [group, index]:

[[grp,indx],[grp,indx],[grp,indx],[grp,indx],[grp,indx],[grp,indx]]

 
The script has 2 main loops where the outer one iterates over every group and the inner one over exery waypoint in _all_wp_info.
the first if condition inside the inner loop is to exclude the last element because its not filled with waypoint information, its just the index of the current waypoint of the group.
(_x select 18) is an array of indexes for _all_wps of all synchronized Waypoints [index, index, index, ...] for the actually processed waypoint.
this line: 

    _synced_wps = (_x select 18) apply {_all_wps select (_x)};

uses apply to push the waypoints in waypoint format [group, index] from _all_wps to _synced_wps.
_synced_wps is filled with the correct information after that, i checked that multiple times.

(_x select 19) contains the index in _all_wps of the actually processed waypoint.
so that this line:

   (_all_wps select (_x select 19)) synchronizeWaypoint _synced_wps;

selects the current processed wp from _all_wps and synchronizes it with the waypoints stored in _synced_wps.

 

Its so long, Ive to do a break here and end that post later. Ill bump the topic if I ve finished this post...

 

The problem:

syncing works only in a few cases.

 

I created 2 groups each with 3 waypoints.

In each of my tests I synced 2 waypoint each other only.

I tested each combination of synced waypoints possible and I get the following table containing the successes:

grp1   grp2   1sw2   2sw1

F      F      Y      N
F      M      Y      N
F      L      N      N

M      F      Y      N
M      M      Y      N
M      L      N      N

L      F      N      N
L      M      N      N
L      L      N      N

description of table:

 

column grp1 shows the waypoint of group 1 which I tried to sync

column grp2 shows the waypoint of group 2 which I tried to sync

column 1sw2 (1 synced with 2) shows if syncing waypoint group 1 with wp grp 2 was a success

column 2sw1 (2 synced with 1) shows if syncing waypoint group 2 with wp grp 1 was a success

F - first waypoint of group

M - middle waypoint of group

L - last waypoint of group

Y - Yes, syncing worked

N - No, syncing didnt work

 

As u can see in the table, only syncing of first and middle waypoint of group 1 with first and middle waypoint of group 2 worked. Not vice versa...

 

I hope anyone of u is fancy to this theme and has the time for it to dig in...

 

Download:

mission folder in dropbox if anyone likes to download and test the whole thing.

the code snippet above is inside "spawn_script_creator.Altis\functions\spawn\fn_spawn_all_in.sqf"

 

If u downloaded the mission and dont get where is what and which script is called by what then just PM me...

Edited by sarogahtyp

Share this post


Link to post
Share on other sites

bump because first post is finished...

Share this post


Link to post
Share on other sites

okay guys, seems to be solved. I used a waitUntil for the syncing:

waitUntil   {      (_all_wps select (_x select 19)) synchronizeWaypoint _synced_wps;    (_synced_wps isEqualTo (synchronizedWaypoints (_all_wps select (_x select 19))))   };
synchronizeWaypoint seems to need some kind of delay... that's the reason why the second Sync never worked.

but there is another mistake in my Script which is related to the Arrays Index count. That's the reason why syncing one of the last Waypoints never works. But I think I can solve that soon with some Debugging.

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  

×