Page MenuHomeFeedback Tracker

weaponDisassembled event handler would be more useful if it provided a parameter pointing to the static weapon
New, WishlistPublic


I want to do the following things:

1- prevent some players from disassembling static weapons they are not allowed to disassemble (eg: the static weapon is assigned to other squads/players)

2- track weapon backpack status that is related to the status weapon by using setVariable command on it (eg: know if backpack still exists in a vehicle, an ammocrate on a dead/alive body)

I thought about using the weaponDisassembled event handler because it seems to be the only solution for what I want to do. Unfortunately it seems this event handler executes after the weapon is disassembled which means I cannot check if the player actually is allowed to disassemble this weapon (point 1). This also means I cannot have a 4th parameter provided by this EH with a reference to the weapon that is being disassembled. This would help me since I'm setting a variable on the static weapon to know what squad can use it. I would like to copy the variable on the weapon backpack (point 2).

I would like to know if there is any chance of having this 4th parameter added to the weaponDisassembled event handler and also preventing the weapon from being disassembled if false is returned by the code.


Legacy ID
Additional Information

Here are concrete suggestions for implementation of a solution:

WeaponAssembled => the return boolean determines whether the weapon is assembled or not

WeaponDisassembled => add reference to the weapon object (so I don't need to use cursorTarget workaround which is limited to human player and cannot work with AI soldier)

WeaponDisassembled => the return boolean determines whether the weapon is disassembled or not

Event Timeline

d3nn16 edited Steps To Reproduce. (Show Details)Mar 24 2014, 8:44 PM
d3nn16 edited Additional Information. (Show Details)
d3nn16 set Category to Scripting.
d3nn16 set Reproducibility to N/A.
d3nn16 set Severity to None.
d3nn16 set Resolution to Open.
d3nn16 set Legacy ID to 2544628946.May 7 2016, 6:16 PM

Absolutely agreed.

WeaponDisassembled EH should passed the disassembled weapon as 4th paramter.
This missing creates a potentiel bug in my project.

Would be great to cancel the weapon disassembly by returning false.
Or in a smarter way : to disable the disassembly feature by : weapon setVariable ["BIS_disable_weapon_disassembly", true]

The command cursorTarget can be used to get the disassembled weapon.
It works only for the local player. And this not a safe way to retrieve it.

To work also for units different from player, commands like nearestObject could also be used. But this is a very unsafe way.

BIS, please add this 4th parameter.

d3nn16 added a subscriber: d3nn16.May 7 2016, 6:16 PM

I tested the idea with the nearestObject command but it returned objNull. I bet the cursorTarget command will return the same (haven't tested). From this I deduce that the event handler triggers after the weapon is disassembled (after the weapon object is removed and replaced with backpacks).

I deduce that the event handler triggers after the weapon is disassembled

No, I thought too before testing it. But I succeed to retrieve the dismounted weapon with cursorTarget.
Maybe the near* commands don't work (too slow ?).

A simple script command like "disableWeaponDisassembly" would be the most appropriate. Global effect, of course.

The cursorTarget command can be used only if players disassemble the static weapon (missions with AI disabled). In a mission with AIs I can cheat by ordering an AI to disassemble the weapon since cursorTarget applies to player unit and will return objNull.

Bohemia added a subscriber: Bohemia.May 7 2016, 6:16 PM

@d3nn16 - could you share the code for your cursorTarget workaround? :)

if (not isDedicated) then
waitUntil {not isNil "ZCM_PLAYER_IS_DEFINED"};


// track backpacks when disassembling static weapons
player addEventHandler

			(_this select 1) setVariable ["zgp_vehicle_group", cursorTarget getVariable ["zgp_vehicle_group", grpNull], true];


This will update the weapon backpack object by adding a variable to it that tells the group of the player who disassembled it.

WeaponDisassembled and cursorTarget in R3F Logistics :

player addEventHandler ["WeaponDisassembled",

				private ["_objet"];
				_objet = cursorTarget;
				if (!isNull _objet && {!isNull (_objet getVariable ["R3F_LOG_est_deplace_par", objNull])}) then
					_objet setVariable ["R3F_LOG_est_deplace_par", objNull, true];

Upvoted - we need what have been suggested here. I just did more tests, the original object reference is NOT objNull after the weapon is disassembled eg. _my50="B_HMG_01_F" createVehicle pos; The getPos on _my50 after it has been disassembled is a position on altis in the sea, so a workaround to get the reference to the weapon that was disassembled could be to check the cords against the sea pos, it should be safe as a weapon cannot be assembled in the sea, maybe that is why the sea cords was used? Anyway you can still get info on ammo and magazines on _my50 after its been disassembled. So _isDisassembled = surfaceIsWater (position _my50); used together with the EventHandler you can find out what weapon was just disassembled. Other info that could be useful is that if you do player moveInGunner _my50 (when disassembled) will put the 50 cal back where is was dismantled although bugged.

d3nn16 removed a subscriber: d3nn16.Dec 21 2020, 2:11 PM