Jump to content
Sign in to follow this  
A-SUICIDAL

"Request Vehicle Drop" script problem/need help

Recommended Posts

In my 14 man coop mission I have given each player the ability(action) to "Request vehicle drop" (HMMWV GPK M2). After requesting a vehicle drop, the player is given a hint message letting them know that another vehicle drop will not be available again until 10 minutes has passed. When playing the mission, players rarely ever use the action unless they are stranded far away, which is why I wanted the script in my mission. Everything works fine with the script as far as the vehicle being dropped when the action is performed, but there are a few additional features that were added to the vehicle that did not work correctly for clients.

In the script - I added gear (rifles/mags etc) into the cargo of the vehicle, additional turret ammunition for the M2 gun, an action to repair the vehicle if it is damaged and I also added additional armor to the vehicle by using an EH handleDamage. When I hosted the mission and tested the script with a friend, we both requested a vehicle drop and my friend was not able to see any of the gear that was added to the vehicle cargo and he was not able to see any action to repair the vehicle after he shot one of the tires. I forgot to ask him to check to see if the M2 had additional ammo. As for the additional armor that was added to the vehicle - that was not thoroughly tested yet either. I am mostly concerned that my friend could not see the additional gear (rifles-mags etc) that was added to the cargo of the vehicle and he could not see an action to repair the vehicle when it was damaged. As the Host, I was able to see the additional gear and the "repair" action. So apparently something in the script needs to be changed so it works correctly for all players/clients.

I tried adding:

if (isServer) then {     // at the beginning of the script
};     // at the end of the script

...but the problem still occurred.

I then tried adding a script that would first set a publicVariable to "true" when the "Request vehicle drop" action is performed and then I added a trigger to the mission that would execute the script provided the condition met was "true", but that did not work either. The vehicle drops, but the extra vehicle features are not being sent to the clients on the server. Any help with getting this to work correctly would be most appreciated.

The action added to player s1:

[s1] execVM "request\s1_add_req_veh_drop.sqf";

s1_add_req_veh_drop.sqf

_req_s1 = s1 addAction ['<t color="#336699">' + "Request Vehicle Drop" + '</t>', "request\s1_veh_drop_requested.sqf", [], -4, false, true, "", "_target == _this"];

The script that starts the 10 minute timer and sets the variable true:

s1_veh_drop_requested.sqf

if (s1vehDropActive) exitWith{hint composeText [parsetext format["<t size='1.2' align='center' color='#FFFF00'>Vehicle drop unavailable.</t><br/><t size='1' align='center' color='#FFFFFF'>10 minutes has not yet passed.</t>"]];};

s1vehDropActive = true;

waitUntil{!(isNil "BIS_MPF_InitDone")};
[s1,nil,rGLOBALCHAT,"REQUESTING VEHICLE DROP"] call RE;

sleep 3;

s1_veh_drop = true;   //   activates trigger, which then activates the next script.
publicVariable "s1_veh_drop";

sleep 597;   //  10 minute wait before next available request.

s1_veh_drop = false;
publicVariable "s1_veh_drop";

s1vehDropActive = false;

hint composeText [parsetext format["<t size='1.2' align='center' color='#FFFF00'>C-130 is ready.</t><br/><t size='1' align='center' color='#FFFFFF'>Vehicle drop available.</t>"]];
sleep 10;
hint "";

The script that is activated by a trigger and drops the vehicle and adds the additional features(problem):

trigger condition: s1_veh_drop

trigger activation: null = [] execVM "request\s1_veh_drop.sqf";

s1_veh_drop.sqf

if (isServer) then {

[west,"HQ"] sideChat format["ROGER THAT %1. VEHICLE DROP IN PROGRESS AT YOUR POSITION.",name s1];

s1_veh_drop = false;
publicVariable "s1_veh_drop";

sleep 5;

[this,nil,rPLAYSOUND,"c130"] call RE;

sleep 5;

deleteVehicle s1_hmmwv;  //  deletes previously dropped vehicle if it exists

s1_chute = "ParachuteMediumWest" createVehicle (getMarkerPos "veh_spawn");
s1_chute setPos [(getpos s1 select 0), (getPos s1 select 1)-2, (getPos s1 select 2)+170];

s1_hmmwv = "HMMWV_M1151_M2_DES_EP1" createVehicle (getMarkerPos "veh_spawn");
s1_hmmwv setpos [(getpos s1_chute select 0), (getpos s1_chute select 1)-2, (getpos s1_chute select 2)-170];
s1_hmmwv attachto [s1_chute, [0, 0, 0]];

sleep 1;

s1_hmmwv setVariable ["selections", []];
s1_hmmwv setVariable ["gethit", []];

s1_hmmwv addEventHandler 
[
"HandleDamage",
{
	_selections = s1_hmmwv getVariable ["selections", []];
	_gethit = s1_hmmwv getVariable ["gethit", []];
	_selection = _this select 1;
	if !(_selection in _selections) then {_selections set [count _selections, _selection];
		_gethit set [count _gethit, 0];
	};
	_i = _selections find _selection;
	_olddamage = _gethit select _i;
	_damage = _olddamage + ((_this select 2) - _olddamage) * 0.5;
	_gethit set [_i, _damage];
	_damage;}
];

s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];
s1_hmmwv addMagazineTurret ["100Rnd_127x99_M2",[1]];

clearWeaponCargo s1_hmmwv;
clearMagazineCargo s1_hmmwv;

