Jump to content
  • 0

Help with Script (Load Player as Patient in Vehicle)


Guest

Question

// EDIT: I managed to solve all Problems...

In Variables.sqf add:
 

Veh_Med = ["Mi17_medevac_Ins","HMMWV_Ambulance","HMMWV_Ambulance_CZ_DES_EP1","HMMWV_Ambulance_DES_EP1","S1203_ambulance_EP1","GAZ_Vodnik_MedEvac"];

This allows you to have a custom List...

In fn_selfActions.sqf, add:

 

if(_typeOfCursorTarget in Veh_Med && _isVehicle && !_isMan &&_isAlive && !_isMan && !locked _cursorTarget && !(_cursorTarget isKindOf "Bicycle") && (player distance _cursorTarget < 5)) then {
		if (s_player_assign_patient < 0) then {		 
			s_player_assign_patient = player addAction ["<t color='#0059FF'>Get in as Patient</t>", "EPOCHMODS\Medical\patient_loadin.sqf", cursorTarget, 1, false, true, "",""];
		};
	} else {
			player removeAction s_player_assign_patient;
			s_player_assign_patient = -1;
	};

 You might want to edit the Path tho...


Actual patient_loadin.sqf:

// Author: Martin - Thanks to SchwEde (http://epochmod.com/forum/index.php?/user/15060-schwede/)
private ["_i","_tempArr","_veh","_changed","_getArrayPos","_getArrayPosCount","_getArrayPosCountSet","_getVeh","_hasCargoFood","_hasCargoWater","_DaFood","_DaWater","_lastindex","_timeout","_unit","_vehicle","_posCommander","_posCargo","_itemsCargo","_itemsCargoObjects","_itemsCargoCount","_itemsCargoCountSet","_itemsMedical","_itemsDrink","_itemsFood","_removedSuccess"];
disableserialization;

//////////////////////
//Remove Items?///////
_removeItems = true;//
//////////////////////
//Show Message?///////
_showMessage = true;//
//////////////////////
//////////////////////

_unit = player;

_cursorTarget = cursorTarget;

_itemsMedical = ["ItemBandage","ItemEpiniphrine","ItemMorphine","ItemHeatPack","ItemBloodbag","ItemAntibiotic","ItemPainkiller"];
_itemsFood = ["FoodSteakRaw","FoodSteakCooked","FoodCanBakedBeans","FoodCanSardines","FoodCanFrankBeans","FoodCanPasta","FoodmeatRaw","FoodmuttonRaw","FoodchickenRaw","FoodrabbitRaw","FoodbaconRaw","FoodbeefRaw","FoodmeatCooked","FoodmuttonCooked","FoodchickenCooked","FoodbaconCooked","FoodrabbitCooked","FoodbeefCooked","FoodMRE","FoodPistachio","FoodNutmix"];
_itemsDrink = ["ItemWaterbottle","ItemSodaCoke","ItemSodaPepsi","ItemSodaMdew","ItemSodaMtngreen","ItemSodaR4Z0R","ItemSodaClays","ItemSodaSmasht","ItemSodaDrWaste","ItemSodaLemonade","ItemSodaLvg","ItemSodaMzly","ItemSodaRabbit","ItemSodaRbull","ItemSodaOrangeSherbet","ItemWaterbottleBoiled"];

_posCommander = _cursorTarget emptyPositions "Commander";
_posCargo = _cursorTarget emptyPositions "Cargo";

