Jump to content
  • 0

scattered destroyed vehicle loot


calamity

Question

13 answers to this question

Recommended Posts

  • 0

vehicle_handleKilled.sqf

private["_unit","_hitPoints","_selection","_killer"];

_unit = _this select 0;
_killer = _this select 1;

_hitPoints = _unit call vehicle_getHitpoints;
{
    _selection = getText (configFile >> "CfgVehicles" >> (typeof _unit) >> "HitPoints" >> _x >> "name");
    _unit setVariable [_selection, 1, true];
} count _hitPoints;

//["PVDZE_veh_Update",[_unit, "damage"]] call callRpcProcedure;
if (isServer) then {
    [_unit, "killed"] call server_updateObject;
} else {
    if (DZE_Debug_Damage && ((!isPlayer _unit) || ((isPlayer _unit) && (vehicle _unit != _unit) && (_unit != _killer)))) then {
        PVDZE_veh_Update = [_unit, "killed",_killer];
        _killerVeh = if (vehicle _killer != _killer) then { format["[KILLER IN VEHICLE %1 OF TYPE %2]", (vehicle _killer), (typeOf (vehicle _killer))]; } else {""};
        _name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; };
        // diag_log format["DAMAGE: Vehicle %1 (TYPE: %2) Killed by player %3 (UID: %4) %5",_unit, (typeOf _unit), _name, (getPlayerUID _killer), _killerVeh];
    } else {
        PVDZE_veh_Update = [_unit, "killed"];
    };
    publicVariableServer "PVDZE_veh_Update";
};

_unit removeAllEventHandlers "HandleDamage";
_unit removeAllEventHandlers "Killed";
_unit removeAllEventHandlers "GetIn";
_unit removeAllEventHandlers "GetOut";

//_var = round ((random 9) + 1);
Xvar = true; ///test
if (Xvar) then {
_wep = getWeaponCargo _unit;
_mags = getMagazineCargo _unit;
_pos = getPosATL _unit;

//create weaponHolder
_tempContainer = createVehicle ["weaponHolder", [(_pos select 0) + 5, (_pos select 1) + 5, (_pos select 2)], [], 0, "can_collide"];
//add items to weaponHolder
{
    _tempContainer addWeaponCargoGlobal [_x,1];
} forEach _wep;

{
    _tempContainer addMagazineCargoGlobal [_x,1];
} forEach _mags;

};
Link to comment
Share on other sites

  • 0

Doesn't seem to work. I coped the vehicle_handleKilled.sqf to my mission file. Added this line to my custom compiles:

vehicle_handleKilled    = compile preprocessFileLineNumbers "custom\vehicle_loot\vehicle_handleKilled.sqf";

I shot one car up and I also crashed another and in neither case did any loot drop.

Link to comment
Share on other sites

  • 0

It could be 1 of 2 things that are stopping it working.

No 1. When a vehicle is destroyed I think it's cargo is cleared right away.

No 2. When using getWeaponCargo or getMagazineCargo it returns an array in this format [["weapons","weapons"],[1,4]]

So when you use a forEach loop of _wep and _mags it's trying to add ["weapons,"weapons"] and [1,4] to the vehicle as cargo.

Link to comment
Share on other sites

  • 0

It could be 1 of 2 things that are stopping it working.

No 1. When a vehicle is destroyed I think it's cargo is cleared right away.

No 2. When using getWeaponCargo or getMagazineCargo it returns an array in this format [["weapons","weapons"],[1,4]]

So when you use a forEach loop of _wep and _mags it's trying to add ["weapons,"weapons"] and [1,4] to the vehicle as cargo.

 

So any idea if this is even do-able?

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...