djdan9741 11 Posted April 20, 2020 Hello, I would like know how i can detect when a player drop an item for delete it. I have try with "addEventHandler Put" but the return of item is type string and DeleteVehicle use type object.. Thank you! (Sorry for my bad english) Share this post Link to post Share on other sites
Larrow 2820 Posted April 21, 2020 19 hours ago, djdan9741 said: I have try with "addEventHandler Put" but the return of item is type string and DeleteVehicle use type object.. An item is not an OBJECT so deleteVehicle will not work anyway. player addEventHandler[ "Put", { params[ "_unit", "_container", "_item" ]; //Only if its dropped on the floor AND is an item if ( { _container isKindOf _x }count [ "weaponHolder", "weaponHolderSimulated" ] > 0 && { _item isKindOf[ "ItemCore", configFile >> "CfgWeapons" ] } ) then { //Get item contents of weaponHolder _itemContents = itemCargo _container call BIS_fnc_consolidateArray; //Find the dropped item type in contents _index = _itemContents findIf{ _x select 0 == _item }; //Remove 1 from items count _itemContents select _index set[ 1, ( _itemContents select _index select 1 ) - 1 ]; //Clear container of all items clearItemCargoGlobal _container; //Add back modified contents { _container addItemCargoGlobal _x; }forEach _itemContents; }; }]; 3 1 Share this post Link to post Share on other sites
djdan9741 11 Posted April 21, 2020 2 hours ago, Larrow said: An item is not an OBJECT so deleteVehicle will not work anyway. player addEventHandler[ "Put", { params[ "_unit", "_container", "_item" ]; //Only if its dropped on the floor AND is an item if ( { _container isKindOf _x }count [ "weaponHolder", "weaponHolderSimulated" ] > 0 && { _item isKindOf[ "ItemCore", configFile >> "CfgWeapons" ] } ) then { //Get item contents of weaponHolder _itemContents = itemCargo _container call BIS_fnc_consolidateArray; //Find the dropped item type in contents _index = _itemContents findIf{ _x select 0 == _item }; //Remove 1 from items count _itemContents select _index set[ 1, ( _itemContents select _index select 1 ) - 1 ]; //Clear container of all items clearItemCargoGlobal _container; //Add back modified contents { _container addItemCargoGlobal _x; }forEach _itemContents; }; }]; Thank you for your answer, I have try your script but it does not work. I have this error: Incorrect number in expression. Share this post Link to post Share on other sites
Larrow 2820 Posted April 22, 2020 23 hours ago, djdan9741 said: I have try your script but it does not work. Code works fine as I tested it before posting. Check what you have copied has no hidden characters( known forum bug ) OR rewrite it from scratch. Share this post Link to post Share on other sites
Mathieu Trudel 0 Posted November 17, 2020 On 4/21/2020 at 9:22 AM, Larrow said: An item is not an OBJECT so deleteVehicle will not work anyway. player addEventHandler[ "Put", { params[ "_unit", "_container", "_item" ]; //Only if its dropped on the floor AND is an item if ( { _container isKindOf _x }count [ "weaponHolder", "weaponHolderSimulated" ] > 0 && { _item isKindOf[ "ItemCore", configFile >> "CfgWeapons" ] } ) then { //Get item contents of weaponHolder _itemContents = itemCargo _container call BIS_fnc_consolidateArray; //Find the dropped item type in contents _index = _itemContents findIf{ _x select 0 == _item }; //Remove 1 from items count _itemContents select _index set[ 1, ( _itemContents select _index select 1 ) - 1 ]; //Clear container of all items clearItemCargoGlobal _container; //Add back modified contents { _container addItemCargoGlobal _x; }forEach _itemContents; }; }]; nice code ; thx !! question were do I put this ?? in the Init of the player ? or in the mission folder?? I have tried in the init of player, I take gear form a box and it still drop it on the floor .... Help plz Share this post Link to post Share on other sites
razzored 37 Posted November 19, 2020 I'd recommend making an "initPlayerLocal.sqf". However, if the mission includes respawning, you might want to use "OnPlayerRespawn.sqf" instead. 1 Share this post Link to post Share on other sites
brotherreaper 12 Posted September 28, 2021 Can I save this as an sqf file and add it to my init.sqf file and execVM ? 1 Share this post Link to post Share on other sites
ZaellixA 383 Posted September 28, 2021 Yes, but this would work well on single player. In case you intend to use it for multiplayer too it could prove beneficial to use/run it inside an initPlayerLocal.sqf like razzored suggested. 1 Share this post Link to post Share on other sites