Jump to content
  • 0

Spawning Vehicles With Loot Inside


TheGodfather

Question

I've been trying to spawn a vehicle in my AI city for every restart like Sector B did with the urals but I've been running into some trouble. I can spawn them in with WAI using the custom static boxes, but the problem is if you get in the vehicle it stays over on a restart. I know that you can disable that feature, but that would effect with our mission system. I've tried spawning Urals in via mission.pbo, but that didn't work at all, but that seems like the way to do it. 

 

Here is the code that's located in the mission.pbo (called from init.sqf), I know I must be doing something wrong...

 

if (isServer) then {
private ["_object","_uniqueid"];
 
_vehicle_43 = objNull;
if (true) then
{
  _object = createVehicle ["KamazOpen", [429.88358, 451.99084, 2.2888184e-005], [], 0, "CAN_COLLIDE"];
  _object addMagazineCargoGlobal ["CinderBlocks", 50];
  _object addMagazineCargoGlobal ["MortarBucket", 25];
  _object addMagazineCargoGlobal ["PartPlywoodPack", 10];
  _object addMagazineCargoGlobal ["cinder_garage_kit", 2];
  _object addMagazineCargoGlobal ["PartGeneric", 10];
  _object addMagazineCargoGlobal ["ItemSandbag", 15];
  _object addMagazineCargoGlobal ["ItemTankTrap", 15];
  _object addMagazineCargoGlobal ["forest_large_net_kit", 3];
  _object addMagazineCargoGlobal ["ItemComboLock", 2];
  _vehicle_43 = _object;
  _object setPos [429.88358, 451.99084, 2.2888184e-005];
  _object setVariable ["malsar",1,true];
  _uniqueid = str(round(random 999999));
  _object setVariable ["ObjectID", _uniqueid, true];
  _object setVariable ["ObjectUID", _uniqueid, true];
};

 

Link to comment
Share on other sites

Recommended Posts

  • 0
[_vehicle] spawn {
private ['_selectedVeh','_proceed'];

_selectedVeh = _this select 0;
_proceed = true;

while {!isNull && _proceed} do {
if ((count (getMagazineCargo _selectedVeh) <= 0) &&
(count (getWeaponCargo _selectedVeh) <= 0) &&
(count (getBackpackCargo _selectedVeh) <= 0)) exitWith {
_proceed = false;
deletevehicle _selectedVeh;
};
};
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...