if (_posCommander != 0 || _posCargo != 0) then {
	if (_posCommander != 0) then {
		_unit assignAsCommander _cursorTarget;
		[_unit] orderGetIn true;
		_unit moveInCommander _cursorTarget;
	} else {
		_unit assignAsCargo _cursorTarget;
		[_unit] orderGetIn true;
		_unit moveInCargo [_cursorTarget,1]; //0 Is the Passenger and 1 is the "invisible" (i think?)
	};
		
	_timeout = 10;
	while {_timeout > 0} do {
		cutText["~~ You are being Healed... ~~\n~~ Please wait ~~","PLAIN",0.5];
		sleep 1;
		_timeout = _timeout - 1;
		
		if (vehicle player != player) then {
			vehicle player lockDriver true;
			vehicle player lockCargo true;
			vehicle player setVehicleLock "LOCKED";
		} else {
			_cursorTarget lockDriver true;
			_cursorTarget lockCargo true;
			_cursorTarget setVehicleLock "LOCKED";
		};
	};
	
	if (vehicle player != player) then {
		_itemsCargo = getMagazineCargo (vehicle player);
	} else {
		_itemsCargo = getMagazineCargo cursorTarget;
	};
	
	_itemsCargoObjects = _itemsCargo select 0;
	_itemsCargoCount = _itemsCargo select 1;
	
	_changed = false;
		
	/**
	Everything related to BloodBag
	(Low Blood, Blurry Screen)
	**/
	if ("ItemBloodbag" in _itemsCargoObjects) then {
		'dynamicBlur' ppEffectAdjust [0]; 
		'dynamicBlur' ppEffectCommit 5; 
		r_player_blood = r_player_bloodTotal;
		r_player_lowblood = false; 
		player setVariable['USEC_lowBlood',false,true]; 
		player setVariable['USEC_BloodQty',12000,true]; 
		player setdamage 0;
		
		if (_removeItems) then {
			
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemBloodbag"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A BloodBag has been removed from the Vehicle Inventory");
			};
		};
	};
	
	/**
	Everything related to Painkillers
	(Camera Shake)
	**/
	if ("ItemPainkiller" in _itemsCargoObjects) then { 
		r_player_inpain = false; 
		resetCamShake; 
		player setVariable['USEC_inPain',false,true]; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemPainkiller"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A Pack of Painkillers has been removed from the Vehicle Inventory");
			};
		};
	};
	
	/**
	Everything related to Antibiotics
	(Coughing, Loosing Blood?)
	**/
	if ("ItemAntibiotic" in _itemsCargoObjects) then { 
		r_player_infected = false; 
		player setVariable['USEC_infected',false,true]; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemAntibiotic"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A Pack of Antibiotics has been removed from the Vehicle Inventory");
			};
		};
	};

	/**
	Everything related to Bandages
	(Loosing Blood)
	**/
	if ("ItemBandage" in _itemsCargoObjects) then { 
		dayz_sourceBleeding = objNull; 
		player setVariable['USEC_injured',false,true]; 
		r_player_injured = false; 
		_display = uiNameSpace getVariable 'DAYZ_GUI_display'; 
		_control = _display displayCtrl 1303; 
		_control ctrlShow false;
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemBandage"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A Bandage has been removed from the Vehicle Inventory");
			};
		};
	};
	
	/**
	Everything related to Heatpacks
	(Being Cold, Coughing?)
	**/
	if ("ItemHeatPack" in _itemsCargoObjects) then { 
		dayz_temperatur = 37; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemHeatPack"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A Heat Pack has been removed from the Vehicle Inventory");
			};
		};
	};
	
	/**
	Everything related to Morphine
	(Fractures)
	**/
	if ("ItemMorphine" in _itemsCargoObjects) then { 
		_selection = 'legs'; 
		_damage = 0; 
		player setHit[_selection,_damage]; 
		r_fracture_legs = false; 
		r_fracture_arms = false; 
		player setVariable['hit_legs',0,true]; 
		player setVariable['hit_hands',0,true]; 
		_display = uiNameSpace getVariable 'DAYZ_GUI_display'; 
		_control = _display displayCtrl 1203; 
		_control ctrlShow false; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemMorphine"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A Morphine Injection has been removed from the Vehicle Inventory");
			};
		};
	};

	/**
	Everything related to Epi Pens
	(Unconscious? - You can't really use scroll wheel, if unconscious, so this is probably impossible)
	**/
	if ("ItemEpiniphrine" in _itemsCargoObjects) then { 
		r_player_unconscious = false; 
		player setVariable['NORRN_unconscious',false,true]; 
		player setVariable['unconsciousTime',0,true]; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemEpiniphrine"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat ("A Epinephrine Injection has been removed from the Vehicle Inventory");
			};
		};
	};
	
	/**
	Everything related to Food
	(Hungry)
	**/
	_hasCargoFood = false;
	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoFood = true;
			_DaFood = _x;
		};
	} count _itemsFood;
	
	if (_hasCargoFood) then {
		dayz_hunger = 0;
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find _DaFood; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat (format["%1 has been removed from the Vehicle Inventory", _DaFood]);
			};
		};
	};
	
	/**
	Everything related to Water
	(Thirsty)
	**/
	_hasCargoWater = false;
	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoWater = true;
			_DaWater = _x;
		};
	} count _itemsDrink;
	
	if (_hasCargoWater) then {
		dayz_thirst = 0;
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
			_getArrayPosCountSet = 0;
		
			_getArrayPos = _itemsCargoObjects find _DaWater; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			_itemsCargoCountSet = _getArrayPosCount - 1;
			_itemsCargoCount set [_getArrayPos, _itemsCargoCountSet];
			
			_changed = true;
			
			if (_showMessage) then {
				systemChat (format["%1 has been removed from the Vehicle Inventory", _DaWater]);
			};
		};
	};
	
	if (_changed) then {
		
		//This is just a double check...
		if (vehicle player != player) then {
			_veh = vehicle player;
			clearMagazineCargo _veh;
			
			//Format the array and put the items back in
			_i = 0;
			
			{	
				//If the Count is 0, we jump that entry
				if ((_itemsCargoCount select _i) == 0) then {_i = _i + 1;};
				
				//Make sure to clear the _tempArr
				_tempArr = [];
				
				//					Name of Item					Count of Item
				_tempArr = [(_itemsCargoObjects select _i),(_itemsCargoCount select _i)];
				
				//Actually put it in
				_veh addMagazineCargoGlobal _tempArr;
				
				//Add to _i, so we can do this for all items...
				_i = _i + 1;
				
			} foreach _itemsCargoObjects;
			
			//Make sure to unlock vehicle again after finish
			vehicle player lockDriver false;
			vehicle player lockCargo false;
			vehicle player setVehicleLock "UNLOCKED";
			
			//Send it to the Hive
			PVDZE_veh_Update = [_veh,"gear"];
			publicVariableServer "PVDZE_veh_Update";
			
		} else {
			clearMagazineCargo cursorTarget;
			
			_i = 0;
			
			{	
				//If the Count is 0, we jump that entry
				if ((_itemsCargoCount select _i) == 0) then {_i = _i + 1;};
				
				//Make sure to clear the _tempArr
				_tempArr = [];
				
				//					Name of Item					Count of Item
				_tempArr = [(_itemsCargoObjects select _i),(_itemsCargoCount select _i)];
				
				//Actually put it in
				cursorTarget addMagazineCargoGlobal _tempArr;
				
				//Add to _i, so we can do this for all items...
				_i = _i + 1;
				
			} foreach _itemsCargoObjects;
			
			//Make sure to unlock vehicle again after finish
			_cursorTarget lockDriver false;
			_cursorTarget lockCargo false;
			_cursorTarget setVehicleLock "UNLOCKED";
			
			//Send it to the Hive
			PVDZE_veh_Update = [_cursorTarget,"gear"];
			publicVariableServer "PVDZE_veh_Update";
		};
		
	} else {
		//Nothing changed, unlock the Vehicle
		vehicle player lockDriver false;
		vehicle player lockCargo false;
		vehicle player setVehicleLock "UNLOCKED";
	};
	
	sleep 5;
	
} else {
	cutText["~~ No room in target Vehicle! ~~","PLAIN",0.5];
};

