Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
christian2526

How to check if the vehicle player has any kind of magazines or weapons?

Recommended Posts

Heey Everyone,

I`m trying to get a ai named "guard" to check if the vehicle of the player has any kind of weapons or magazines. I want it to be like a Checkpoint and if the script detects anything in the vehicles cargo it should clear the cargo and give the car the fuel back. This is what i got sofar, the gurad is already going to the car and car is set to certian point and the fuel is being removed untill the check is done. I`m playing with ACE.

_searchTime = 15; //This is defined for later use.
if (vehicle player isKindOf "LandVehicle") then
{
vehicle player setFuel 0;
sleep 2;
vehicle player setPos (getPos bod);
guard doMove (getPos vehicle player);
sleep 5;
//guard playMove "AinvPknlMstpSlayWrflDnon_medic";
if (Here is the point where i want the vehicle to be search by this script and then it should remove everything) then
{
sleep 1;
clearMagazineCargo vehicle player;
clearWeaponCargo vehicle player;
};
sleep 9;
guard doMove (getPos vehicle player);
sleep 3;
guard doMove (getMarkerPos "wait");
};

It would be nice if someone cloud help me out with that. Thank you guys.

Chris ~Germany, sorry for my english :)

Share this post


Link to post
Share on other sites

ehm, if you want to remove all weapons and magazines from a vehicle without exceptions, so just do it :D

You don't need to check for weapons or other stuff if you'll remove them anyway xD

The only reason why you'd check for it would be executing a response to that, like saying something and alike.

Just get rid of the if around your code that removes the stuff and you're good to go ;)

Share this post


Link to post
Share on other sites

Nah, i just want the script to remove Exlosives, i would add a list.

Share this post


Link to post
Share on other sites

Untested but should probably work fine.

	
private ["_index"];
_vehicle = vehicle player;
_unwantedmag = "Pipebomb";
//Get all the magazines in the vehicle
_mags = getmagazinecargo _vehicle;

//Separate the resultarray into magazinclassnames and amount of each magazineclass
_magazines = _mags select 0;
_magazineamounts = _mags select 1;

//Check if some type of magazine is in the vehicle and act accordingly
if (_unwantedmag in _magazines) then {
_counter = 0;

//Check what index the magazine has in the _magazines array
{
	if (_x == _unwantedmag) then {_index = _counter};
	_counter = _counter + 1;
} forEach _magazines;

//Remove all mags
clearMagazineCargoGlobal _vehicle;

//Add all mags back, EXCEPT the item that we don't want to add
if (count _magazines > 0) then {
	for "_i" from 0 to ((count _magazines)-1) do {
		if (_i != _index) then {
			_vehicle addMagazineCargoGlobal [_magazines select _i, _magazineamounts select _i];
		};
	};
};
};

Share this post


Link to post
Share on other sites

Thank you, i already figured out a way that works fine but i will try and may add yours. Thanks for you time people.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×