Add function for vehicle addons

This adds a remove and add ammo function for vehicles. Also a keep flares check if the vehicle ammo got removed.
Server admins can add/remove different weapons to vehicles by just editing server_spawnVehicle.
This commit is contained in:
A Man
2022-03-22 18:27:33 +01:00
parent 637f1f4450
commit 981e217b8e
12 changed files with 148 additions and 82 deletions

View File

@@ -18,37 +18,4 @@ VG_RandomizeMyKey = {
_return;
};
vg_serverKey = toString (8 call VG_RandomizeMyKey);
vg_alreadySpawned = [];
VG_ClearTurrets = {
//By denvdmj (probably, I found it on the biki)
private ["_weaponArray","_findRecurse","_class","_obj","_turret","_mags"];
_obj = _this;
_weaponArray = [];
_weaponArray set [count _weaponArray,[-1]];
_findRecurse = {
private ["_root", "_class", "_path", "_currentPath", "_thisThis"];
_root = (_this select 0);
_path = +(_this select 1);
_thisThis = _this select 2;
for "_i" from 0 to count _root -1 do {
_class = _root select _i;
if (isClass _class) then {
_currentPath = _path + [_i];
{_weaponArray set [count _weaponArray, _currentPath];} count getArray (_class >> "weapons");
_class = _class >> "turrets";
if (isClass _class) then {[_class, _currentPath, _thisThis] call _findRecurse;};
};
};
};
[configFile >> "CfgVehicles" >> typeOf (_obj) >> "turrets", [], _this] call _findRecurse;
{
_turret = _x;
_mags = _obj magazinesTurret _turret;
{_obj removeMagazinesTurret[_x,_turret];} count _mags;
} forEach _weaponArray;
};
vg_alreadySpawned = [];

View File

@@ -1,4 +1,4 @@
private ["_isAir","_VG_ObjID","_characterID","_class","_clientID","_clrinit","_clrinit2","_colour","_colour2","_dam","_damage","_dir","_fuel","_hitpoints","_id","_inventory","_key","_location","_message","_object","_oid","_outcome","_player","_result","_selection","_serverKey","_uid","_worldSpace"];
private ["_VG_ObjID","_characterID","_class","_clientID","_clrinit","_clrinit2","_colour","_colour2","_dam","_damage","_dir","_fuel","_hitpoints","_id","_inventory","_key","_location","_message","_object","_oid","_outcome","_player","_result","_selection","_serverKey","_uid","_worldSpace"];
_worldSpace = _this select 0;
_player = _this select 1;
@@ -57,7 +57,6 @@ if (_outcome != "PASS") then {
clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
if (vg_clearAmmo && {vg_serverKey == _serverKey}) then {_object call VG_ClearTurrets;};
_object setFuel _fuel;
_object setDamage _damage;
@@ -90,11 +89,12 @@ if (_outcome != "PASS") then {
[_object,_hitpoints] call server_setHitpoints;
[_object,"all",true] call server_updateObject;
[_object,vg_clearAmmo,false] call server_vehicleAddons;
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
_object call fnc_veh_ResetEH;
{if (_object isKindOf _x) exitWith {_object disableTIEquipment true;}} count vg_disableThermal;
_object call fnc_veh_ResetEH;
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";