Link to comment
Share on other sites

20 answers to this question

Recommended Posts

  • 0

try using:

removeMagazineCargo

 

 

The Problem is, i don't know the variable i need and i can't find it anywhere :s

Thats because this is hardcoded in arma, and there is no simple way to remove this option.

If you find an easy way tell me, im also interessted in this ^^

Link to comment
Share on other sites

  • 0

try using:

removeMagazineCargo

Thats because this is hardcoded in arma, and there is no simple way to remove this option.

If you find an easy way tell me, im also interessted in this ^^

 

Well i found a solution for the removing actions and for the removing items, but now i'm stuck on the food or water items:

Removing items, like so:

 

	if ("ItemBloodbag" in _itemsCargoObjects) then { 'dynamicBlur' ppEffectAdjust [0]; 'dynamicBlur' ppEffectCommit 5; r_player_blood = r_player_bloodTotal; r_player_lowblood = false; player setVariable['USEC_lowBlood',false,true]; player setVariable['USEC_BloodQty',12000,true]; player setdamage 0; _removedSuccess = ([_cursorTarget,"ItemBloodbag",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A BloodBag has been removed from the Vehicle Cargo");}; };
	if ("ItemPainkiller" in _itemsCargoObjects) then { r_player_inpain = false; resetCamShake; player setVariable['USEC_inPain',false,true]; _removedSuccess = ([_cursorTarget,"ItemPainkiller",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A Package of Painkillers has been removed from the Vehicle Cargo");}; };
	if ("ItemAntibiotic" in _itemsCargoObjects) then { r_player_infected = false; player setVariable['USEC_infected',false,true]; _removedSuccess = ([_cursorTarget,"ItemAntibiotic",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A Package of Antibiotics has been removed from the Vehicle Cargo");}; };
	if ("ItemBandage" in _itemsCargoObjects) then { dayz_sourceBleeding = objNull; player setVariable['USEC_injured',false,true]; r_player_injured = false; _display = uiNameSpace getVariable 'DAYZ_GUI_display'; _control = _display displayCtrl 1303; _control ctrlShow false; _removedSuccess = ([_cursorTarget,"ItemBandage",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A Bandage has been removed from the Vehicle Cargo");}; };
	if (_itemsFood in _itemsCargoObjects) then { dayz_hunger = 0; _cursorTarget removeMagazine [_itemsFood select _x]; };
	if (_itemsDrink in _itemsCargoObjects) then { dayz_hunger = 0; _cursorTarget removeMagazine [_itemsDrink select _x]; };
	if ("ItemHeatPack" in _itemsCargoObjects) then { dayz_temperatur = 37; _removedSuccess = ([_cursorTarget,"ItemHeatPack",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A Heatpack has been removed from the Vehicle Cargo");}; };
	if ("ItemMorphine" in _itemsCargoObjects) then { _selection = 'legs'; _damage = 0; player setHit[_selection,_damage]; r_fracture_legs = false; r_fracture_arms = false; player setVariable['hit_legs',0,true]; player setVariable['hit_hands',0,true]; _display = uiNameSpace getVariable 'DAYZ_GUI_display'; _control = _display displayCtrl 1203; _control ctrlShow false; _removedSuccess = ([_cursorTarget,"ItemMorphine",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A Morphine Injection has been removed from the Vehicle Cargo");}; };
	if ("ItemEpiniphrine" in _itemsCargoObjects) then { r_player_unconscious = false; player setVariable['NORRN_unconscious',false,true]; player setVariable['unconsciousTime',0,true]; _removedSuccess = ([_cursorTarget,"ItemEpiniphrine",1] call BIS_fnc_invRemove); if(_removedSuccess == 1) then {systemChat ("A Epinephrine Injection has been removed from the Vehicle Cargo");}; }; //Pretty Impossible.. Anyway

And removing actions like so:

 

	_timeout = 10;
	while {_timeout > 0} do {
		cutText["~~ You are being Healed... ~~\n~~ Please wait ~~","PLAIN",0.5];
		sleep 1;
		_timeout = _timeout - 1;
		
		//Remove all actions during heal Process
		if (isNil "_maxNo") then {_maxNo = 1000;};
		private ["_i"];
		for [{_i=0};{_i<=_maxNo};{_i = _i + 1}] do
		{
			_unit removeAction _i;
		};		
	};

Both untested, because i haven't got a Test Server.

 

Link to comment
Share on other sites

  • 0

 

wow you pretty like one line code dont you? ^^

 

well try this:

([_cursorTarget,(_itemsFood select _x),1] call BIS_fnc_invRemove)

Linebreak is allways counted as 2 Characters. Less LineBreaks = Less Characters = less file size = less loading time.. It's not a much, maybe just a millisecond, but if you do that to every file, it does affect the time :)

Link to comment
Share on other sites

  • 0

tested your remove action script, its not working:

 

this is tested and working:

private ["_timeout","_maxNo"];
_timeout = 40;
	while {_timeout > 0} do {
		cutText["~~ You are being Healed... ~~\n~~ Please wait ~~","PLAIN",0.5];
		sleep 1;
		_timeout = _timeout - 1;
		
		_lastindex = player addaction ["", ""]; for [{_i = 0}, {_i <= _lastindex}, {_i = _i + 1}] do {player removeaction _i;};
	};
Link to comment
Share on other sites

  • 0

nope give me a second =)

 

ok here is the thing:

 

_itemsCargoObjects is an array

 

and _itemsFood in _itemsCargoObjects  will allways return false.

[_cursorTarget,(_itemsFood select _x),1] call BIS_fnc_invRemove;

is not working, but i tested all this in the editor, because of faster testing.

Will probably need test it on the server because neither works this:

[player,"30Rnd_556x45_STANAG",4] call BIS_fnc_invRemove;

which defently should work ^^

 

So for the check i think this should work:

	_hasCargoFood = false;

	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoFood = true;
		};
	} forEach _itemsFood;

if (_hasCargoFood) then {/*Feed Player and Remove Items here*/};

This way you defently have the right check for food in the inventory of the vehicle.

 

The Next step is to get it removing.

 

Need to do some stuff in real life, will help you later if you still not solved it :)

Link to comment
Share on other sites

  • 0
private ["_DaFood","_unit","_vehicle","_posCommander","_posCargo","_itemsCargo","_itemsCargoObjects","_itemsCargoCount","_itemsMedical","_itemsDrink","_itemsFood"];
_cursorTarget = cursorTarget;
_itemsCargo = getMagazineCargo _cursorTarget; //Is Array [["Object","Object","Object"],1,2,3]
_itemsCargoObjects = _itemsCargo select 0;
_itemsCargoCount = _itemsCargo select 1;
_itemsFood = ["FoodSteakRaw","FoodSteakCooked","FoodCanBakedBeans","FoodCanSardines","FoodCanFrankBeans","FoodCanPasta","FoodmeatRaw","FoodmuttonRaw","FoodchickenRaw","FoodrabbitRaw","FoodbaconRaw","FoodbeefRaw","FoodmeatCooked","FoodmuttonCooked","FoodchickenCooked","FoodbaconCooked","FoodrabbitCooked","FoodbeefCooked","FoodMRE","FoodPistachio","FoodNutmix"];

_hasCargoFood = false;

	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoFood = true;
			_DaFood = _x;
		};
	} count _itemsFood;
if (_hasCargoFood) then {
[_cursorTarget,_DaFood,1] call BIS_fnc_invRemove;
};

This should do the trick, just make sure you have every variable in the private [....];

Maybe predefine some variables, so they wont be any undefined :)

 

Tested and worked :)

Link to comment
Share on other sites

  • 0

 

This should do the trick, just make sure you have every variable in the private [....];

Maybe predefine some variables, so they wont be any undefined :)

 

Tested and worked :)

 

 

 

I kinda broke it (somehow?) Was just adding a bit community support, then tested it and again no items are being removed..

The healing 'n stuff works fine, but the Item's aren't removed. I don't understand, why this works in other scripts like player_build.sqf, but not here..

This is the "new" modified version:

 

// Author: Martin - Thanks to SchwEde (http://epochmod.com/forum/index.php?/user/15060-schwede/)
private ["_hasCargoFood","_hasCargoWater","_DaFood","_DaWater","_lastindex","_timeout","_unit","_vehicle","_posCommander","_posCargo","_itemsCargo","_itemsCargoObjects","_itemsCargoCount","_itemsMedical","_itemsDrink","_itemsFood","_removedSuccess","_maxNo"];
disableserialization;

//////////////////////
//Remove Items?///////
_removeItems = true;//
//////////////////////
//Show Message?///////
_showMessage = true;//
//////////////////////
//////////////////////

_unit = player;

_cursorTarget = cursorTarget;
_vehicle = typeOf _cursorTarget;
_itemsCargo = getMagazineCargo _cursorTarget; //Is Array [["Object","Object","Object"],1,2,3]
_itemsCargoObjects = _itemsCargo select 0;
_itemsCargoCount = _itemsCargo select 1;

_itemsMedical = ["ItemBandage","ItemEpiniphrine","ItemMorphine","ItemHeatPack","ItemBloodbag","ItemAntibiotic","ItemPainkiller"];
_itemsFood = ["FoodSteakRaw","FoodSteakCooked","FoodCanBakedBeans","FoodCanSardines","FoodCanFrankBeans","FoodCanPasta","FoodmeatRaw","FoodmuttonRaw","FoodchickenRaw","FoodrabbitRaw","FoodbaconRaw","FoodbeefRaw","FoodmeatCooked","FoodmuttonCooked","FoodchickenCooked","FoodbaconCooked","FoodrabbitCooked","FoodbeefCooked","FoodMRE","FoodPistachio","FoodNutmix"];
_itemsDrink = ["ItemWaterbottle","ItemSodaCoke","ItemSodaPepsi","ItemSodaMdew","ItemSodaMtngreen","ItemSodaR4Z0R","ItemSodaClays","ItemSodaSmasht","ItemSodaDrWaste","ItemSodaLemonade","ItemSodaLvg","ItemSodaMzly","ItemSodaRabbit","ItemSodaRbull","ItemSodaOrangeSherbet","ItemWaterbottleBoiled"];

_posCommander = _cursorTarget emptyPositions "Commander";
_posCargo = _cursorTarget emptyPositions "Cargo";

if (_posCommander != 0 || _posCargo != 0) then {
	if (_posCommander != 0) then {
		_unit assignAsCommander _cursorTarget;
		[_unit] orderGetIn true;
		_unit moveInCommander _cursorTarget;
	} else {
		_unit assignAsCargo _cursorTarget;
		[_unit] orderGetIn true;
		_unit moveInCargo [_cursorTarget,1]; //0 Is the Passenger and 1 is the "invisible" (i think?)
	};
		
	_timeout = 10;
	while {_timeout > 0} do {
		cutText["~~ You are being Healed... ~~\n~~ Please wait ~~","PLAIN",0.5];
		sleep 1;
		_timeout = _timeout - 1;
		
		_lastindex = player addaction ["", ""]; for [{_i = 0}, {_i <= _lastindex}, {_i = _i + 1}] do {player removeaction _i;};
	};
				
	/**
	Everything related to BloodBag
	(Low Blood, Blurry Screen)
	**/
	if ("ItemBloodbag" in _itemsCargoObjects) then { 
		'dynamicBlur' ppEffectAdjust [0]; 
		'dynamicBlur' ppEffectCommit 5; 
		r_player_blood = r_player_bloodTotal;
		r_player_lowblood = false; 
		player setVariable['USEC_lowBlood',false,true]; 
		player setVariable['USEC_BloodQty',12000,true]; 
		player setdamage 0;
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemBloodbag",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A BloodBag has been removed from the Vehicle Cargo");
			}; 
		};
	};
	
	/**
	Everything related to Painkillers
	(Camera Shake)
	**/
	if ("ItemPainkiller" in _itemsCargoObjects) then { 
		r_player_inpain = false; resetCamShake; 
		player setVariable['USEC_inPain',false,true]; 
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemPainkiller",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A Package of Painkillers has been removed from the Vehicle Cargo");
			}; 
		};
	};
	
	/**
	Everything related to Antibiotics
	(Coughing, Loosing Blood?)
	**/
	if ("ItemAntibiotic" in _itemsCargoObjects) then { 
		r_player_infected = false; 
		player setVariable['USEC_infected',false,true]; 
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemAntibiotic",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A Package of Antibiotics has been removed from the Vehicle Cargo");
			}; 
		};
	};

	/**
	Everything related to Bandages
	(Loosing Blood)
	**/
	if ("ItemBandage" in _itemsCargoObjects) then { 
		dayz_sourceBleeding = objNull; 
		player setVariable['USEC_injured',false,true]; 
		r_player_injured = false; 
		_display = uiNameSpace getVariable 'DAYZ_GUI_display'; 
		_control = _display displayCtrl 1303; 
		_control ctrlShow false;
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemBandage",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A Bandage has been removed from the Vehicle Cargo");
			}; 
		};
	};
	
	/**
	Everything related to Heatpacks
	(Being Cold, Coughing?)
	**/
	if ("ItemHeatPack" in _itemsCargoObjects) then { 
		dayz_temperatur = 37; 
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemHeatPack",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A Heatpack has been removed from the Vehicle Cargo");
			}; 
		};
	};
	
	/**
	Everything related to Morphine
	(Fractures)
	**/
	if ("ItemMorphine" in _itemsCargoObjects) then { 
		_selection = 'legs'; 
		_damage = 0; 
		player setHit[_selection,_damage]; 
		r_fracture_legs = false; 
		r_fracture_arms = false; 
		player setVariable['hit_legs',0,true]; 
		player setVariable['hit_hands',0,true]; 
		_display = uiNameSpace getVariable 'DAYZ_GUI_display'; 
		_control = _display displayCtrl 1203; 
		_control ctrlShow false; 
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemMorphine",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A Morphine Injection has been removed from the Vehicle Cargo");
			};
		};
	};

	/**
	Everything related to Epi Pens
	(Unconscious? - You can't really use scroll wheel, if unconscious, so this is probably impossible)
	**/
	if ("ItemEpiniphrine" in _itemsCargoObjects) then { 
		r_player_unconscious = false; 
		player setVariable['NORRN_unconscious',false,true]; 
		player setVariable['unconsciousTime',0,true]; 
		
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,"ItemEpiniphrine",1] call BIS_fnc_invRemove); 
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("A Epinephrine Injection has been removed from the Vehicle Cargo");
			}; 
		};
	};
	
	/**
	Everything related to Food
	(Hungry)
	**/
	_hasCargoFood = false;
	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoFood = true;
			_DaFood = _x;
		};
	} count _itemsFood;
	
	if (_hasCargoFood) then {
		dayz_hunger = 0;
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,_DaFood,1] call BIS_fnc_invRemove);
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("Test1");
			}; 
		};
	};
	
	/**
	Everything related to Water
	(Thirsty)
	**/
	_hasCargoWater = false;
	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoWater = true;
			_DaWater = _x;
		};
	} count _itemsDrink;
	
	if (_hasCargoWater) then {
		dayz_thirst = 0;
		if (_removeItems) then {
			_removedSuccess = ([_cursorTarget,_DaWater,1] call BIS_fnc_invRemove);
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("Test2");
			}; 
		};
	};
	
	//r_player_loaded = false;
	//r_player_cardiac = false;
	//r_player_timeout = 0;
	//r_handlercount = 0;
	//r_interrupt = false;
	//r_doLoop = false;
	//r_drag_sqf = false;
	//r_self = false;
	//r_action = false;
	//r_action_unload = false;
	//r_player_handler = false;
	//r_player_handler1 = false;
	//disableUserInput false
	player setVariable['messing',[dayz_hunger,dayz_thirst],true];
	player setVariable['USEC_isCardiac',false,true];
	player setVariable['medForceUpdate',true,true];
	0 fadeSound 1;
	//healing end

	sleep 5;
	
} else {
	cutText["~~ No room in target Vehicle! ~~","PLAIN",0.5];
};
Link to comment
Share on other sites

  • 0

