Help Thread for Epoch Remove Weapons

Hi there, I've been having a difficult time removing the ammo on a T34 on Overpoch 1051 server.

I've tried several seat positions according to a M1A2 Tusk seat arrangement which didn't work.

Currently i've got all seats covered with the different ammo classes but none seem to work:
if (_object isKindof "T34") then {

_object removeMagazinesTurret ["10Rnd_85mmAP",[0,0]]; <= Commander position
_object removeMagazinesTurret ["33Rnd_85mmHE",[0,0]];
_object removeMagazinesTurret ["10Rnd_85mmAP",[0,1]]; <= Loader on M1A2, maybe sidegunner on T34?
_object removeMagazinesTurret ["33Rnd_85mmHE",[0,1]];
_object removeMagazinesTurret ["10Rnd_85mmAP",[0]]; <= Gunner
_object removeMagazinesTurret ["33Rnd_85mmHE",[0]];
_object removeMagazinesTurret ["10Rnd_85mmAP",[1]]; <= Test
_object removeMagazinesTurret ["33Rnd_85mmHE",[1]];
_object removeMagazinesTurret ["60Rnd_762x54_DT",[1]];
_object removeMagazinesTurret ["60Rnd_762x54_DT",[0,1]];
_object removeMagazinesTurret ["60Rnd_762x54_DT",[0]];
_object removeMagazinesTurret ["60Rnd_762x54_DT",[0,0]];

};

I could use some help figuring this out, since the T34 is a reward on my AI mission and ammo will be a seperate award.

Edit: The objective is to have the vehicle spawn within the WAI mission files.. I got that working so my guess is, the remove ammo script is running before the vehicle spawns therefore not removing the ammo. within the WAI default.sqf i call: ["T34",[409.362,15310.2,0.00140381],true] call custom_publish; Which publishes the vehicle on said coordinates.

If i put the vehicle in the trader, the script works fine, as i've tested it with BAF_Apache_AH1_D class vehicle. If i spawn that chopper in the WAI mission file, it still has ammo in it. tried adding the call fnc_remWepSG; after the call custom_publish, but that gives back expression errors in server RPT.

Thx in advance.
 
Last edited:
So first of all:
Thanks for giving as much information as possible.
But i am currently not on my home computer (and won't be on it for a couple of months), so i would gladly appreciate it if you could upload the custom_publish file.

And does it remove the Ammo from the T34 when it is spawned through the trader? Otherwise i would need to look into it what could be causing it.


As I already said earlier in this thread (at least I think so :p) if you would use an "Antihacktool" for spawning in Vehicles it won't work. Simply because it isn't executed when they are spawned. The trader are executing the Script before they are spawning it because they are using one of the spawnVehicle Scripts from Epoch (as I was saying I can't really tell you the right name because I can't look it up).

tl:dr If you upload the custom_spawn file I can have a look into it. It needs to be executed in the Script. Not before the script is called nor after. It needs to be executed in the right place in the script.
So upload it and I try to see what I can to for you :).


Cheers J3T


PS: I would advise you to seperate Sections of the Script. For example have a File for the Trader and one for the Mission Spawns. If you do it like that it is more likely to not let a vehicle out but you would need to execute both scripts in the spawn scripts of epoch but only the the script for the mission in the actual script for the mission spawned vehicle.
 
Hey man, thx for the reply.

