Laerte Leite 1 Posted May 12, 2018 Hi guys. Iam new in this scripting world.So i making a mission TvT who the Cops are responsable to discover who are the shooter who kills the president.So i am thinking if some way i can check which player shots the president using a gunshot residue kit or something and how i make this thanks Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 Killed EH? You could assign it to global variable if needed later on. https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed Quote unit: Object - Object the event handler is assigned to killer: Object - Object that killed the unit. Contains the unit itself in case of collisions 1.65 instigator: Object - Person who pulled the trigger 1.67 useEffects: Boolean - same as useEffects in setDamage alt syntax Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 12, 2018 @HazJReally i want check if the player actually shot in the last minutes Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 Shot dead or just injured shot? You could use Hit EH (or Killed EH if you want shot to death). Use setVariable and store nested array. Something like: player addEventHandler ["Hit", { params ["_unit", "_source", "_damage", "_instigator"]; if (_damage > 0.1) then { _unit setVariable ["injuryReport", [_unit, _instigator, _damage, time], true]; }; }]; hintSilent format [":: %1 %2", player getVariable "injuryReport", (time > (player getVariable "injuryReport" select 3) + 10)]; // 10 seconds... systemChat format ["%1 was injured by %2 (%3 damage delt) %4 seconds ago.", (name (player getVariable "injuryReport" select 0)), (name (player getVariable "injuryReport" select 1)), (player getVariable "injuryReport" select 2), (player getVariable "injuryReport" select 3)]; Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 12, 2018 @HazJ I do not want to know if the shot is fatal or not what I want to know is the player fired with his gun or not Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 What you want and what you get are two different things, lol. I gave you working code. Adapt it to your needs. It is pretty much the same thing except: You don't need the nested array. Just use setVariable + time. Change Hit EH to Fired EH. https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Fired Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 12, 2018 Sorry if sound arrogant thanks for script Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 12, 2018 @HazJWhere i put this code on init ? Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 No problem. All good. This is the part for setVariable which should help. The rest is easy. You can find it on the link I provided. _unit setVariable ["injuryReport", time, true]; You can put it in init.sqf: // from the link I gave you... player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; }]; Inside the event handler... After params add the setVariable code above. Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 12, 2018 @HazJ i tried this one player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; { _unit setVariable ["injuryReport", time, true]; }; }]; hintSilent format [":: %1 %2", player getVariable "injuryReport", (time > (player getVariable "injuryReport" select 3) + 10)]; // 10 seconds... systemChat format ["%1 was injured by %2 (%3 damage delt) %4 seconds ago.", (name (player getVariable "injuryReport" select 0)), (name (player getVariable "injuryReport" select 1)), (player getVariable "injuryReport" select 2), (player getVariable "injuryReport" select 3)]; But the hint apears a error called "bolean" Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 First off. Let me correct my mistake from earlier post of mine. There was no nested array, just normal array. No need for select as no longer an array. hintSilent format [":: %1 %2", player getVariable "injuryReport", (time > (player getVariable "injuryReport") + 10)]; Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 12, 2018 @HazJCan you send me a example of init.sqf with the script Share this post Link to post Share on other sites
Cigs4 18 Posted May 12, 2018 Hello Hajz, It's not working for me either... Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 init.sqf way: player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; _unit setVariable ["injuryReport", time, true]; }]; To check: hintSilent format [":: Was %1 injured more than 10 seconds ago? %2", (name player), (time > (player getVariable "injuryReport") + 10)]; Use this where-ever needed. Share this post Link to post Share on other sites
HazJ 1289 Posted May 12, 2018 Okay. Tested: player addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; _unit setVariable ["injuryReport", (round time), true]; }]; hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name player), (time - (player getVariable "injuryReport"))]; You may want to round the number like so: hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name player), (round (time - (player getVariable "injuryReport")))]; This will work for player. For AI, you'll need to add EH to them as well. Only when they fire their weapon. It will create setVariable on them. Which you can retrieve anywhere. See above code for that. It may be a good idea to set a default as well. Like so: hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name player), (time - (player getVariable ["injuryReport", -1]]))]; hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name player), (round (time - (player getVariable ["injuryReport", -1]])))]; Not tested round or getVariable alt syntax (default value) since I added that here in post afterwards. It should work though. I've used it before in my projects, etc just fine. 2 Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 13, 2018 @HazJ I can call the hint with a addaction on the player ? Share this post Link to post Share on other sites
HazJ 1289 Posted May 13, 2018 Try: player addAction ["Action text", { hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name (_this select 0)), (round (time - ((_this select 0) getVariable ["injuryReport", -1]])))]; }]; Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 13, 2018 @HazJNot working here were i put this on init of unit or on init.sqf Share this post Link to post Share on other sites
HazJ 1289 Posted May 13, 2018 Eden editor object init: this addAction ["Action text", {hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name (_this select 0)), (round (time - ((_this select 0) getVariable ["injuryReport", -1]])))];}]; Please stop being so vague when you post. Saying "it doesn't work" doesn't help me or anyone. How does it not work? What did you try? Etc... A little info can go a long way. 1 Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 13, 2018 @HazJSorry in editor says generic error in expression Share this post Link to post Share on other sites
HazJ 1289 Posted May 14, 2018 Try: this addAction ["Action text", {hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name player), (time - ((_this select 0) getVariable "injuryReport"))];}]; Think missing bracket from one of the examples with getVariable alt syntax or something. From yesterday's post. You may not even see the hint as they override each other. I believe the ACRE one is looping? this addAction ["Action text", {systemChat format [":: When did %1 fire his weapon? %2 seconds ago...", (name player), (time - ((_this select 0) getVariable "injuryReport"))];}]; Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 14, 2018 Other image was wrong sorry Share this post Link to post Share on other sites
HazJ 1289 Posted May 14, 2018 Fixed missing bracket. Try: this addAction ["Action text", {hintSilent format [":: When did %1 fire his weapon? %2 seconds ago...", (name (_this select 0)), (round (time - ((_this select 0) getVariable ["injuryReport", -1])))];}]; Or: this addAction ["Action text", {systemChat format [":: When did %1 fire his weapon? %2 seconds ago...", (name (_this select 0)), (round (time - ((_this select 0) getVariable ["injuryReport", -1])))];}]; Share this post Link to post Share on other sites
Laerte Leite 1 Posted May 14, 2018 It works man but is possible to put this is script on a Engineer for example to make his check if other player or ai fired his weapon? Share this post Link to post Share on other sites
HazJ 1289 Posted May 14, 2018 Yes, it is. Search around on here or Google it. Sorry but I'm not doing everything for you. Share this post Link to post Share on other sites