Powershard 2 Posted March 21, 2017 Hello! I want to add an action to all corpses in the map, but apply it only once. I have a trigger that adds addAction to all corpses every second, but the problem is that it creates duplicate entries. Is there some easy way I can mark these corpses so that they will be ignored for addAction in further triggers? Some IF sentence or something? Here is the code I have been using in my trigger: { _x addAction["Loot","Cash150.sqf","",0,false,false,"",'(alive player) && player distance _target < 3'];} forEach allDeadMen; Share this post Link to post Share on other sites
beno_83au 1369 Posted March 21, 2017 Use a "Killed" event handler, and add the code using that. This way it'll only need to run once per unit when they die and not once per second for all dead units. https://community.bistudio.com/wiki/addEventHandler If it's an MP mission then https://community.bistudio.com/wiki/addMPEventHandler and "MPKilled" might be what you need. Share this post Link to post Share on other sites
Powershard 2 Posted March 21, 2017 I will give it a shot, thank you :) I am using Zeus and it needs to be something that updates automatically for even Zeus spawned units that which then die and leave a corpse after them, the corpse gains an addAction button. It is for multiplayer with players vs AI. We got zombies and demons and bunch of other addons so I hope it works with all "kills". I might need a trigger still though, as I have same problem with objects, not only corpses. { _x addAction ["Loot!", "Cash150.sqf"] } forEach (allMissionObjects "Land_Money_F"); So how could I make an eventhandler for that? Share this post Link to post Share on other sites
Powershard 2 Posted March 21, 2017 (edited) How could I make the eventhandler work? I used the following with no results: this addMPEventHandler ["mpkilled",{this addAction["Loot","Cash150.sqf","",0,false,false,"",'(alive player) && player distance _target < 3'];}] The goal is to make the corpse have an addAction button for "looting" it for money. Isn't the event "mpkilled" made to be run on the event of kill, thus while target was alive, not when it is dead corpse? Just wondering since I get no addAction result. What if I wanted to make this same effect for vehicles, destroying a vehicle would give it's wreckage an addAction as well? To me it would seem to be simpler if I had 1 trigger running every 1 second and it scans for certains Objects, Wreckages and Corpses and applies their corresponding addActions to them. Edited March 21, 2017 by Powershard additions Share this post Link to post Share on other sites
Powershard 2 Posted March 22, 2017 I have made a workaround which I am satisfied with. Only downside is the momentary flickering of the text but since I got no solution from here I got to go with it. It seems to work fine in multiplayer Zeus and zombie addon. Here is the code for others use if it can help. What it does is index all dead men and land_money_F objects, remove their added addActions if any any refresh a new addAction. I made a trigger named Money Generator Condition: MoneyGenerator; Activation: MoneyGenerator=false; { removeAllActions _x; _x addAction["<img image='HG\UI\money.paa' size='1.5'/><t color='#ED28EA'>Loot! </t>","Cash150.sqf","",6,true,false,"",' player distance _target < 1']} forEach allDeadMen; { removeAllActions _x; _x addAction["<img image='HG\UI\money.paa' size='1.5'/><t color='#ED28EA'>Loot! </t>","Cash150.sqf","",6,true,false,"",' player distance _target < 2']} forEach (allMissionObjects "Land_Money_F");Deactivation: MoneyGenerator=true; TimeOut: 3,3,3 Cash150.sqf contains: smallMoney = round(random [0, 8, 12]); //money generator [smallmoney,0] call HG_fnc_addOrSubCash; //adds money using addon functionality TitleText [format ["You found $%1", smallMoney], "Plain down"]; //tells how much was randomly generated _object = _this select 0; deletevehicle _object; //deletes manipulated object, be it corpse or pile of cash playSound "cashClass"; //adds my own sound file for looting money init.sqf contains: MoneyGenerator=true; //to enable the trigger above Share this post Link to post Share on other sites
Deadth 1 Posted March 22, 2017 I wish I knew more about scripting so I could help. I've built simple missions in the editor before but nothing too complicated. Share this post Link to post Share on other sites