I've figured as much that the script wsn't called, the trader runs fine, it spawns without ammo from trader. I just caouldn't figure out where to execute the script. Here's the sqf file that spawns the vehicle.
/********************************************************************************************
Usage: | [classname,position,(boolean),(direction)] call custom_publish;
Parameters | classname: Class or array of classnames of vehicle to spawn
in brackets | position: Position to spawn vehicle
are optional | boolean: true, or false by default to spawn vehicle static at position
| direction: Direction to face vehicle, random by default
/********************************************************************************************/
if (isServer) then {

private ["_hit","_classnames","_count","_vehpos","_max_distance","_vehicle","_position_fixed","_position","_dir","_class","_dam","_damage","_hitpoints","_selection","_fuel","_key"];

_count = count _this;
_classnames = _this select 0;
_position = _this select 1;
_max_distance = 35;
_vehpos = [];

if (typeName(_classnames) == "ARRAY") then {
_class = _classnames call BIS_fnc_selectRandom;
} else {
_class = _classnames;
};

if(_count > 2) then {

_position_fixed = _this select 2;

if(_count > 3) then {
_dir = _this select 3;
} else {
_dir = floor(round(random 360));
};

} else {
_position_fixed = false;
_dir = floor(round(random 360));
};

if (!_position_fixed) then {
while{count _vehpos < 1} do {
_vehpos = _position findEmptyPosition[10,_max_distance,_class];
_max_distance = (_max_distance + 15);
};
} else {
_vehpos = _position;
};

_vehicle = createVehicle [_class,_vehpos,[],5,"FORM"];
_vehicle setDir _dir;
_vehicle setVectorUp surfaceNormal position _vehicle;
_vehicle setvelocity [0,0,1];

_vehicle setVariable ["ObjectID","1",true];
_vehicle setVariable ["CharacterID","0",true];

clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;

_fuel = 0;

if (getNumber(configFile >> "CfgVehicles" >> _class >> "isBicycle") != 1) then {

_damage = (wai_vehicle_damage select 0) / 100;
_vehicle setDamage _damage;
_hitpoints = _vehicle call vehicle_getHitpoints;

{

_dam = ((wai_vehicle_damage select 0) + random((wai_vehicle_damage select 1) - (wai_vehicle_damage select 0))) / 100;
_selection = getText(configFile >> "cfgVehicles" >> _class >> "HitPoints" >> _x >> "name");

if ((_selection in dayZ_explosiveParts) && _dam > 0.8) then {
_dam = 0.8
};

_hit = [_vehicle,_selection,_dam] call object_setHitServer;

} count _hitpoints;

_fuel = ((wai_mission_fuel select 0) + random((wai_mission_fuel select 1) - (wai_mission_fuel select 0))) / 100;;

};

if(debug_mode) then { diag_log("WAI: Spawned " +str(_class) + " at " + str(_position) + " with " + str(_fuel) + " fuel and " + str(_damage) + " damage."); };

_vehicle setFuel _fuel;
_vehicle addeventhandler ["HandleDamage",{ _this call vehicle_handleDamage } ];

PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_vehicle];

if(wai_keep_vehicles) then {

_vehicle addEventHandler ["GetIn", {
_vehicle = _this select 0;
if(debug_mode) then { diag_log ("PUBLISH: Attempt " + str(_vehicle)); };

_class = typeOf _vehicle;
_characterID = _vehicle getVariable ["CharacterID", "0"];
_worldspace = [getDir _vehicle, getPosATL _vehicle];
_hitpoints = _vehicle call vehicle_getHitpoints;
_damage = damage _vehicle;
_array = [];

{
_hit = [_vehicle,_x] call object_getHit;
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _x >> "name");
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
} count _hitpoints;

_fuel = fuel _vehicle;
_uid = _worldspace call dayz_objectUID2;

_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance,_class,_damage,_characterID,_worldspace,[],_array,_fuel,_uid];

if(debug_mode) then { diag_log ("HIVE: WRITE: "+ str(_key)); };

_key call server_hiveWrite;

[_vehicle,_uid,_fuel,_damage,_array,_characterID,_class] call {

private["_vehicle","_uid","_fuel","_damage","_array","_characterID","_done","_retry","_key","_result","_outcome","_oid","_class"];

_vehicle = _this select 0;
_uid = _this select 1;
_fuel = _this select 2;
_damage = _this select 3;
_array = _this select 4;
_characterID = _this select 5;
_class = _this select 6;
_done = false;

while {!_done} do {
_key = format["CHILD:388:%1:",_uid];
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;

waitUntil {!isNil "_outcome"};

if(debug_mode) then { diag_log ("HIVE: WRITE: "+ str(_key)); };

if(_outcome == "PASS") then {
_oid = _result select 1;
_vehicle setVariable ["ObjectID", _oid, true];
if(debug_mode) then { diag_log("CUSTOM: Selected " + str(_oid)); };
_done = true;
} else {
if(debug_mode) then { diag_log("CUSTOM: trying again to get id for: " + str(_uid)); };
_done = false;
};
};

if(!_done) then {
deleteVehicle _vehicle;
if(debug_mode) then { diag_log("CUSTOM: failed to get id for : " + str(_uid)); };
} else {
_vehicle setVariable ["lastUpdate",time];
};
};

_vehicle call fnc_veh_ResetEH;
PVDZE_veh_Init = _vehicle;

publicVariable "PVDZE_veh_Init";

if(debug_mode) then { diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid)); };
}];

};

