Jump to content
Sign in to follow this  
Katash

Help Needed With Simple Script

Recommended Posts

Can someone please help me - I need to create a script that controls a convoy of vehicles.

In my mission my squad waits for a friendly convoy of supply trucks to arrive then escorts them through a hostile village, I'd like to have the ability to tell the convoy to "wait here" or "move on" either by using the 'supports' menu or by action menu interaction with the lead vehicle.

Important factor here is it must be multiplayer compatible and available for all players to use.

If anybody could explain how to do this I'd be very grateful.

Thanks in advance.

Share this post


Link to post
Share on other sites

player addAction["Convoy wait",{commandStop(AI that you want to stop goes here)};];

I suggest putting in an AI that has a rank above the rest, that way he'll tell his group to do the same thing.

To carry on again:

player addAction["Convoy move",{(AI that you want to move goes here) commandMove (position where you want them to go goes here)};];

Share this post


Link to post
Share on other sites

commandMove only works on local AI, so won't be multiplayer compatible for everyone.

Share this post


Link to post
Share on other sites

Unfortunately, I have to tell you that working AI convoys can be expected, according to the most conservative sources, somewhere around 2023 with the release of Arma VI. ;)

Share this post


Link to post
Share on other sites

I assume that you need them to stop or keep moving any number of times. You would need to script two actions that appear exclusively and are visible to everyone in multiplayer. They need to switch for every player when one is called by a player. The action must then tell the vehicle to move or stop where the vehicle is local (the server I assume). This is not simple, but can be done fairly quickly.

I would set up the init.sqf like this:

AllPlayers = [...];

Fnc_AddStopAction = {
   LeadVehicle addAction ["Stop", Fnc_StopConvoy];
};

Fnc_AddMoveAction = {
   LeadVehicle addAction ["Move", fnc_MoveConvoy];
};

Fnc_RemoveAction = {
   private ["_object", "_actionID"];
   _object = _this select 0;
   _actionID = _this select 1;
   _object removeAction _actionID;
};

Fnc_Move = {
   private ["_group", "_destination"];
   _group = _this select 0;
   _destination = _this select 1;
   _group commandMove _destination;
};

Fnc_StopConvoy = {
   private ["_vehicle", "_actionID"];
   _vehicle = _this select 0;
   _actionID = _this select 2;
   0 = [[_vehicle, _actionID], "Fnc_RemoveAction", AllPlayers] call BIS_fnc_MP;
   0 = [[_vehicle, _actionID], "Fnc_AddMoveAction", AllPlayers] call BIS_fnc_MP;
   {
       commandStop _x;
   } forEach (units group _vehicle);
};

fnc_MoveConvoy = {
   private ["_vehicle", "_actionID"];
   _vehicle = _this select 0;
   _actionID = _this select 2;
   0 = [[_vehicle, _actionID], "Fnc_RemoveAction", AllPlayers] call BIS_fnc_MP;
   0 = [[_vehicle, _actionID], "Fnc_AddStopAction", AllPlayers] call BIS_fnc_MP;
   0 = [[(driver _vehicle), (getMarkerPos "mkConvoyDestination")], "Fnc_Move", _vehicle] call BIS_fnc_MP;
};

0 = [] call Fnc_AddStopAction;

I assume that you have limited experience scripting, so this is what you need to get this working: a convoy with a lead vehicle named 'LeadVehicle', a marker where the convoy should go named 'mkConvoyDestination', and you must fill in the names of all of the players. You must also group all of the units in the convoy together and make sure they are not grouped with anything else. If you have all that, the functions should put the action on the vehicle from the start and handle everything.

None of this is tested in multiplayer, but it looks to me like it should work fine so long as BIS_fnc_MP does its job. It works well in singleplayer, so there are not syntax errors.

Share this post


Link to post
Share on other sites

Heres my version.. thought id have a go seeing theres 101 ways to do things in arma. Similar to Zenophon's but here i let the addActions do all the work and setvariable to display the actions.

init.sqf

if (isServer) then {

FNC_move = {
	{
		_x commandMove ( getMarkerPos "mkConvoyDestination" );
	}forEach (units group LeadVehicle);
	LeadVehicle setVariable ["stopped",false,true];
};

FNC_stop = {
	{
		commandStop _x;
	}forEach (units group LeadVehicle);
	LeadVehicle setVariable ["stopped",true,true];
};

};

if (!isDedicated) then {

player addAction ["Move Convoy",
	{ [ [], "FNC_move", effectiveCommander LeadVehicle, false ] call BIS_fnc_MP },
	nil,
	1,
	false,
	true,
	"",
	"(LeadVehicle getVariable ""stopped"")"];

player addAction ["Stop Convoy",
	{ [ [], "FNC_stop", effectiveCommander LeadVehicle, false ] call BIS_fnc_MP },
	nil,
	1,
	false,
	true,
	"",
	"(!(LeadVehicle getVariable ""stopped""))"];

};

Same as Zenophon, name your lead vehicle called LeadVehicle and a marker for their destination called "mkConvoyDestination". Tested on a dedicated server and seems ok.

EDIT: Cleaned it up a little so its not sending any code via BIS_fnc_MP

Edited by Larrow

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  

×