/**
	Everything related to BloodBag
	(Low Blood, Blurry Screen)
	**/
	if ("ItemBloodbag" in _itemsCargoObjects) then { 
		'dynamicBlur' ppEffectAdjust [0]; 
		'dynamicBlur' ppEffectCommit 5; 
		r_player_blood = r_player_bloodTotal;
		r_player_lowblood = false; 
		player setVariable['USEC_lowBlood',false,true]; 
		player setVariable['USEC_BloodQty',12000,true]; 
		player setdamage 0;
		
		systemChat ("Breakpoint 0");
		
		if (_removeItems) then {
			systemChat ("Breakpoint 1");
			_removedSuccess = ([_cursorTarget,"ItemBloodbag",1] call BIS_fnc_invRemove);
			systemChat ("Breakpoint 2");
			systemChat (format["_removedSuccess = %1",_removedSuccess]);
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("Breakpoint 3");
				systemChat ("A BloodBag has been removed from the Vehicle Cargo");
				systemChat ("Breakpoint 4");
			}; 
		};
	};

Result:

Breakpoint 0

Breakpoint 1

Breakpoint 2

_removedSuccess = 0

 

No script or RPT errors showing up.

 

//EDIT: I added this:

 

systemChat (format["Did cursorTarget change? (%1)",_cursorTarget]);

