Jump to content
Sign in to follow this  
ov3rj0rd

How to get a script to reapply to a re spawned vehicle

Recommended Posts

Well title says it all, I am having a problem with some scripts to reapply to vehicles after they have re spawned. VAS for an example, I have an MHQ but when it is destroyed it loses its Virtual Ammo box add action. Any help would be much appreciated.

Share this post


Link to post
Share on other sites

Just spent the night sorting this one out! Know how much of headache it can cause so I'll share my wip with ya.

vehicleInit.sqf

fnc_vehAction1 =
{
_this addAction
["Repair Vehicle","Scripts\repair.sqf",
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction1";
};
fnc_vehAction2 =
{
_this addAction ["<t color='#ff1111'>Virtual Ammobox</t>","VAS\open.sqf",
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction2";
};

if (!isServer) exitWith {};

_vehicle = _this;
_vehiclepos = getPos _vehicle;
_vehicledir = getDir _vehicle;
_classname = typeOf _vehicle;

// Add vehicle actions
_vehAction1 = [_vehicle,"fnc_vehAction1",nil,true] spawn BIS_fnc_MP;
_vehAction2 = [_vehicle,"fnc_vehAction2",nil,true] spawn BIS_fnc_MP;

waitUntil{!alive _vehicle};
sleep 5;
deleteVehicle _this;
sleep 5;
_vehicle = _classname createVehicle _vehiclepos;
_vehicle setPos _vehiclepos;
_vehicle setDir _vehicledir;
_vehicle execVM "scripts\vehicleInit.sqf";

Sorry, just had to make some changes so hope you didn't read the first part that I had up!

Alright, accidentally posted the wrong one up. This script will work but you need to execute it from the the init.sqf like so:

MHQ_Alpha execVM "scripts\vehicleInit.sqf";

Where MHQ_Alpha is the name of your vehicle or mobile hq.

The problem with this one is that it doesn't store the name. The first script I accidentally put up stores the name but I realized when I put it up here that I was calling this script to respawn the vehicle, and that script isn't working entirely yet so I'll have to play with it some more when I have time but it's too late here to do it today.

If you have a respawn script already or some one else's that your using then you'll just need to follow what I did for the vehicleActions and fnc_vehicleActions.

Edited by King_Richard

Share this post


Link to post
Share on other sites

Just add a MP Eventhandler "Respawn" in the vehicle's init.

Share this post


Link to post
Share on other sites

NICE script King Richard - thank for sharing - coupe of things maybe someone could help me with

Just tried this on our dedi server and it did work to a degree but not entirely.

Had a vehicle named MCV

Synched to BIS vehicle respawn module - set for 120sec (2 min) respawn

When destroyed it respawned with the actions attached so thats working ok.

But then about 30 sec later the vehicle blew up and another one spawned on to of it WITHOUT The actions.

I did try moving the respawn point to make sure it wasnt an "ARMA" thing and I am sure its not as I have

several vehicles with the same respawn module but NOT with the vehicleint.sqf and they work fine.

Did I do something wrong - do I need to synch it to the BIS module?

I think what Ranwer above said is something to do with it but I have no idea how to do that.

Any chance ranwer you could point us in the right direction?

Thx in advance

If we can get this working on a dedi it would be a VERY GOOD script that I am sure would come in very usefull for people

Share this post


Link to post
Share on other sites

Thank you for the fast replies!

@King_Richard: I will try this out. I am using Tophe's vehicle respawn modified by Ahoy World so where would your bit go in?

@Ranwer: Could you explain a little bit more on that? I searched MP Eventhandler Respawn and got this https://community.bistudio.com/wiki/Arma_3_Respawn but I am not sure what to make of it. Sorry I am still very new to this :confused:

Here is the Respawn script that has been edited by AW. Where would that code go in here?

================================================================================================================== */


private ["_hasname","_delay","_deserted","_respawns","_noend","_dead","_nodelay","_timeout","_position","_dir","_effect","_rounds","_run","_unit","_explode","_dynamic","_unitinit","_haveinit","_unitname","_type"];
if (!isServer) exitWith {};

// Define variables
_unit = _this select 0;
_delay = if (count _this > 1) then {_this select 1} else {30};
_deserted = if (count _this > 2) then {_this select 2} else {120};
_respawns = if (count _this > 3) then {_this select 3} else {0};
_explode = if (count _this > 4) then {_this select 4} else {false};
_dynamic = if (count _this > 5) then {_this select 5} else {false};
_unitinit = if (count _this > 6) then {_this select 6} else {};
_haveinit = if (count _this > 6) then {true} else {false};

_hasname = false;
_unitname = vehicleVarName _unit;
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;};
_noend = true;
_run = true;
_rounds = 0;

if (_delay < 0) then {_delay = 0};
if (_deserted < 0) then {_deserted = 0};
if (_respawns <= 0) then {_respawns= 0; _noend = true;};
if (_respawns > 0) then {_noend = false};

_dir = getDir _unit;
_position = getPosASL _unit;
_type = typeOf _unit;
_dead = false;
_nodelay = false;


// Start monitoring the vehicle
while {_run} do
{
 sleep (5 + (random 20));
 if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true};

// Check if the vehicle is deserted.
if (_deserted > 0) then
{
   _nearPlayers = false;
   {
     if ((_x distance _unit) < PARAMS_VehicleRespawnDistance) exitWith { _nearPlayers = true; };
   } forEach playableUnits;
	if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8) and !_nearPlayers) then
	{
		_timeout = time + _deserted;
		sleep 0.1;
	 	waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0};
		if ({alive _x} count crew _unit > 0) then {_dead = false};
		if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};
		if !(alive _unit) then {_dead = true; _nodelay = false};
	};
};

