mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
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:
@@ -102,6 +102,10 @@ if (isServer) then {
|
|||||||
dayz_POIs = false; //Enable POI's
|
dayz_POIs = false; //Enable POI's
|
||||||
dayz_enableGhosting = false;
|
dayz_enableGhosting = false;
|
||||||
dayz_ghostTimer = 120;
|
dayz_ghostTimer = 120;
|
||||||
|
DZE_disableThermal = []; // Array of vehicle classnames to disable thermal on when being spawned. i.e: ["AH1Z","MTVR"];
|
||||||
|
DZE_clearVehicleAmmo = true; // Clears the ammo of vehicles spawned, bought, claimed and upgraded during the same restart
|
||||||
|
DZE_clearVehicleFlares = false; // Clears the flares of vehicles during the same restart, DZE_clearVehicleAmmo must be true in order to work
|
||||||
|
DZE_addVehicleAmmo = false; // Adds ammo to all spawned, bought, claimed and upgraded vehicles during the same restart
|
||||||
|
|
||||||
// ZSC
|
// ZSC
|
||||||
Z_globalBankingTraders = false; // Enable banking NPCs at trader cities.
|
Z_globalBankingTraders = false; // Enable banking NPCs at trader cities.
|
||||||
@@ -109,14 +113,8 @@ if (isServer) then {
|
|||||||
// Safe Zone Relocating
|
// Safe Zone Relocating
|
||||||
DZE_SafeZone_Relocate = false; //Enables relocating of vehicles left in Safe Zones over a server restart.
|
DZE_SafeZone_Relocate = false; //Enables relocating of vehicles left in Safe Zones over a server restart.
|
||||||
|
|
||||||
if (DZE_VehicleKey_Changer) then {
|
|
||||||
vkc_clearAmmo = true; // Clear the ammo of vehicles after they have been rekeyed/claimed? (stops users getting a free rearm)
|
|
||||||
vkc_disableThermal = [""]; // Array of vehicle config classes as well as vehicle classnames to disable thermal on when being spawned. i.e: ["All","Land","Air","Ship","StaticWeapon","AH1Z","MTVR"];
|
|
||||||
};
|
|
||||||
|
|
||||||
if (DZE_Virtual_Garage) then {
|
if (DZE_Virtual_Garage) then {
|
||||||
vg_clearAmmo = true; // Clear the ammo of vehicles spawned during the same restart they are stored? (stops users storing a vehicle for a free rearm)
|
vg_clearAmmo = true; // Clear the ammo of vehicles spawned during the same restart they are stored? (stops users storing a vehicle for a free rearm)
|
||||||
vg_disableThermal = []; // Array of vehicle config classes as well as vehicle classnames to disable thermal on when being spawned. i.e: ["All","Land","Air","Ship","StaticWeapon","AH1Z","MTVR"];
|
|
||||||
vg_sortColumn = 0; //0 or an out of range value sorts by the default column 'DisplayName', otherwise 1 = 'DateStored', 2 = 'id', 3 = 'Name' (of storing player), 4 = 'DateMaintained'
|
vg_sortColumn = 0; //0 or an out of range value sorts by the default column 'DisplayName', otherwise 1 = 'DateStored', 2 = 'id', 3 = 'Name' (of storing player), 4 = 'DateMaintained'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,36 +19,3 @@ VG_RandomizeMyKey = {
|
|||||||
};
|
};
|
||||||
vg_serverKey = toString (8 call VG_RandomizeMyKey);
|
vg_serverKey = toString (8 call VG_RandomizeMyKey);
|
||||||
vg_alreadySpawned = [];
|
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;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -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;
|
_worldSpace = _this select 0;
|
||||||
_player = _this select 1;
|
_player = _this select 1;
|
||||||
@@ -57,7 +57,6 @@ if (_outcome != "PASS") then {
|
|||||||
|
|
||||||
clearWeaponCargoGlobal _object;
|
clearWeaponCargoGlobal _object;
|
||||||
clearMagazineCargoGlobal _object;
|
clearMagazineCargoGlobal _object;
|
||||||
if (vg_clearAmmo && {vg_serverKey == _serverKey}) then {_object call VG_ClearTurrets;};
|
|
||||||
|
|
||||||
_object setFuel _fuel;
|
_object setFuel _fuel;
|
||||||
_object setDamage _damage;
|
_object setDamage _damage;
|
||||||
@@ -91,10 +90,11 @@ if (_outcome != "PASS") then {
|
|||||||
|
|
||||||
[_object,"all",true] call server_updateObject;
|
[_object,"all",true] call server_updateObject;
|
||||||
|
|
||||||
|
[_object,vg_clearAmmo,false] call server_vehicleAddons;
|
||||||
|
|
||||||
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
|
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_object];
|
||||||
|
|
||||||
_object call fnc_veh_ResetEH;
|
_object call fnc_veh_ResetEH;
|
||||||
{if (_object isKindOf _x) exitWith {_object disableTIEquipment true;}} count vg_disableThermal;
|
|
||||||
|
|
||||||
PVDZE_veh_Init = _object;
|
PVDZE_veh_Init = _object;
|
||||||
publicVariable "PVDZE_veh_Init";
|
publicVariable "PVDZE_veh_Init";
|
||||||
|
|||||||
43
SQF/dayz_server/compile/server_clearTurrets.sqf
Normal file
43
SQF/dayz_server/compile/server_clearTurrets.sqf
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
//By denvdmj (probably, I found it on the biki)
|
||||||
|
|
||||||
|
local _obj = _this;
|
||||||
|
|
||||||
|
local _weaponArray = [];
|
||||||
|
_weaponArray set [count _weaponArray,[-1]];
|
||||||
|
|
||||||
|
local _findRecurse = {
|
||||||
|
local _root = (_this select 0);
|
||||||
|
local _path = +(_this select 1);
|
||||||
|
local _thisThis = _this select 2;
|
||||||
|
|
||||||
|
for "_i" from 0 to count _root -1 do {
|
||||||
|
local _class = _root select _i;
|
||||||
|
|
||||||
|
if (isClass _class) then {
|
||||||
|
local _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", [], _obj] call _findRecurse;
|
||||||
|
|
||||||
|
{
|
||||||
|
local _turret = _x;
|
||||||
|
local _mags = _obj magazinesTurret _turret;
|
||||||
|
|
||||||
|
{
|
||||||
|
local _mag = _x;
|
||||||
|
if !(["horn",_mag] call fnc_inString) then {
|
||||||
|
if (DZE_clearVehicleFlares) then {
|
||||||
|
_obj removeMagazinesTurret[_mag,_turret];
|
||||||
|
} else {
|
||||||
|
if !(["flare",_mag] call fnc_inString) then {
|
||||||
|
_obj removeMagazinesTurret[_mag,_turret];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} count _mags;
|
||||||
|
} forEach _weaponArray;
|
||||||
47
SQF/dayz_server/compile/server_fillTurrets.sqf
Normal file
47
SQF/dayz_server/compile/server_fillTurrets.sqf
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
local _obj = _this select 0;
|
||||||
|
local _countMags = _this select 1;
|
||||||
|
|
||||||
|
local _weaponArray = [];
|
||||||
|
_weaponArray set [count _weaponArray,["",[-1]]];
|
||||||
|
|
||||||
|
local _findRecurse = {
|
||||||
|
local _root = (_this select 0);
|
||||||
|
local _path = +(_this select 1);
|
||||||
|
local _thisThis = _this select 2;
|
||||||
|
|
||||||
|
for "_i" from 0 to count _root -1 do {
|
||||||
|
local _class = _root select _i;
|
||||||
|
|
||||||
|
if (isClass _class) then {
|
||||||
|
local _currentPath = _path + [_i];
|
||||||
|
{
|
||||||
|
_weaponArray set [count _weaponArray,[_x,_currentPath]];
|
||||||
|
} count getArray (_class >> "weapons");
|
||||||
|
_class = _class >> "turrets";
|
||||||
|
if (isClass _class) then {[_class, _currentPath, _thisThis] call _findRecurse;};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
[configFile >> "CfgVehicles" >> typeOf (_obj) >> "turrets", [], _obj] call _findRecurse;
|
||||||
|
|
||||||
|
{
|
||||||
|
local _type = _x select 0;
|
||||||
|
local _turret = _x select 1;
|
||||||
|
local _mags = getArray(configFile >> "CfgWeapons" >> _type >> "magazines");
|
||||||
|
local _mag = _mags select 0;
|
||||||
|
|
||||||
|
if (!isNil "_mag" && {!(["horn",_mag] call fnc_inString)})then {
|
||||||
|
for "_i" from 1 to _countMags do {
|
||||||
|
_obj addMagazineTurret[_mag,_turret];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach _weaponArray;
|
||||||
|
|
||||||
|
{
|
||||||
|
local _mags = getArray(configFile >> "CfgWeapons" >> _x >> "magazines");
|
||||||
|
local _mag = _mags select 0;
|
||||||
|
for "_i" from 1 to _countMags do {
|
||||||
|
_obj addMagazine _mag;
|
||||||
|
};
|
||||||
|
} count (weapons _obj);
|
||||||
@@ -80,6 +80,8 @@ if (_outcome != "PASS") then {
|
|||||||
|
|
||||||
[_object,"all",true] call server_updateObject;
|
[_object,"all",true] call server_updateObject;
|
||||||
|
|
||||||
|
[_object,DZE_clearVehicleAmmo,DZE_addVehicleAmmo] call server_vehicleAddons;
|
||||||
|
|
||||||
_object call fnc_veh_ResetEH;
|
_object call fnc_veh_ResetEH;
|
||||||
|
|
||||||
PVDZE_veh_Init = _object;
|
PVDZE_veh_Init = _object;
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ if (_outcome != "PASS") then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[_object,DZE_clearVehicleAmmo,DZE_addVehicleAmmo] call server_vehicleAddons;
|
||||||
|
|
||||||
_object call fnc_veh_ResetEH;
|
_object call fnc_veh_ResetEH;
|
||||||
|
|
||||||
PVDZE_veh_Init = _object;
|
PVDZE_veh_Init = _object;
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ if (_outcome != "PASS") then {
|
|||||||
|
|
||||||
[_object,"all",true] call server_updateObject;
|
[_object,"all",true] call server_updateObject;
|
||||||
|
|
||||||
|
[_object,DZE_clearVehicleAmmo,false] call server_vehicleAddons;
|
||||||
|
|
||||||
_object call fnc_veh_ResetEH;
|
_object call fnc_veh_ResetEH;
|
||||||
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
|
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
|
||||||
PVDZE_veh_Init = _object;
|
PVDZE_veh_Init = _object;
|
||||||
|
|||||||
@@ -141,53 +141,19 @@ if (_outcome != "PASS") then {
|
|||||||
processInitCommands;
|
processInitCommands;
|
||||||
[_weapons,_magazines,_backpacks,_object] call fn_addCargo;
|
[_weapons,_magazines,_backpacks,_object] call fn_addCargo;
|
||||||
|
|
||||||
_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;
|
|
||||||
};
|
|
||||||
|
|
||||||
_object setFuel _fuel;
|
_object setFuel _fuel;
|
||||||
|
|
||||||
[_object,_newHitpoints] call server_setHitpoints;
|
[_object,_newHitpoints] call server_setHitpoints;
|
||||||
|
|
||||||
[_object,"all",true] call server_updateObject;
|
[_object,"all",true] call server_updateObject;
|
||||||
|
|
||||||
|
[_object,DZE_clearVehicleAmmo,false] call server_vehicleAddons;
|
||||||
|
|
||||||
_object call fnc_veh_ResetEH;
|
_object call fnc_veh_ResetEH;
|
||||||
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
|
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
|
||||||
PVDZE_veh_Init = _object;
|
PVDZE_veh_Init = _object;
|
||||||
publicVariable "PVDZE_veh_Init";
|
publicVariable "PVDZE_veh_Init";
|
||||||
|
|
||||||
{if (_object isKindOf _x) exitWith {_object disableTIEquipment true;}} count vkc_disableThermal;
|
|
||||||
if (vkc_clearAmmo) then {_object call _clearTurrets;};
|
|
||||||
|
|
||||||
dze_waiting = "success";
|
dze_waiting = "success";
|
||||||
(owner _activatingPlayer) publicVariableClient "dze_waiting";
|
(owner _activatingPlayer) publicVariableClient "dze_waiting";
|
||||||
|
|
||||||
|
|||||||
34
SQF/dayz_server/compile/server_vehicleAddons.sqf
Normal file
34
SQF/dayz_server/compile/server_vehicleAddons.sqf
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
local _vehicle = _this select 0;
|
||||||
|
local _clearAmmo = _this select 1;
|
||||||
|
local _addAmmo = _this select 2;
|
||||||
|
local _type = typeOf _vehicle;
|
||||||
|
|
||||||
|
local _skipAmmoClear = []; // Add vehicle classnames you do not want to clear the ammo
|
||||||
|
local _skipAmmoFill = []; // Add vehicle classnames you do not want to fill the ammo
|
||||||
|
|
||||||
|
if (_type in DZE_disableThermal) then {
|
||||||
|
_vehicle disableTIEquipment true;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_clearAmmo && {!(_type in _skipAmmoClear)}) then {
|
||||||
|
_vehicle call server_clearTurrets;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_addAmmo && {!(_type in _skipAmmoFill)}) then {
|
||||||
|
local _countMags = 2; // Number of how many magazines will be added to the vehicle
|
||||||
|
[_vehicle,_countMags] call server_fillTurrets;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Add/Remove extra weapons and ammo
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
if (_type == "GNT_C185T") exitwith {
|
||||||
|
_vehicle removeWeapon "FFARLauncher_12";
|
||||||
|
_vehicle addWeapon "pook_M60_dual_DZ";
|
||||||
|
_vehicle addMagazine "pook_1300Rnd_762x51_M60";
|
||||||
|
_vehicle addMagazine "pook_1300Rnd_762x51_M60";
|
||||||
|
};
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -24,6 +24,9 @@ server_onPlayerDisconnect = compile preprocessFileLineNumbers "\z\addons\dayz_se
|
|||||||
call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\updateObject_functions.sqf";
|
call compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\updateObject_functions.sqf";
|
||||||
server_updateObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
|
server_updateObject = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateObject.sqf";
|
||||||
server_setHitpoints = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_setHitpoints.sqf";
|
server_setHitpoints = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_setHitpoints.sqf";
|
||||||
|
server_vehicleAddons = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_vehicleAddons.sqf";
|
||||||
|
server_clearTurrets = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_clearTurrets.sqf";
|
||||||
|
server_fillTurrets = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_fillTurrets.sqf";
|
||||||
server_playerDied = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
|
server_playerDied = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerDied.sqf";
|
||||||
server_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf"; //Creates the object in DB
|
server_publishObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_publishObject.sqf"; //Creates the object in DB
|
||||||
server_deleteObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf"; //Removes the object from the DB
|
server_deleteObj = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf"; //Removes the object from the DB
|
||||||
|
|||||||
@@ -372,6 +372,8 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
|
|||||||
|
|
||||||
[_object,"all",true] call server_updateObject;
|
[_object,"all",true] call server_updateObject;
|
||||||
|
|
||||||
|
[_object,DZE_clearVehicleAmmo,DZE_addVehicleAmmo] call server_vehicleAddons;
|
||||||
|
|
||||||
_object call fnc_veh_ResetEH;
|
_object call fnc_veh_ResetEH;
|
||||||
if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {_object setVehicleLock "locked";};
|
if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {_object setVehicleLock "locked";};
|
||||||
_serverVehicleCounter set [count _serverVehicleCounter,_type]; // total each vehicle
|
_serverVehicleCounter set [count _serverVehicleCounter,_type]; // total each vehicle
|
||||||
|
|||||||
Reference in New Issue
Block a user