With the Result:

 

 

Did cursorTarger change? (B 1-1-C:1 (Martin))

 

Looks like the cursorTarget resets, as the player get's in vehicle?

Link to comment
Share on other sites

  • 0

just to get some more info:

 

the script should work like this:

 

player loading in a patient into vehicle, and then shoots the script via fn_selfaction to heal the patient with all the stuff which is in the vehicle, right?

 

Or should the patient who is in the vehicle should execute the script when he is in the vehicle to get healed themselfes?

 

EDIT: 

(B 1-1-C:1 (Martin))

This is a unit and not a vehicle.

If i understand that right now, then the patient is executing this script then. Well But why is it changing the _cursortarget..hmmmm....

Maybe we should try a different way here then, instead of a cursortarget we could try it with looking for the nearest Vehicle and pick that one instead:

_nearEntities = _unit nearEntities [["Land","Air"], 5];		//All Kind of Vehicles
_nearVehicles = _nearEntities - (_unit nearEntities [["Man"], 5]);	//Subtract all Units from the Array
_nearVehicles = _nearVehicles select 0;		//Picks the neares Vehicle
systemChat format['%1',_nearVehicles];

This is maybe a better way to get the right vehicle without any changes?

Link to comment
Share on other sites

  • 0

Well i made it a bit different. I'm getting the Objects, after the player joined the vehicle, like so:

 