_vehicle


};

The script is called from within the WAI Static AI spawn script at server start in default.sqf: ["T34",[4402.13,10516.8,0.00143433],true] call custom_publish;

The idea of seperating script sections was my idea as well, but i wanted to get it working first.

Thx for the help.
 
Try this ;):
/********************************************************************************************
Usage: | [classname,position,(boolean),(direction)] call custom_publish;
Parameters | classname: Class or array of classnames of vehicle to spawn
in brackets | position: Position to spawn vehicle
are optional | boolean: true, or false by default to spawn vehicle static at position
| direction: Direction to face vehicle, random by default
/********************************************************************************************/
if (isServer) then {

private ["_hit","_classnames","_count","_vehpos","_max_distance","_vehicle","_position_fixed","_position","_dir","_class","_dam","_damage","_hitpoints","_selection","_fuel","_key"];

_count = count _this;
_classnames = _this select 0;
_position = _this select 1;
_max_distance = 35;
_vehpos = [];

if (typeName(_classnames) == "ARRAY") then {
_class = _classnames call BIS_fnc_selectRandom;
} else {
_class = _classnames;
};

if(_count > 2) then {

_position_fixed = _this select 2;

if(_count > 3) then {
_dir = _this select 3;
} else {
_dir = floor(round(random 360));
};

} else {
_position_fixed = false;
_dir = floor(round(random 360));
};

if (!_position_fixed) then {
while{count _vehpos < 1} do {
_vehpos = _position findEmptyPosition[10,_max_distance,_class];
_max_distance = (_max_distance + 15);
};
} else {
_vehpos = _position;
};

_vehicle = createVehicle [_class,_vehpos,[],5,"FORM"];
_vehicle setDir _dir;
_vehicle setVectorUp surfaceNormal position _vehicle;
_vehicle setvelocity [0,0,1];

_vehicle setVariable ["ObjectID","1",true];
_vehicle setVariable ["CharacterID","0",true];

//Remove Weapon by SiothieGaming start
call fnc_remWepSG;
//Remove Weapon by SiothieGaming end

clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;

_fuel = 0;

if (getNumber(configFile >> "CfgVehicles" >> _class >> "isBicycle") != 1) then {

_damage = (wai_vehicle_damage select 0) / 100;
_vehicle setDamage _damage;
_hitpoints = _vehicle call vehicle_getHitpoints;

{

_dam = ((wai_vehicle_damage select 0) + random((wai_vehicle_damage select 1) - (wai_vehicle_damage select 0))) / 100;
_selection = getText(configFile >> "cfgVehicles" >> _class >> "HitPoints" >> _x >> "name");

if ((_selection in dayZ_explosiveParts) && _dam > 0.8) then {
_dam = 0.8
};

_hit = [_vehicle,_selection,_dam] call object_setHitServer;

} count _hitpoints;

_fuel = ((wai_mission_fuel select 0) + random((wai_mission_fuel select 1) - (wai_mission_fuel select 0))) / 100;;

};

if(debug_mode) then { diag_log("WAI: Spawned " +str(_class) + " at " + str(_position) + " with " + str(_fuel) + " fuel and " + str(_damage) + " damage."); };

_vehicle setFuel _fuel;
_vehicle addeventhandler ["HandleDamage",{ _this call vehicle_handleDamage } ];

PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_vehicle];

