Jump to content

Recommended Posts

SITUATION:

The player is responsible for determining when and where a convoy will move.

 

OBJECTIVE:

The plan was to use the Command Custom menu by adding a Menu Item that the player may select.  When selected the map would open and the player could select a location on the map.  The convoy (currently on a Hold waypoint) would then get a new waypoint and have the old one deleted.

 

Admittedly, it has been a few years since I attempted something like this, but when I did this is how I did it (from the init.sqf):


//Creates a Custom menu and menu item #0 (0-9) for High Command.
missionNamespace setVariable [
  "HC_Custom_0",
  [
    ["Convoy", true],
    ["Set Waypoint", [12], "", -5, ["expression", "nul = [] execVM 'scripts\MoveConvoy.sqf';"], "1", "1"]
  ]
];

 

However, the above code no longer seems to function.  No errors are generated, but nothing happens.  The Custom Command menu remains unaffected.

 

In an attempt to resolve this problem I came across this method for accomplishing the same thing (from the description.ext):


class CfgCommunicationMenu
{
    class MoveConvoy
    {
        text = "Move Convoy";                                   // Text displayed in the menu and in a notification
        submenu = "";                                                 // Submenu opened upon activation (expression is ignored when submenu is not empty.)
        expression = "nul = [] execVM 'scripts\MoveConvoy.sqf';";                             // Code executed upon activation
        icon = "\a3\Ui_f\data\GUI\Cfg\CommunicationMenu\transport_ca.paa";  // Icon displayed permanently next to the command menu
        cursor = "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa";    // Custom cursor displayed when the item is selected
        enable = "1";                                                   // Simple expression condition for enabling the item
        removeAfterExpressionCall = 1;                 // 1 to remove the item after calling
    };
};

_ConvoyID = [player,"MoveConvoy",nil,nil,""] call BIS_fnc_addCommMenuItem;

 

The above code also functions.  Or rather I should say that it does not generate any errors.  However, I get the same results.  No changes to any of the Command Menu or menu items.

 

For completeness sake, the MoveConvoy.sqf is:

_caller = _this select 1;

_caller groupchat "Left click on the map where you want the convoy to move.";

openMap true;
mapclick = false;

onMapSingleClick "clickpos = _pos; mapclick = true; onMapSingleClick """";true;";

waituntil {mapclick or !(visiblemap)};

if (!visibleMap) exitwith {
    _caller groupchat "It is best to be certain, but time is running out.";
    }
else {
    _pos = clickpos;
    _wayP = grp_Convoy addWaypoint [_pos, 1];

    deleteWaypoint [grp_Convoy, 0];
    };

 

I am clearly doing something wrong, but without any errors being generated I'm at a loss as to what the problem might be.  If anyone has any ideas, I would certainly appreciate the help.

 

Thanks.

Share this post


Link to post
Share on other sites
11 hours ago, AlaskanGlitch said:

_caller = _this select 1;

You are not passing anything....

11 hours ago, AlaskanGlitch said:

nul = [] execVM 'scripts\MoveConvoy.sqf';

 

 

11 hours ago, AlaskanGlitch said:

deleteWaypoint [grp_Convoy, 0];

First given waypoint( Hold ) is 1 not 0. You are better off setting the groups current waypoint rather than deleting any.

_wayP = grp_Convoy addWaypoint [_pos, 0];
grp_Convoy setCurrentWaypoint _wayP;

 

 

11 hours ago, AlaskanGlitch said:

missionNamespace setVariable [   "HC_Custom_0",

"#USER:HC_Custom_0"

Share this post


Link to post
Share on other sites
9 hours ago, Larrow said:

You are not passing anything....

 

 

First given waypoint( Hold ) is 1 not 0. You are better off setting the groups current waypoint rather than deleting any.


_wayP = grp_Convoy addWaypoint [_pos, 0];
grp_Convoy setCurrentWaypoint _wayP;

 

 

"#USER:HC_Custom_0"

Actually, the Hold waypoint is ID 0, which is why the new one that I created had an ID of 1.  Also, adding #USER: before HC_Custom_0 made absolutely no difference.  The variable was still being updated either way, but no changes where made to the Custom menu.

Share this post


Link to post
Share on other sites
15 hours ago, AlaskanGlitch said:

Actually, the Hold waypoint is ID 0,

Yes an ID of #0 in the editor. This is not the same as the index you are deleting.

A waypoint is automatically made for every group at index 0 that is the position they spawn at.

Place a group and give the group a name, give them one waypoint( Hold ) in the editor, preview mission and in the debugConsole type....

waypoints groupName apply{ waypointType _x }

You will see that it actually returns two waypoints, the one you added(Hold) in the editor is in fact at index 1.

 

15 hours ago, AlaskanGlitch said:

which is why the new one that I created had an ID of 1

Where do you create a waypoint at ID 1?

All I see is you add a new waypoint to the end of the list that has a random radius of 1.

 

 

15 hours ago, AlaskanGlitch said:

Also, adding #USER: before HC_Custom_0 made absolutely no difference.

Sorry my mistake was confusing myself with calling a sub menu.

missionNamespace setVariable [
  "HC_Custom_0",
  [
    ["Convoy", true],
    ["Set Waypoint", [12], "", -5, [["expression", "nul = [] execVM 'scripts\MoveConvoy.sqf';"]], "1", "1"]
  ]
];

Missing a set of [] around the expression param

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

×