if (vehicle player != player) then {
		_itemsCargo = getMagazineCargo (vehicle player);
	} else {
		_itemsCargo = getMagazineCargo cursorTarget;
	};
	
	_itemsCargoObjects = _itemsCargo select 0;
	_itemsCargoCount = _itemsCargo select 1;
	
	systemChat (format["Item Cargo Objects = %1", _itemsCargoObjects]);

Now i noticed, that while there is no cursor targed, the BIS_fnc_invRemomve won't work anymore, so no objects are being removed. I thought, maybe if i get the location of the object in the array and then remove it from array or lower the obejct count then it would maybe work?

 

 

So i didn't test this yet, but i thought about something like this:

if (_removeItems) then {
			_getArrayPos = {_x == "ItemBloodbag"} count _itemsCargoObjects; // This should get the Position of the Object?
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemBloodbag"];
				_itemsCargoCount = _itemsCargoCount - [(_itemsCargoCount select _getArrayPos)]
			};
		};

Note: This is only the array, it's not actually removing items. It want's all magazines in the vehicle deleted and the filled with the new array

Link to comment
Share on other sites

  • 0

Have you tried it with my method to locate the object?

The Method you want to get through would grab all magazines subtract the _x variable grabbed from the daFood and add it then back to the vehicle.

should definitely work, but could whippe the cargo completely if went something wrong.

So better way would be to get it working with only deleting one object.

Will try something as soon as I get home :)

