Jump to content
Sign in to follow this  
Laerte Leite

Gunshot Residue kit script Help

Recommended Posts

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

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

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

@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

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

@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

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

Hello Hajz,

 

It's not working for me either... 

Share this post


Link to post
Share on other sites

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

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.

  • Like 2

Share this post


Link to post
Share on other sites

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

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.

  • Like 1

Share this post


Link to post
Share on other sites

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

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

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×