s1_hmmwv addMagazineCargo ["30Rnd_556x45_Stanag", 12];
s1_hmmwv addMagazineCargo ["PIPEBOMB",2];
s1_hmmwv addMagazineCargo ["20Rnd_762x51_B_SCAR",12];
s1_hmmwv addMagazineCargo ["MAAWS_HEAT", 10];
s1_hmmwv addMagazineCargo ["stinger", 2];
s1_hmmwv addWeaponCargo ["M110_NVG_EP1",2];
s1_hmmwv addWeaponCargo ["M4A3_RCO_GL_EP1", 2];
s1_hmmwv addWeaponCargo ["MAAWS", 2];
s1_hmmwv addWeaponCargo ["Stinger", 2];

s1_hmmwv addAction [("<t color=""#FF0000"">" + ("Repair HMMWV GPK M2") + "</t>"),"vehicle\veh_repair.sqf",nil,+50,true,true,"","alive _target && (!canMove _target or (damage _target>0 and damage _target<1)) and player distance _target<6"];

sleep 10;

s1_smoke="SmokeShellGreen" createVehicle getPos s1_hmmwv;
s1_smoke attachto [s1_hmmwv, [0, 0, -0.4]];

waitUntil {((getPos s1_hmmwv) select 2) < 1};

detach s1_hmmwv;
detach s1_smoke;

s1_hmmwv setpos [(getpos s1_hmmwv) select 0, (getpos s1_hmmwv) select 1, 0];

s1_chute setPos [(getpos s1_hmmwv select 0)+2, (getPos s1_hmmwv select 1), (getPos s1_hmmwv select 2)];

hint composeText [parsetext format["<t size='1.2' align='center' color='#FFA500'>C-130 is RTB</t><br/><t size='1' align='center' color='#FFFFFF'>Approximately 10 minute wait before next available vehicle drop.</t>"]];

sleep 5;
s1_chute setDamage 1;
deleteVehicle s1_chute;

sleep 5;
hint composeText [parsetext format["<t size='1.2' align='center' color='#FFA500'>HMMWV GPK M2 Info</t><br/><br/><t size='1' align='center' color='#FFFFFF'>This vehicle has been equipped with additional armor and gear.<br/><br/>Respawn time - never.<br/>Deletes upon next request.</t>"]];
sleep 10;
hint "";

};

Sample Mission: request_vehicle_drop_test.Desert_E.zip

Again, I've tried writing the script and executing it different ways. I've tried it with and without using a trigger to execute the script. Currently the sample mission uses a trigger system.

It's a useful little script, but I need help getting the additional vehicle features to work for all clients.

Share this post


Link to post
Share on other sites

you tried addMagazineCargoGlobal ?

and... s1_hmmwv addAction [("<t color="#FF0000"">" + ("Repair HMMWV GPK M2") + "</t>"),"vehicle\veh_repair.sqf",nil,+50,true,true,"","alive _target && (!canMove _target or (damage _target>0 and damage _target<1)) and player distance _target<6];

put it in MPF method or possibly use setVehicleInit - allows others to see the add action - at present its only on the server

Edited by Mikie boy

Share this post


Link to post
Share on other sites

I never heard of an AddMagazineCargoGlobal before. I guess I could try that.

In the past, I did try using setVehicleInit in the script as shown in the spoiler below,

but the same thing would happen where only the host could see the added gear and repair action.

Both of your suggestions are good. I do appreciate the help.

I don't know if AddMagazineCargoGlobal will work or not since I still have problems with the other things not working for clients, but I will try it.

s1_hmmwv setVehicleInit "s1_hmmwv=this;
this setVariable ['selections', []];
this setVariable ['gethit', []];
this addEventHandler ['HandleDamage',{_veh = _this select 0;
_selections = _veh getVariable ['selections', []];
_gethit = _veh getVariable ['gethit', []];
_selection = _this select 1;
if !(_selection in _selections) then {_selections set [count _selections, _selection];_gethit set [count _gethit, 0];};
_i = _selections find _selection;
_olddamage = _gethit select _i;
_damage = _olddamage + ((_this select 2) - _olddamage) * 0.4;
_gethit set [_i, _damage];
_damage;}];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
this addMagazineTurret ['100Rnd_127x99_M2',[1]];
clearWeaponCargo this;
clearMagazineCargo this;
this addMagazineCargo ['PIPEBOMB',2];
this addMagazineCargo ['20Rnd_762x51_B_SCAR',20];
this addMagazineCargo ['MAAWS_HEAT', 10];
this addMagazineCargo ['stinger', 4];
this addWeaponCargo ['M110_NVG_EP1',2];
this addWeaponCargo ['MAAWS', 2];
this addWeaponCargo ['Stinger', 2];
this addAction [('<t color=''#FF0000''>' + ('Repair HMMWV GPK M2') + '</t>'),'vehicle\veh_repair.sqf',nil,+50,true,true,'','alive s1_hmmwv && (!canMove s1_hmmwv or (damage s1_hmmwv>0 and damage s1_hmmwv<1)) and player distance s1_hmmwv<6'];";
processInitCommands;

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

I decided to go with the setVehicleInit method to add the additional armor, gear, turret ammo and the repair action, but this time I am going to use a trigger.

Condition: alive s1_hmmwv

On Act: (everything in the spoiler above with the addition of the addMagazineCargoGlobal command to replace addMagazineCargo)

So far it tested fine in single player, but I can't test it in multiplayer until I can find somebody to test it with :P

This is my last hopeful idea to get this working.

It makes no sense why I can spawn an ammo crate and add gear to it and a "save loadout" action and it works for all clients, but if I spawn a jeep and add things to it, it doesn't work for all clients. Maybe it's the order of things. Like maybe the jeep doesn't like having gear and other things added to it while it is floating down to earth in a parachute, or maybe it won't work if the vehicle was first attached to an object. Maybe I am losing my mind.

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  

×