Link to comment
Share on other sites

  • 0

Umm this is the full file:

 

// Author: Martin - Thanks to SchwEde (http://epochmod.com/forum/index.php?/user/15060-schwede/)
private ["_i","_tempArr","_veh","_changed","_getArrayPos","_getArrayPosCount","_getArrayPosCountBefore","_getVeh","_hasCargoFood","_hasCargoWater","_DaFood","_DaWater","_lastindex","_timeout","_unit","_vehicle","_posCommander","_posCargo","_itemsCargo","_itemsCargoObjects","_itemsCargoCount","_itemsMedical","_itemsDrink","_itemsFood","_removedSuccess"];
disableserialization;

//////////////////////
//Remove Items?///////
_removeItems = true;//
//////////////////////
//Show Message?///////
_showMessage = true;//
//////////////////////
//////////////////////

_unit = player;

_cursorTarget = cursorTarget;

_itemsMedical = ["ItemBandage","ItemEpiniphrine","ItemMorphine","ItemHeatPack","ItemBloodbag","ItemAntibiotic","ItemPainkiller"];
_itemsFood = ["FoodSteakRaw","FoodSteakCooked","FoodCanBakedBeans","FoodCanSardines","FoodCanFrankBeans","FoodCanPasta","FoodmeatRaw","FoodmuttonRaw","FoodchickenRaw","FoodrabbitRaw","FoodbaconRaw","FoodbeefRaw","FoodmeatCooked","FoodmuttonCooked","FoodchickenCooked","FoodbaconCooked","FoodrabbitCooked","FoodbeefCooked","FoodMRE","FoodPistachio","FoodNutmix"];
_itemsDrink = ["ItemWaterbottle","ItemSodaCoke","ItemSodaPepsi","ItemSodaMdew","ItemSodaMtngreen","ItemSodaR4Z0R","ItemSodaClays","ItemSodaSmasht","ItemSodaDrWaste","ItemSodaLemonade","ItemSodaLvg","ItemSodaMzly","ItemSodaRabbit","ItemSodaRbull","ItemSodaOrangeSherbet","ItemWaterbottleBoiled"];

_posCommander = _cursorTarget emptyPositions "Commander";
_posCargo = _cursorTarget emptyPositions "Cargo";

