gitanoiwan 0 Posted April 21, 2021 Hi all, I picked up 8 objects all named obj1 ....... obj8 , and need to bring them to a certain place on the map. I put down a trigger and call this one tr1, this trigger needs to activate when all objects i picked up are are droped from inventory in this area. wrote it like this : Condition : obj1 inArea tr1 && obj2 inArea tr1 && obj3 inArea tr1 && obj4 inArea tr1 && obj5 inArea tr1 && obj6 inArea tr1 && obj7 inArea tr1 && obj8 inArea tr1 On Act.: hint "it works" but it doesn't seems to work, does someone have an idea what i did wrong? Share this post Link to post Share on other sites
pierremgi 4850 Posted April 21, 2021 That's normal. When you name an object (placed on ground like: item_keys), you place an item with "keys" as magazine (cargo). You can name it obj1 . When you pick these keys, you add a magazine "keys" in your inventory and delete the item_keys on ground. So, your former variable name, say obj1 refers to a item_keys which becomes a null object as soon as you pick the keys.... (isNull obj1 is TRUE) When you put this magazine on ground, so the keys, you create a groundWeaponHolder (nothing to do with the former item_keys), and add a magazine "keys" inside. The workaround is not easy. - you can decide to drop the names of objects and just count magazines of some types inside their containers inside the trigger.... - or name the objects and rename the dropped ones like in this code (single player): player addEventHandler ["Take", { params ["_unit", "_container", "_item"]; if (isNil {_unit getVariable "specificItems"}) then { _unit setVariable ["specificItems",[]] }; if (_container in [obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8] ) then { (_unit getVariable ["specificItems",[]]) pushBack [_item,str _container] }; }]; player addEventHandler ["put",{ params ["_unit", "_container", "_item"]; if (!isNil {_unit getVariable "specificItems"}) then { _idx = ((_unit getVariable "specificItems") apply {_x #0}) find _item; if (_idx > -1) then { _name = (_unit getVariable "specificItems") #_idx #1; _container setVehicleVarName _name; missionNameSpace setVariable [_name, _container]; (_unit getVariable "specificItems") deleteAt _idx } } }]; Now, you can use the code with object names in your trigger: [obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8] findIf {!(_x inArea tr1)} == -1 1 Share this post Link to post Share on other sites
gitanoiwan 0 Posted April 22, 2021 I used 4 Kostey's map case, 2 Kostey's notebook , 1 Kostey's photo, and 1 laptop. Isn't there a way to use there class name in the trigger to fire it ? or make them ACE object so they don't die on me if I pick them up ? Share this post Link to post Share on other sites
pierremgi 4850 Posted April 22, 2021 My script manages a variable on player, made of: [type of object, name of container (so the object) as string (because the object itself becomes null] Example: picking obj5 then obj2 then obj4 creates this variable array on player: [["keys","obj5"], ["Laptop_Closed","obj2"], ["keys","obj4"]...] along with types of objects and picked (named) objects. No matter the object/type you picked, but its variable name must be in [obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8] (that's your demand). So, putting the objects on ground, say a laptop then keys then other keys... will add names: obj2 on dropped laptop, obj5 on first dropped keys, obj4 on 2nd dropped keys and so on. If these dropped objects are in area of the trigger, the condition (above) will fire the trigger if all 8 objects are in this area. >> The script I wrote works fine, in SP, if you don't need to make difference between 1st, 2nd,3rd, 4th Kostey's map cases, and so on, because the first picked (pushed back in array) will be the first put on ground (find command). This script doesn't attribute a slot in inventory, then doesn't care for a difference between same object types in inventory. Class names are just string, so no problem for sorting objects by types, but that's all. ACE? I don't care. I don't understand: "they don't die on me if I pick them up" Share this post Link to post Share on other sites
gitanoiwan 0 Posted April 24, 2021 On 4/22/2021 at 9:39 AM, pierremgi said: My script manages a variable on player, made of: [type of object, name of container (so the object) as string (because the object itself becomes null] Example: picking obj5 then obj2 then obj4 creates this variable array on player: [["keys","obj5"], ["Laptop_Closed","obj2"], ["keys","obj4"]...] along with types of objects and picked (named) objects. No matter the object/type you picked, but its variable name must be in [obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8] (that's your demand). So, putting the objects on ground, say a laptop then keys then other keys... will add names: obj2 on dropped laptop, obj5 on first dropped keys, obj4 on 2nd dropped keys and so on. If these dropped objects are in area of the trigger, the condition (above) will fire the trigger if all 8 objects are in this area. >> The script I wrote works fine, in SP, if you don't need to make difference between 1st, 2nd,3rd, 4th Kostey's map cases, and so on, because the first picked (pushed back in array) will be the first put on ground (find command). This script doesn't attribute a slot in inventory, then doesn't care for a difference between same object types in inventory. Class names are just string, so no problem for sorting objects by types, but that's all. ACE? I don't care. I don't understand: "they don't die on me if I pick them up" I don't understand: "they don't die on me if I pick them up" i mean when i use a ace command like carry or something they don't disappear from the map so they keep the name obj1 , obj2 and so on i make a MP mission so it's not only one player that pick them up Share this post Link to post Share on other sites
pierremgi 4850 Posted April 24, 2021 14 hours ago, gitanoiwan said: i make a MP mission so it's not only one player that pick them up This kind of info should always be precised. The problem here, is when a player pick the object(s) on corpse of another player (or even AI). well... You need to create a initPlayerLocal.sqf if not yet existing, at root of your mission folder (where mission.sqm is). in initPlayerLocal.sqf: player addEventHandler ["Take", { params ["_unit", "_container", "_item"]; if (isNil {_unit getVariable "specificItems"}) then { _unit setVariable ["specificItems",[],TRUE] }; call { if (_container in [obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8]) exitWith { (_unit getVariable ["specificItems",[]]) pushBack [_item,str _container]; _unit setVariable ["specificItems",_unit getVariable "specificItems",TRUE]; }; private _idx = ((cursorObject getVariable ["specificItems",[["",""]]]) apply {_x#0}) find _item; if (_idx > -1) then { private _it = (cursorObject getVariable ["specificItems",[["",""]]]) deleteAt _idx; (_unit getVariable ["specificItems",[]]) pushBack _it; _unit setVariable ["specificItems",_unit getVariable "specificItems",TRUE]; }; }; }]; player addEventHandler ["put",{ params ["_unit", "_container", "_item"]; if (!isNil {_unit getVariable "specificItems"}) then { _idx = ((_unit getVariable "specificItems") apply {_x #0}) find _item; if (_idx > -1) then { _name = (_unit getVariable "specificItems") #_idx #1; [ _container,_name] remoteExec ["setVehicleVarName",0,TRUE]; missionNameSpace setVariable [_name, _container,TRUE]; (_unit getVariable "specificItems") deleteAt _idx; _unit setVariable ["specificItems",_unit getVariable "specificItems",TRUE]; } } }]; Notes: 1 - this code works for 8 objects named obj1.... obj8, formerly picked on ground (option1), then occasionally picked in inventory of another player (option2). 2 - picking on a corpse/unit (option2) only works if cursorObject (a BI command) returns the player/corpse who formerly picked the object(s). I.e. If you don't aim at the corpse while opening the inventory, this code will fail. (example: pointing at primary weapon of dead instead of corpse). Share this post Link to post Share on other sites