if(wai_keep_vehicles) then {

_vehicle addEventHandler ["GetIn", {
_vehicle = _this select 0;
if(debug_mode) then { diag_log ("PUBLISH: Attempt " + str(_vehicle)); };

_class = typeOf _vehicle;
_characterID = _vehicle getVariable ["CharacterID", "0"];
_worldspace = [getDir _vehicle, getPosATL _vehicle];
_hitpoints = _vehicle call vehicle_getHitpoints;
_damage = damage _vehicle;
_array = [];

{
_hit = [_vehicle,_x] call object_getHit;
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _x >> "name");
if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
} count _hitpoints;

_fuel = fuel _vehicle;
_uid = _worldspace call dayz_objectUID2;

_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance,_class,_damage,_characterID,_worldspace,[],_array,_fuel,_uid];

if(debug_mode) then { diag_log ("HIVE: WRITE: "+ str(_key)); };

_key call server_hiveWrite;

[_vehicle,_uid,_fuel,_damage,_array,_characterID,_class] call {

private["_vehicle","_uid","_fuel","_damage","_array","_characterID","_done","_retry","_key","_result","_outcome","_oid","_class"];

_vehicle = _this select 0;
_uid = _this select 1;
_fuel = _this select 2;
_damage = _this select 3;
_array = _this select 4;
_characterID = _this select 5;
_class = _this select 6;
_done = false;

while {!_done} do {
_key = format["CHILD:388:%1:",_uid];
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;

waitUntil {!isNil "_outcome"};

if(debug_mode) then { diag_log ("HIVE: WRITE: "+ str(_key)); };

if(_outcome == "PASS") then {
_oid = _result select 1;
_vehicle setVariable ["ObjectID", _oid, true];
if(debug_mode) then { diag_log("CUSTOM: Selected " + str(_oid)); };
_done = true;
} else {
if(debug_mode) then { diag_log("CUSTOM: trying again to get id for: " + str(_uid)); };
_done = false;
};
};

if(!_done) then {
deleteVehicle _vehicle;
if(debug_mode) then { diag_log("CUSTOM: failed to get id for : " + str(_uid)); };
} else {
_vehicle setVariable ["lastUpdate",time];
};
};

_vehicle call fnc_veh_ResetEH;
PVDZE_veh_Init = _vehicle;

publicVariable "PVDZE_veh_Init";

if(debug_mode) then { diag_log ("PUBLISH: Created " + (_class) + " with ID " + str(_uid)); };
}];

};

_vehicle


};

Now it should work like a charm.
 
I hope you had good holidays, do you have any information whether it worked or not?
 
Hi there. I've just tried to apply this script, but nothing happens.
Am I wrong when I'm trying to change vehicles like this?
//an2
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "M240_veh";
};

//ArmoredSUV_PMC
if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

} forEach vehicles;
 
Hi there. I've just tried to apply this script, but nothing happens.
Am I wrong when I'm trying to change vehicles like this?
//an2
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "M240_veh";
};

//ArmoredSUV_PMC
if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

} forEach vehicles;
Just from the looks of it, it does seem right (I can't test it out atm though).
For Antonov, try this
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "M240";
};


For the Armored SUV, it could be the problem that the gun is not in the driver seat but in the gunner seat.
I am not completely sure whether you can remove the gun. I would have to check it for myself, but i can't do that for the next months.
Maybe posting your other files here, where you put the call of the script. So I can eliminate that as a potential problem.
 
I've solved this problem. Just should add additional brackets like this:
{

if (_object isKindOf "AN2_DZ") then {
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";
};

if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object removeMagazine "2000Rnd_762x51_M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

} forEach vehicles;

Works fine for me. But have 2 another questions:
1) This script is applying only for vehicles at spawns or from traders. Can I fix it somehow or not possible?
2) How could I change vehicle capacity? (e.g. UH1H has 50/25/5 slots, but I wanna change capacity to 250/50/10)
3) Am I able to disable vehicle radars using this script?
 
Last edited:
1) This script is applying only for vehicles at spawns or from traders. Can I fix it somehow or not possible?
You need to change your server_publishVehicle2.sqf and server_publishVehicle3.sqf for this, with the same code

2) How could I change vehicle capacity? (e.g. UH1H has 50/25/5 slots, but I wanna change capacity to 250/50/10)

No chance without make a comlete new mod

3) Am I able to disable vehicle radars using this script?

No, but there is a Script somewhere where they put a grey image above the radar, just search for it.
 
1) I have this file, it looks like this:
_uid = _worldspace call dayz_objectUID3;

// TODO: check if uid already exists && if so increment by 1 && check again as soon as we find nothing continue.

//Send request
_key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, 0 , _characterID, _worldspace, [], [], 1,_uid];
diag_log ("HIVE: WRITE: "+ str(_key));
_key call server_hiveWrite;