// Respawn vehicle
 if (_dead) then
{
	if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
	if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
	if (_explode) then {_effect = "M_AT" createVehicle getPosASL _unit; _effect setPosASL getPosASL _unit;};
	sleep 0.1;



	deleteVehicle _unit;
	sleep 2;
	_unit = _type createVehicle _position;
	_unit setPosASL [_position select 0,_position select 1,(_position select 2) + 0.2];
	_unit setDir _dir;
	if (["B_UAV", _type] call BIS_fnc_inString) then { createVehicleCrew _unit; };

	if(_unitname != "") then
	{
		_unit  setVehicleVarName (format ["%1",_unitname]);
		PublicVariable (format ["%1",_unitname]);
	};
	//processInitCommands;

	[[[_unit],"scripts\aw_unitSetup.sqf"],"BIS_fnc_execVM",nil,true] spawn BIS_fnc_MP;
	_unit addeventhandler ["fired",{  if (vehicle (_this select 0) in list base ) then {deleteVehicle (_this select 6)};}];
	//if(isServer) then {[_unit] execVM "scripts\aw_markerFollow.sqf"};

	_dead = false;

	// Check respawn amount
	if !(_noend) then {_rounds = _rounds + 1};
	if ((_rounds == _respawns) and !(_noend)) then {_run = false;};
};
};

Share this post


Link to post
Share on other sites

@Ranwer,

I tried getting the event "Respawn" to work but couldn't. Do you know of any examples showing it execute a sqf on vehicle respawn? I've tried searching off and on for that one but couldn't find any extra info on it. Main reason I looked at creating a vehicle through script so I could re add the actions.

@Doodle,

No it does not get synced to the bis vehicle spawn module. Was the vehicle that blew up using the script that I posted? Or was it synced to the spawn module? Sounds like a duplicate spawned in. Also if you left the sleep timers at 5 then the vehicles running this script will spawn after 10 seconds. 5 seconds until it's deleted and then another 5 seconds until it's created. I put them to 5 for testing purposes.

The version that I posted does not save the name that you give the vehicle in the editor. I'm working on one that includes the name but have some issues to resolve with it.

@OV3RJ0RD,

That's a robust spawn script there! I saw traces of the old one that wouldn't work anymore and did not realize that it was updated. I'll have to download it sometime and look into it more since it's running in a loop. Assuming the actions aren't already added to the vehicle then the only places that I see for adding in the actions is @ line 34, underneath the get positions and delay code. But then you'd have to call the actions again after createVehicle around @ line 82, under "//processInitCommands;". But I don't know what's going on with "scripts\aw_unitSetup.sqf" without downloading and testing it out.

So, without looking further into, right now I'd say add at the top of the script:

