Spaxxow 11 Posted October 25, 2017 I feel like this is simple but I cannot find it. I just want to know how to set a trigger to go off any time an independent unit is killed. Share this post Link to post Share on other sites
HazJ 1289 Posted October 25, 2017 In the init of Independent unit(s): this addEventHandler ["Killed", {}]; Your code goes inside the {} brackets. { if ((side _x isEqualTo independent)) then { _x addEventHandler ["Killed", { _unit = param [0, objNull]; if ((isNull _unit)) exitWith {}; hintSilent "An Independent unit has been killed."; }]; }; } forEach allUnits; Can't remember if side command returns correct side when killed. I think it does. If not, you can use the BIS function objectSide or something. Can't check now as Wiki is down, still! :( Share this post Link to post Share on other sites
pierremgi 4850 Posted October 25, 2017 I'd rather write in initServer.sqf addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then { "you ve just killed an independant!" remoteExec ["hint", _instigator]; } }]; - compatible with spawned units, - check the native side of the killed unit (doesn't work if you intend to change the unit's side). - fire on player's shot only. If you need to take into account AI lills, just remove the isPlayer condition. On 24/10/2017 at 4:56 PM, HazJ said: Can't remember if side command returns correct side when killed. I think it does. If not, you can use the BIS function objectSide or something. Can't check now as Wiki is down, still! :( No, always civilian. Not really bad while you're adding your EH when the unit is still alive. More problematic: your allUnits is not updated. 1 Share this post Link to post Share on other sites
HazJ 1289 Posted October 25, 2017 Yeah... Use ^ method. Good work! Share this post Link to post Share on other sites
Spaxxow 11 Posted January 27, 2018 Sorry for the late reply I will test this out and let you guys know how it goes. And just curious...forgot where I was going with that. Share this post Link to post Share on other sites
Spaxxow 11 Posted January 27, 2018 On 10/24/2017 at 8:28 PM, pierremgi said: addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then { "you ve just killed an independant!" remoteExec ["hint", _instigator]; } }]; So awesome it triggered. But how do I attach this to an ingame trigger. So pretty much the ingame (TRIGGER:A) is functioned to (Add $100,000 to Command Post 1) so every time one of my guys kill an enemy the command post gets money. And the other thing is how do I apply this to BLUFOR so I can deduct money every time we lose a unit? Help is much appreciated. Share this post Link to post Share on other sites
Spaxxow 11 Posted January 27, 2018 Right now this private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; Is the line I have in the deactivation trigger. What I need is to connect another trigger to the line of script you guys gave me. The trigger that needs to be connected will have this line private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; It'll be set on repeatable so everytime the enemy is downed we get $100,000 The other one that'll be connected will have the line private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 100000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 100000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 100000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; So everytime a friendly dies it will deduct $100,000. fac1,fac2,fac3 are the Mobile Command Vehicles in which the funds are added. Share this post Link to post Share on other sites
pierremgi 4850 Posted January 27, 2018 4 hours ago, Spaxxow said: So awesome it triggered. But how do I attach this to an ingame trigger. So pretty much the ingame (TRIGGER:A) is functioned to (Add $100,000 to Command Post 1) so every time one of my guys kill an enemy the command post gets money. And the other thing is how do I apply this to BLUFOR so I can deduct money every time we lose a unit? Help is much appreciated. Trigger?? You don't need any trigger. You have an event handler, waiting for an event (a kill). You can add any condition you need in the code (like native side or inAera or distance from something, even timer... Share this post Link to post Share on other sites
Spaxxow 11 Posted January 28, 2018 7 hours ago, pierremgi said: Trigger?? You don't need any trigger. You have an event handler, waiting for an event (a kill). You can add any condition you need in the code (like native side or inAera or distance from something, even timer... I'm saying the triggers are already in the game and I need either a way to fire them with this On 10/24/2017 at 8:28 PM, pierremgi said: addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then { "you ve just killed an independant!" remoteExec ["hint", _instigator]; } }]; or have the line that is in that trigger activated in place of "you've killed an independent" Share this post Link to post Share on other sites
Spaxxow 11 Posted January 28, 2018 Ok I have made progress. addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then {private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; } }]; Problem now is with every kill it adds 3.2 Million Dollars lol We are out here shooting millionaires. Share this post Link to post Share on other sites
Spaxxow 11 Posted January 28, 2018 6 minutes ago, Spaxxow said: Ok I have made progress. addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then {private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; } }]; Problem now is with every kill it adds 3.2 Million Dollars lol We are out here shooting millionaires. Fixed it. I took it out of the trigger and put it back in the init 1 Share this post Link to post Share on other sites
Spaxxow 11 Posted January 28, 2018 All problems have been worked out. Thank you guys so much for your help. Keep doing great things. -King Mike Share this post Link to post Share on other sites
Spaxxow 11 Posted January 29, 2018 22 hours ago, Spaxxow said: All problems have been worked out. Thank you guys so much for your help. Keep doing great things. -King Mike I take it back. So my secondary goal for this was to pressure my soldiers to operate with the most precision possible. They let there AI die way too much. Right now they're currently under the impression that if they lose a soldier there will be a $250000 penalty on all MCVs. So when I was testing to see if the script worked I was lining up these units from each faction and shooting them to see if it would input or deduct the funds, in which it did. But I didn't test to see if AI killing AI had that effect. It doesn't. addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then {private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits + 100000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; } }]; addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 3) then {private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 500000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 500000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 500000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; } }]; addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (isPlayer _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 1) then {private ["_credits"]; _credits = fac1 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 250000; fac1 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac2 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 250000; fac2 setVariable ["R3F_LOG_CF_credits", _credits, true]; private ["_credits"]; _credits = fac3 getVariable "R3F_LOG_CF_credits"; _credits = _credits - 250000; fac3 setVariable ["R3F_LOG_CF_credits", _credits, true]; } }]; This is what I have for now. I'm not gonna tell them that it doesn't actually work. I'm going to be working on it throughout the night but I'm sure it has something to do with the 23 hours ago, Spaxxow said: params ["_killed","_killer","_instigator"]; if (isPlayer _instigator Part. So I'm gonna try and find something to replace isplayer. Sorry I'm not that good at this scripting thing. Share this post Link to post Share on other sites
lordfrith 401 Posted January 31, 2018 the if(isPlayer _instigator) line will exclude all non player kills. you could use the technique you're using to check the side of "_killed" and check also the side of "_killer" so it would count kills by side rather than player? Share this post Link to post Share on other sites
Spaxxow 11 Posted January 31, 2018 13 hours ago, lordfrith said: the if(isPlayer _instigator) line will exclude all non player kills. you could use the technique you're using to check the side of "_killed" and check also the side of "_killer" so it would count kills by side rather than player? Yeah I could give that a try to. Because like I said I want them to be able to support their AI counterparts. So how would I go about doing that? Share this post Link to post Share on other sites
lordfrith 401 Posted February 1, 2018 i think it should be _instigator instead of _killer, my mixup, but anyway something like: On 1/29/2018 at 7:23 AM, Spaxxow said: if (getNumber (configFile >> "cfgVehicles" >> typeOf _instigator >> "side") == 1 && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) can you not just check the side of _instigator the same as _killed? or Quote if ((isPlayer _instigator or _instigator in units group player) && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) if you have other stuff going on that you don't want to be getting paid for. untested and all that ;) Share this post Link to post Share on other sites
Spaxxow 11 Posted February 9, 2018 addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if ((isPlayer _instigator or _instigator in units group player) && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then { "you ve just killed an independant!" remoteExec ["hint", _instigator]; } }]; addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (getNumber (configFile >> "cfgVehicles" >> typeOf _instigator >> "side") == 1 && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then { "you ve just killed an independant!" remoteExec ["hint", _instigator]; } }]; Neither Seemed to work Share this post Link to post Share on other sites
pierremgi 4850 Posted February 9, 2018 Wait... An Event Handler EH or Mission EH in this case, is a command running where the code is. I you place it in initserver.sqf, it will run on server only. The code is always local, except for specific MPEH MPHit MPKilled or MPRespawn. Then you can remoteExec the code (like in example). And that works. You can also avoid the remoteExecution and its network traffic, just executing this command on each PC. As you don't want to treat all players as instigators of the crime, you need to identify him. So you place the MEH in init.sqf and change a little bit the code for: addMissionEventHandler ["entityKilled", { params ["_killed","_killer","_instigator"]; if (local _instigator && getNumber (configFile >> "cfgVehicles" >> typeOf _killed >> "side") == 2) then { "you ve just killed an independant!" remoteExec ["hint", _instigator]; } }]; Nothing more. I skipped the fact the instigator is a player. You don't need to specify it for MP dedicated mission because player is responsible only for his AI group (as leader). If you're on hosted, the player on server is also local with all server AIs. So, in this case you need to add a isplayer condition... or group . 2 Share this post Link to post Share on other sites