if (_posCommander != 0 || _posCargo != 0) then {
	if (_posCommander != 0) then {
		_unit assignAsCommander _cursorTarget;
		[_unit] orderGetIn true;
		_unit moveInCommander _cursorTarget;
	} else {
		_unit assignAsCargo _cursorTarget;
		[_unit] orderGetIn true;
		_unit moveInCargo [_cursorTarget,1]; //0 Is the Passenger and 1 is the "invisible" (i think?)
	};
		
	_timeout = 10;
	while {_timeout > 0} do {
		cutText["~~ You are being Healed... ~~\n~~ Please wait ~~","PLAIN",0.5];
		sleep 1;
		_timeout = _timeout - 1;
		
		if (vehicle player != player) then {
			vehicle player lockDriver true;
			vehicle player lockCargo true;
		} else {
			_cursorTarget lockDriver true;
			_cursorTarget lockCargo true;
		};
	};
	
	if (vehicle player != player) then {
		_itemsCargo = getMagazineCargo (vehicle player);
	} else {
		_itemsCargo = getMagazineCargo cursorTarget;
	};
	
	_itemsCargoObjects = _itemsCargo select 0;
	_itemsCargoCount = _itemsCargo select 1;
	
	_changed = false;
	
	systemChat (format["Item Cargo Objects = %1", _itemsCargoObjects]);

				
	/**
	Everything related to BloodBag
	(Low Blood, Blurry Screen)
	**/
	if ("ItemBloodbag" in _itemsCargoObjects) then {
		'dynamicBlur' ppEffectAdjust [0]; 
		'dynamicBlur' ppEffectCommit 5; 
		r_player_blood = r_player_bloodTotal;
		r_player_lowblood = false; 
		player setVariable['USEC_lowBlood',false,true]; 
		player setVariable['USEC_BloodQty',12000,true]; 
		player setdamage 0;
		
		if (_removeItems) then {
			
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemBloodbag"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemBloodbag"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};
	
	/**
	Everything related to Painkillers
	(Camera Shake)
	**/
	if ("ItemPainkiller" in _itemsCargoObjects) then { 
		r_player_inpain = false; 
		resetCamShake; 
		player setVariable['USEC_inPain',false,true]; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemPainkiller"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemPainkiller"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};
	
	/**
	Everything related to Antibiotics
	(Coughing, Loosing Blood?)
	**/
	if ("ItemAntibiotic" in _itemsCargoObjects) then { 
		r_player_infected = false; 
		player setVariable['USEC_infected',false,true]; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemAntibiotic"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemAntibiotic"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};

	/**
	Everything related to Bandages
	(Loosing Blood)
	**/
	if ("ItemBandage" in _itemsCargoObjects) then { 
		dayz_sourceBleeding = objNull; 
		player setVariable['USEC_injured',false,true]; 
		r_player_injured = false; 
		_display = uiNameSpace getVariable 'DAYZ_GUI_display'; 
		_control = _display displayCtrl 1303; 
		_control ctrlShow false;
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemBandage"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemBandage"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};
	
	/**
	Everything related to Heatpacks
	(Being Cold, Coughing?)
	**/
	if ("ItemHeatPack" in _itemsCargoObjects) then { 
		dayz_temperatur = 37; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemHeatPack"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemHeatPack"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};
	
	/**
	Everything related to Morphine
	(Fractures)
	**/
	if ("ItemMorphine" in _itemsCargoObjects) then { 
		_selection = 'legs'; 
		_damage = 0; 
		player setHit[_selection,_damage]; 
		r_fracture_legs = false; 
		r_fracture_arms = false; 
		player setVariable['hit_legs',0,true]; 
		player setVariable['hit_hands',0,true]; 
		_display = uiNameSpace getVariable 'DAYZ_GUI_display'; 
		_control = _display displayCtrl 1203; 
		_control ctrlShow false; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemMorphine"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemMorphine"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};

	/**
	Everything related to Epi Pens
	(Unconscious? - You can't really use scroll wheel, if unconscious, so this is probably impossible)
	**/
	if ("ItemEpiniphrine" in _itemsCargoObjects) then { 
		r_player_unconscious = false; 
		player setVariable['NORRN_unconscious',false,true]; 
		player setVariable['unconsciousTime',0,true]; 
		
		if (_removeItems) then {
		
			//Make sure the Var is Empty
			_getArrayPos = 0;
			_getArrayPosCount = 0;
		
			_getArrayPos = _itemsCargoObjects find "ItemEpiniphrine"; // Testing this instead
			_getArrayPosCount = _itemsCargoCount select _getArrayPos; //_result is the Object Count of the Object
			
			systemChat (format["Array Pos = %1", _getArrayPos]);
			systemChat (format["Array Pos Count = %1", _getArrayPosCount]);
			
			if (_getArrayPosCount > 1) then {
				_getArrayPosCount = (_itemsCargoCount select _getArrayPos) - 1;
				systemChat (format["Array Pos Count New = %1", _getArrayPosCount]);
				_changed = true;
			} else {
				_itemsCargoObjects = _itemsCargoObjects - ["ItemEpiniphrine"];
				//_removedSuccess = _itemsCargoCount deleteAt _getArrayPos; <- This won't work for some reason?
				
				//Object will not be added, if the Count is == 0
				_itemsCargoCount = (_itemsCargoCount select _getArrayPos) - 1;
				
				systemChat (format["Cargo Objects new = %1", _itemsCargoCount]);
				_changed = true;
			};
		};
	};
	
	/**
	Everything related to Food
	(Hungry)
	**/
	_hasCargoFood = false;
	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoFood = true;
			_DaFood = _x;
		};
	} count _itemsFood;
	
	if (_hasCargoFood) then {
		dayz_hunger = 0;
		if (_removeItems) then {
			_removedSuccess = ([vehicle player,_DaFood] call BIS_fnc_invRemove);
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("Test1");
			}; 
		};
	};
	
	/**
	Everything related to Water
	(Thirsty)
	**/
	_hasCargoWater = false;
	{
		if (_x in _itemsCargoObjects) exitWith
		{
			_hasCargoWater = true;
			_DaWater = _x;
		};
	} count _itemsDrink;
	
	if (_hasCargoWater) then {
		dayz_thirst = 0;
		if (_removeItems) then {
			_removedSuccess = ([(vehicle player),_DaWater] call BIS_fnc_invRemove);
			if(_removedSuccess == 1 && _showMessage) then {
				systemChat ("Test2");
			}; 
		};
	};
	
	if (_changed) then {
		
		//This is just a double check...
		if (vehicle player != player) then {
			_veh = vehicle player;
			clearMagazineCargo _veh;
			
			//Format the array and put the items back in
			_i = 0;
			
			{	
				//If the Count is 0, we jump that entry
				if ((_itemsCargoCount select _i) == 0) then {_i = _i + 1;};
				
				//					Name of Item					Count of Item
				_tempArr = [[(_itemsCargoObjects select _i)],[(_itemsCargoCount select _i)]];
				
				//Actually put it in
				(vehicle player) addMagazineCargoGlobal _tempArr;
				
				//Add to _i, so we can do this for all items...
				_i = _i + 1;
				
			} foreach _itemsCargoObjects;
			
			//Make sure to unlock vehicle again after finish
			vehicle player lockDriver false;
			vehicle player lockCargo false;
			
		} else {
			clearMagazineCargo cursorTarget;
			
			_i = 0;
			
			{	
				//If the Count is 0, we jump that entry
				if ((_itemsCargoCount select _i) == 0) then {_i = _i + 1;};
				
				//					Name of Item					Count of Item
				_tempArr = [[(_itemsCargoObjects select _i)],[(_itemsCargoCount select _i)]];
				
				//Actually put it in
				cursorTarget addMagazineCargoGlobal _tempArr;
				
				//Add to _i, so we can do this for all items...
				_i = _i + 1;
				
			} foreach _itemsCargoObjects;
			
			//Make sure to unlock vehicle again after finish
			_cursorTarget lockDriver true;
			_cursorTarget lockCargo true;
		};
		
	} else {
		//Nothing changed, unlock the Vehicle
		vehicle player lockDriver false;
		vehicle player lockCargo false;
	};
	
	sleep 5;
	
} else {
	cutText["~~ No room in target Vehicle! ~~","PLAIN",0.5];
};

It is removing the Items, but not putting any items back in... I think the Problem is  in the last Part the forEach loop.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...