// Switched to spawn so we can wait a bit for the ID
[_object,_uid,_characterID,_class,_dir,_location,_donotusekey,_activatingPlayer] spawn {
private ["_object","_uid","_characterID","_done","_retry","_key","_result","_outcome","_oid","_class","_location","_object_para","_donotusekey","_activatingPlayer"];

_object = _this select 0;
_uid = _this select 1;
_characterID = _this select 2;
_class = _this select 3;
//_dir = _this select 4;
_location = _this select 5;
_donotusekey = _this select 6;
_activatingPlayer = _this select 7;

_done = false;
_retry = 0;
// TODO: Needs major overhaul for 1.1
while {_retry < 10} do {

sleep 1;
// GET DB ID
_key = format["CHILD:388:%1:",_uid];
diag_log ("HIVE: WRITE: "+ str(_key));
_result = _key call server_hiveReadWrite;
_outcome = _result select 0;
if (_outcome == "PASS") then {
_oid = _result select 1;
//_object setVariable ["ObjectID", _oid, true];
diag_log("CUSTOM: Selected " + str(_oid));
_done = true;
_retry = 100;

} else {
diag_log("CUSTOM: trying again to get id for: " + str(_uid));
_done = false;
_retry = _retry + 1;
};
};

// Remove marker
deleteVehicle _object;

if(!_done) exitWith { diag_log("CUSTOM: failed to get id for : " + str(_uid)); };

if(DZE_TRADER_SPAWNMODE) then {
_object_para = createVehicle ["ParachuteMediumWest", [0,0,0], [], 0, "CAN_COLLIDE"];
_object_para setPos [_location select 0, _location select 1,(_location select 2) + 65];
_object = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
} else {
_object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
};

if(!_donotusekey) then {
// Lock vehicle
_object setvehiclelock "locked";
};
//Remove Weapon by SiothieGaming start
call fnc_remWepSG;
//Remove Weapon by SiothieGaming end
clearWeaponCargoGlobal _object;
clearMagazineCargoGlobal _object;
// _object setVehicleAmmo DZE_vehicleAmmo;

_object setVariable ["ObjectID", _oid, true];

_object setVariable ["lastUpdate",time];

_object setVariable ["CharacterID", _characterID, true];

if(DZE_TRADER_SPAWNMODE) then {
_object attachTo [_object_para, [0,0,-1.6]];
sleep 1.0;
WaitUntil{(([_object] call FNC_GetPos) select 2) < 0.1};
detach _object;
deleteVehicle _object_para;
};

PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];

_object call fnc_veh_ResetEH;

// for non JIP users this should make sure everyone has eventhandlers for vehicles.
PVDZE_veh_Init = _object;
publicVariable "PVDZE_veh_Init";

diag_log ("PUBLISH: " + str(_activatingPlayer) + " Bought " + (_class) + " with ID " + str(_uid));
};
I should insert this
{

if (_object isKindOf "AN2_DZ") then {
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";
};

if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object removeMagazine "2000Rnd_762x51_M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

} forEach vehicles;
inside this file and server_publishVehicle3.sqf and problem will be solved?

2) New mod? May I create a new .pbo file and change vehicle capacity/add new weapons/new skins/etc? Or it's a stupid idea?
 
yeah put it under:

Code:
_object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
};

and just use this:
Code:
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";
};

if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object removeMagazine "2000Rnd_762x51_M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

the foreach Vehicle is not necessary here

===========================

You dont have to make new pbo, you could just change the config which is already in the dayz_code; Problem if you do this, everybody who wants to play on your server will have to have this exact same dayz_code.pbo (all clients and the server)
No problem for a server only for your friends and yourself, bad for a public server ;)
 
Exactly! Also, if I'll change server's dayz_code.pbo, I will lose file signature. I really don't wanna edit something in dayz_code, only one thing I have - make a new pbo with my own stuff.
 
never change something in the dayz_code!
If you do so then make sure every client have this addon, otherwise it become a pretty damn mess ^^
 
Yeah. Thats why only one thing left - making new pbo file and attaching it to server mode.
 
Vehicles still have no changed weapons. Got this:
_object = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"];
};
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";
};

if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object removeMagazine "2000Rnd_762x51_M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

But dunno how to add this function for server_publishVehicle3. For now it has a look like this:
_newobject = createVehicle [_class, [0,0,0], [], 0, "CAN_COLLIDE"];
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";
};

if (_object isKindOf "ArmoredSUV_PMC_DZE") then {
_object removeWeapon "M134";
_object removeMagazine "2000Rnd_762x51_M134";
_object addWeapon "PKT";
_object addMagazine "100Rnd_762x54_PK";
};

When I'm spawning vehicle, AN2 has no weapon and SUV has his own M134.
 
Back
Top