fnc_vehAction1 =
{
_this addAction
["Repair Vehicle","Scripts\repair.sqf",
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction1";
};

And then add:

_vehAction1 = [_unit,"fnc_vehAction1",nil,true] spawn BIS_fnc_MP;

to the two places that I mentioned, underneath:: _nodelay = false; and once again under //processInitCommands;

Of course changing the actions to whatever you need them to do. And if you've already added the actions to the vehicles, then you'll just need to add the code to the //processInitCommands; section.

I also realized that I can use =BTC= revive's mobile HQ and add the actions to that as well. Will have to check the release notes to make sure I can post how to before doing so. But I like spawning into the cargo section of the vehicle so I'll continue to work on what I got going too.

Share this post


Link to post
Share on other sites

@King Richard

Thanks for the reply , I tested again WITHOUT the bis respawn mod and can report back that it worked perfectly (not tested on our dedi yet, will do tonight).

Will be keeping an eye on this cos if we can find a way of the vehicle keeping its name this would become a much needed script.

Not sure if its of any use to you but the BIS module keeps the vehicle name and works perfectly on hosted and dedi - ,ight give you a clue on how to save vehice name.

---------- Post added at 08:21 PM ---------- Previous post was at 07:52 PM ----------

@King Richard

This is part of a script we use to create circular partols - This is how it sets the vehicle name and it keeps the name on respawn. This has been tried and tested on our dedi and works perfectly.

if (!isServer) exitWith {};

	_con1GRP1 = createGroup EAST;  

	_con1 = createVehicle ["I_APC_tracked_03_cannon_F", getMarkerPos "c1a", [],0,"NONE"];
	_con1  setDir 190;

	_VarName = "con1"; 
	_con1 SetVehicleVarName _VarName; 
           call compile format["%1 = _con1", _VarName]; 
           clearMagazineCargoGlobal  _con1;
           clearWeaponCargoGlobal _con1;
	_con1 setCaptive false;
           _con1pilot = _con1GRP1 createunit ["O_soldierU_AR_F", [0,0,1], [], 0, "CAN_COLLIDE"];
           _VarName = "c1d"; 
           _con1pilot SetVehicleVarName _VarName; 
           call compile format["%1 = _con1pilot", _VarName];

          _con1pilot moveInDriver _con1; 
	_con1pilot setCombatMode "WHITE";
	_con1pilot setBehaviour "SAFE";
           _con1pilot allowDamage true;
           _con1pilot setCaptive false;
	sleep 3.0;

           _con1gunner = _con1GRP1 createunit ["O_SoldierU_SL_F", [0,0,1], [], 0, "CAN_COLLIDE"];
          	_VarName = "c1ga";
	_con1gunner SetVehicleVarName _VarName;
           call compile format["%1 = _con1gunner", _VarName];
	_con1gunner moveInTurret [_con1, [0]];
	_con1gunner setCombatMode "RED";
	_con1gunner setBehaviour "AWARE";
           _con1gunner setCaptive false;

           _con1gunner1 = _con1GRP1 createunit ["O_sniper_F", [0,0,1], [], 0, "CAN_COLLIDE"];
          	_VarName = "c1gb";
	_con1gunner1 SetVehicleVarName _VarName;
           call compile format["%1 = _con1gunner1", _VarName];
	_con1gunner1 moveInTurret [_con1, [0,0]];
	_con1gunner1 setCombatMode "RED";
	_con1gunner1 setBehaviour "AWARE";
           _con1gunner1 setCaptive false;
 		_con1 lock true;
 /*
             _con1gunner1 = _con1GRP1 createunit ["O_soldierU_AR_F", [0,0,1], [], 0, "CAN_COLLIDE"];
          	_VarName = "c1g1";
	_con1gunner1 SetVehicleVarName _VarName;
           call compile format["%1 = _con1gunner1", _VarName];
	_con1gunner1 moveInTurret [_con1, [0,1]];
	_con1gunner1 setCombatMode "RED";
	_con1gunner1 setBehaviour "AWARE";
           _con1gunner1 setCaptive true;

(not sure if any use to you)

Share this post


Link to post
Share on other sites

Put this in your vehicle's init:

this addMPEventHandler ["MPRespawn",{_this execVM "respawn.sqf"}];

Then in the respawn.sqf, put:

_veh addAction ["Open VAS Menu","[color=#3E3E3E]VAS\open.sqf[/color]"];

It should put the Eventhandler into a loop so it should come up each time it respawns.

NOTE: King_Richard's way could be alot better, but my script here is more basic. :D

Regards,

Ranwer

Share this post


Link to post
Share on other sites
Put this in your vehicle's init:

this addMPEventHandler ["MPRespawn",{_this execVM "respawn.sqf"}];

Then in the respawn.sqf, put:

_veh addAction ["Open VAS Menu","[color=#3E3E3E]VAS\open.sqf[/color]"];

It should put the Eventhandler into a loop so it should come up each time it respawns.

NOTE: King_Richard's way could be alot better, but my script here is more basic. :D

Regards,

Ranwer

Put this in your vehicle's init:

this addMPEventHandler ["MPRespawn",{_this execVM "respawn.sqf"}];

Then in the respawn.sqf, put:

_veh addAction ["Open VAS Menu","[color=#3E3E3E]VAS\open.sqf[/color]"];

It should put the Eventhandler into a loop so it should come up each time it respawns.

NOTE: King_Richard's way could be alot better, but my script here is more basic. :D

Regards,

Ranwer

@Ranwar - Yes this does look a very simple option - will test this out - any idea if it works on a dedi server?

@King Richard - Tested on our dedi last night seemed to work fine

Wonder if anyone can help with the following. I changed one of the actions to a different script that I kow works fine when called from radio trigger but didnt run as an add action from the vehicle - even though I could see it. I am guessing it was something to do with the way I called the script.

In a radio trigger I run it as

publicVariable "cas1"; cas1 = true; nul = execVM "cas1_info.sqf";

But this didnt work from add adtion, any idea how I would go about calling the above scriprt as a vehicle add action as below

fnc_vehAction2 =

{

_this addAction ["<t color=#01DFD7'>Ammobox</t>","VAS\open.sqf",

nil, 1, false, true, "",

"alive _this && {speed _this == 0}];

publicVariable "fnc_vehAction2";

Thanks in advance

Share this post


Link to post
Share on other sites

Ranwer,

Thank you for the script snip but I'm still unable to get it working. Tried it on a helicopter if that makes a difference. From what I read on the event handler's, "Init" is the one that is used in conjunction with createVehicle, but I haven't played with it.

Doodle,

Note the execute sqf's section as I've left one in there for reference that will need to be deleted or changed. Same goes for the actions, adjust them to whatever you need.

MHQvehicleInit.sqf

/**************************************************************************
Add to vehicle's init in the editor
null = [this] execVM "Scripts\MHQvehicleInit.sqf";
***************************************************************************/

_spawnDelay = 5; // Time for respawn

/////////////////////////// VEHICLE ACTIONS ///////////////////////////
///////////////////////////////////////////////////////////////////////

// Actions are public for jip's
fnc_vehAction1 =
{
_this addAction
["Repair Vehicle","Scripts\repair.sqf",
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction1";
};
fnc_vehAction2 =
{
_this addAction ["<t color='#ff1111'>Virtual Ammobox</t>","VAS\open.sqf",
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction2";
};

fnc_AddVehicleActions =
{
   private ["_vehAction1","_vehAction2","_vehicle"];
   _vehicle = _this select 0;
   // calls the functions to add actions to the vehicle
_vehAction1 = [_vehicle,"fnc_vehAction1",nil,true] spawn BIS_fnc_MP;
_vehAction2 = [_vehicle,"fnc_vehAction2",nil,true] spawn BIS_fnc_MP;
};

/////////////////////////// EXECUTE SQF's /////////////////////////////
///////////////////////////////////////////////////////////////////////

fnc_ExecVehSQFs =
{
private ["_veh","_vName"];
_veh = _this select 0;
_vName = _this select 1;
// use this area to execute your external sqf's on vehicle spawn
null = [[[_veh,_vName],"scripts\vehMarker.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;
};

///////////////////////////////////////////////////////////////////////
/////////////////////////// THE REST OF IT ////////////////////////////
///////////////////////////////////////////////////////////////////////

if (!isServer) exitWith {};

// Load Initial vehicle variables
_vehicle = _this select 0;
_vehName = vehicleVarName _vehicle;
_vehiclepos = getPos _vehicle;
_vehicledir = getDir _vehicle;
_classname = typeOf _vehicle;
// _run keeps the loop going and keeps given name of vehicle from the editor
_vehKilled = false;
_run = true;

// init addactions and external sqf's
call {[_vehicle] call fnc_AddVehicleActions};
call {[_vehicle,_vehName] call fnc_ExecVehSQFs};

while {_run} do
{
sleep 1; // rest between alive checks

if (!(alive _vehicle)) then {_vehKilled = true; sleep 1;};

if (_vehKilled) then
{
	sleep _spawnDelay;
	deleteVehicle _vehicle;
	sleep 2;

	// set vehicle position and name
	_vehicle = _classname createVehicle _vehiclepos;
	_vehicle setPos _vehiclepos;
	_vehicle setDir _vehicledir;
	_vehicle SetVehicleVarName (format ["%1", _vehName]);
	publicVariable format ["%1", _vehName];

	// Calls to add actions and execute other sqf's
	call {[_vehicle] call fnc_AddVehicleActions};
	call {[_vehicle,_vehName] call fnc_ExecVehSQFs};

	// Respawn and init done!
	_vehKilled = false;
};
};

This one will keep the vehicle's name. Problem I was having is solved by not exiting the script. Do note that this script is meant to be simple and will not delete deserted vehicles and such, it just does what I need it to for the time being. If you use it, let me know if there's any problems as I haven't had time to test it with the rest of the guys!

Your radio trigger, I have no idea what it's doing or how it's executed as I have not ventured into radio triggers at all. However, if your just trying to get an action added to the vehicle that executes "cas1_info.sqf" when performed then using the script from above edit this section, append a new function called fnc_vehAction3 and add it to fnc_AddVehicleActions: Or, change one of the actions if your not using repair for example

fnc_vehAction3 = //fnc_vehAction3 added 
{
_this addAction ["cas1","cas1_info.sqf", // name of action and sqf file changed
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"]; // if you need the action available while vehicle is moving then remove the speed check
publicVariable "fnc_vehAction3"; // fnc_vehAction3 made public for jip's
};

fnc_AddVehicleActions =
{
   private ["_vehAction1","_vehAction2","_vehicle","_vehAction3"]; // added _vehAction3 to the array
   _vehicle = _this select 0;
   // calls the functions to add actions to the vehicle
_vehAction1 = [_vehicle,"fnc_vehAction1",nil,true] spawn BIS_fnc_MP;
_vehAction2 = [_vehicle,"fnc_vehAction2",nil,true] spawn BIS_fnc_MP;
_vehAction3 = [_vehicle,"fnc_vehAction3",nil,true] spawn BIS_fnc_MP; // added a 3rd action which calls fnc_vehAction3
};

I think that's what your asking.

Edited by King_Richard

Share this post


Link to post
Share on other sites

@king Richard

congrats on solving the namin vehicle issue

Sorry should have been more precise about what I meant - I understand about adding and editing the actions attached to the vehicle.

I have a radio trigger that calls in air suppprt

called it from the radio with the following line

publicVariable "cas1"; cas1 = true; nul = execVM "cas1_info.sqf";

- it works perfectly.

I would like to call it from the vehicle ie a new add action (or amend existing) rather than radio

I have tried all the below to no avail - any idea

fnc_vehAction1 =

{

_this addAction

["CAS"," publicVariable "cas1"; cas1 = true; nul = execVM "cas1_info.sqf";

", nil, 1, false, true, "",

"alive _this && {speed _this == 0}"];

publicVariable "fnc_vehAction1";

or

fnc_vehAction1 =

{

_this addAction

["CAS"," nul = execVM "cas1_info.sqf";

", nil, 1, false, true, "",

"alive _this && {speed _this == 0}"];

publicVariable "fnc_vehAction1";

or

fnc_vehAction1 =

{

_this addAction

["CAS"," "cas1_info.sqf";

", nil, 1, false, true, "",

"alive _this && {speed _this == 0}"];

publicVariable "fnc_vehAction1";

will let you know how i get on with new version

Thanks

Share this post


Link to post
Share on other sites

Doodle,

This might work:

fnc_vehAction1 =
{
_this addAction
["CAS",{cas1 = true, publicVariable "cas1", execVM "cas1_info.sqf"}, // brackets around the code to execute
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction1";
};

And if it doesn't then you'd need to find out what cas1 does when true, but that's in another script and can't help ya much with that.

Edited by King_Richard

Share this post


Link to post
Share on other sites

King Richard, you're awesome! That script pretty much solved all of my issues with VAS and respawning MHQs. I do have one issue, though. I have a marker that attaches to the vehicle. When first starting everything works fine and dandy, but once a vehicle is destroyed and respawns, the marker doesn't move. It stays right where the vehicle was initially destroyed.

vehMarker.sqf

while{not isnull helo1} do {"mhqheli" setmarkerpos getpos helo1; sleep 0.5;};

I'm really new to this, but I'm not seeing what's wrong with any of it.

Share this post


Link to post
Share on other sites
Doodle,

This might work:

fnc_vehAction1 =
{
_this addAction
["CAS",{cas1 = true, publicVariable "cas1", execVM "cas1_info.sqf"}, // brackets around the code to execute
nil, 1, false, true, "",
"alive _this && {speed _this == 0}"];
publicVariable "fnc_vehAction1";
};

And if it doesn't then you'd need to find out what cas1 does when true, but that's in another script and can't help ya much with that.

@King Richard

The above worked perfectly - many thanks.

I tried the amended script last night (the one that remembers the vehicles name) and I think it might not be quite right as it kicked an error up when I tried it on our. Sorry didnt manage to catch it but I think it was referencing the veh name or it may have had something to do wth the bit below

fnc_ExecVehSQFs =
{
   private ["_veh","_vName"];
   _veh = _this select 0;
   _vName = _this select 1;
   // use this area to execute your external sqf's on vehicle spawn
   null = [[[_veh,_vName],"scripts\vehMarker.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;
};

as I wasnt using a the script in here - tried commenting out this section too and still an error

Didnt have time to investigate further as we had a game on.

For the time being I have reverted back to the first version on page and to get around the "not remembering the vehicles name" I made the vehicle indestructable not a perfect solution but it does all work

@Nutlink - a work around for not remembering the name is use the version on the first page and make the vehicle indestructable not ideal but a hacky solution. We had exactly the same issue as the vehilce has a marker attached to it and that marker is referenced in other scripts

Share this post


Link to post
Share on other sites

Nutlink,

The vehicle is null during the time that it's deleted and respawned hence the reason for your marker being deleted. The script that I'm posting does not work on a dedicated server for me and I have yet to track down the culprit. But if your not running it on a dedicated server then it's not a problem! It's also geared towards coop type of missions hence no side check before showing the marker. When this part is finished I'll create a new thread for tracking issues on these scripts as to not derail this thread into a conversation about markers.

vehMarker.sqf

if (!isServer) exitWith {};

private ["_vehicle","_vehName","_vehMarker","_mColor"];

_vehicle = _this select 0;
_vehName = _this select 1;

_mColor = "ColorBlue";

// Create a Marker for vehicle on map
_marker = createMarkerLocal [format ["%1" + "_marker", _vehName], getPos _vehicle];
format ["%1", _marker] setmarkertypeLocal "mil_dot";
format ["%1", _marker] setmarkerColorLocal _mColor;
format ["%1", _marker] setMarkerSizeLocal [0.3, 0.3];
format ["%1", _marker] setMarkerAlphaLocal 0.5;
format ["%1", _marker] setMarkerTextLocal format ["%1", _vehName];

// Move marker to vehicles location while alive
while {alive _vehicle} do
{
	format ["%1", _vehMarker] setMarkerPosLocal (getPos _vehicle);
	if (speed _vehicle < 1 && speed _vehicle > -1) then
		{
		format ["%1", _vehMarker] setmarkerColorlocal _mColor;
		}
	else
		{
		format ["%1", _vehMarker] setmarkerColorlocal "ColorBlack";};
	sleep 1;
};
deleteMarkerLocal format ["%1", _marker];

Doodle,

You only need to comment or delete this line: (As it was left in for reference in case someone has other scripts that run with the vehicle)

//_null = [[[_veh,_vName],"scripts\vehMarker.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;

Share this post


Link to post
Share on other sites

Ah I commented out the entire section

Thanks for reply

- will try on our dedi now and report back

Doodle,

You only need to comment or delete this line: (As it was left in for reference in case someone has other scripts that run with the vehicle)

//_null = [[[_veh,_vName],"scripts\vehMarker.sqf"],"BIS_fnc_execVM",false,true] spawn BIS_fnc_MP;

---------- Post added at 11:03 AM ---------- Previous post was at 10:16 AM ----------

Just about tot test this on dedi and wondered if you could help with one more issue - similar to the CAS addaaction above

I am trying to add and have tried the two different ways below but neither work - am I being stupid and missing something obvious?

["<t color=#58FAF4'>Deploy Static.",{execVM "spawn_mgMCV.sqf"} , // brackets around the code to execute

nil, 1, false, true, "",

"alive _this && {speed _this == 0}"];

publicVariable "fnc_vehAction4";

};

fnc_vehAction5 =

{

_this addAction

["<t color=#F7D358'>Deploy Static MG NUL.",{nul = execVM "spawn_mgMCV.sqf"},

Again like the CAS one above, that you managed to assist me with it, works perfectly in the radio trigger but I just cant figure out what the call is when called from addaction

Again thanks in advance

Also re the script not deleting the destroyed vehicle it might be worth looking into that as if the vehicle gets destroyed in its starting position when the new one spawns it spawns on top of the old wreck and usually explodes straight away leading to a spwan explode spawn explode thing going on..

Edited by Doodle
bad edit

Share this post


Link to post
Share on other sites

still ahaving issues with this vehicle remembering the name its assigned in the editor

I have a script running that puts dynamic markers on all vehicles that works flawlessly

I have called the new vehicle MCV and assigned it a marker - when the mission first loads the marker sticks with the vehicle - destroy the vehicle and the marker dissapears (to bottom left corner where all vehicle markers go when a vehicle is destroyed. But when the MCV respawns the marker soesnt return with it. Suggesting that the vehicle is no longer called MCV

Any ideas?

Thx in advance

Share this post


Link to post
Share on other sites

Doodle,

Your action text needs to be enclosed like so when your setting a different color: (your missing the </t> )

"<t color='#58FAF4'>Deploy Static MG</t>", "spawn_mgMCV.sqf",

The {} brackets are only necessary when you have extra stuff to run or variables to pass before executing the sqf, else you can just use the "" quotations.

I think I solved the issue with the naming. Forgot to check and wait for the vehicle to not be null, which was causing some errors on a dedicated server. Will update when it's ready and have tested a bit.

Share this post


Link to post
Share on other sites
@Ranwar - Yes this does look a very simple option - will test this out - any idea if it works on a dedi server?

Thanks in advance

Not sure? :confused:

Here is the list of MP and SP EventHandlers (Look for the ones called Respawn and Killed)

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

Hope it helps,

Ranwer

Share this post


Link to post
Share on other sites
Doodle,

Your action text needs to be enclosed like so when your setting a different color: (your missing the </t> )

"<t color='#58FAF4'>Deploy Static MG</t>", "spawn_mgMCV.sqf",

The {} brackets are only necessary when you have extra stuff to run or variables to pass before executing the sqf, else you can just use the "" quotations.

I think I solved the issue with the naming. Forgot to check and wait for the vehicle to not be null, which was causing some errors on a dedicated server. Will update when it's ready and have tested a bit.

@King Richard

Thanks for reply - will continue the conversation in the new post

Thanks for pointing out the missins <t> tag - to be honest I had noticed this after making that last post and I did change it but still no luck with running from add action,

Its odd the script works perfectly on our dedi and from the editor when run from a simple radio trigger called with nul = execVM "spawn_mg1.sqf";.

Spawn Static Mg and pop smoke

playsound "drill";

// nul = execVM "spawn_mg1.sqf";

_sta = "<br/><img size='4' img image='icons\mg.paa' align='left'/><br/>";
_sta  = _sta ;
_titleanim1  = "<t color='#F7FE2E' size='1.4' shadow='1' shadowColor='#000066' align='left'><br/>Deploy Static.</t><br/><br/>";
_textanim1   = "<t color='#F7FE2E' size='1.2' shadow='1' shadowColor='#006600' align='left'>A member of your squad is deploying a 50, Cal Static Machine gun at the Mobile Command Vehicle[MCV].<br/><br/>";
hint parseText (_sta + _titleanim1 + _textanim1);

sleep 3.0;
if (!isServer) exitWith {}; 


_ani1 = "SmokeShellGreen" createVehicle (position MCV);
_ani1 setDir 0;


_ani2 = createVehicle ["B_HMG_01_high_F", getPos MCV, [],1,"NONE"];
_ani2 setDir 180;



_ani3 = "SmokeShellRed" createvehicle ((MCV) ModelToWorld [0,0,0]); 
_ani3 setDir 180;


if (true) exitWith {};

But I just cant seem to get it to work from addaction on dedi - yet the albeit slightly different CAS script works perfectly

Thank in advance

Continued in new thread

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  

×