Jump to content
Sign in to follow this  
Zeppelin33

Is the "killed" EH working correctly?

Recommended Posts

Ive got a AI civilian and in his Init i have:

this addEventHandler ["killed", {EH = _this execVM "CivKilled.sqf"}];

CivKilled.sqf :

private ["_killer","_killerSide"];

_killer = _this select 1;

_killerSide = side _killer;

switch (_killerSide) do

{

case west:

{

hint "west";

};

case east:

{

hint "east";

};

};

That gives no hint. So i wanted to check if the player was returned correctly, So i put : this addEventHandler ["killed", "hint format['Killed by %1',_this select 1]"]

in the civ AI init. It returns the civvies name and not mine.

Im using a Nato unit from side blufor to kill the civvie and checking it in the preview of mission editor.

What am i doing wrong?

Edited by Zeppelin33

Share this post


Link to post
Share on other sites

Check my other post, because all of this is wrong apparently, still can't figure this stuff.

You're selecting the wrong item from the array in the EH.

You gotta put:

this addEventHandler ["killed", {EH = (_this select 0) execVM "CivKilled.sqf"}];

AFAIK _this only equals to _this select 0 when there is only 1 item in the array.

A friendlier looking CivKilled.sqf:

_killerSide = side (_this select 1);

switch (_killerSide) do {
   case west : {hint "west"};
   case east : {hint "east"};
};

Edited by 654wak654

Share this post


Link to post
Share on other sites

No, he's just passing the array (which have two elements) to the script. So it would work as far as I can tell. I've also had problem with the killed EH lately. The killer was always wrong

Share this post


Link to post
Share on other sites

Weird, I have it working with your init and this CivKilled.sqf:

_killer = _this select 1;
_killerSide = side _killer;

switch (_killerSide) do {
   case west : {hint "west"};
   case east : {hint "east"};
};

Edited by 654wak654

Share this post


Link to post
Share on other sites

Sorry idk how to wrap the code in the forum, so it looks abit messy.

Thanks for the quick reply!! I have tried 654wak654 way but got : Error select: Type Object, expected Array,Config entry

I just tried again, but used "hit" instead of killed, and it worked 100%

but then i put this in the CivKilled.sqf :

_killed = _this select 0;

_killer = _this select 1;

hint format ["Guy hit = %1\nShooter = %2", _killed, _killer];

and it returns the guy, that was hit's name, twice :confused:

Edited by Zeppelin33

Share this post


Link to post
Share on other sites

It looks your only passing one variable not the array {EH = (_this select 0) execVM "CivKilled.sqf"}]; and then trying to select the second element _this select 1;

try using this to pass all elements to the script

this addEventHandler ["killed", {EH = _this  execVM "CivKilled.sqf"}];

Share this post


Link to post
Share on other sites

Thanks F2k Sel, I tried that at the beginning, but it didnt work. Ill try and neaten up my first post ;) (im not sure how todo the PHP code thing, but ive learned colours XD)

My solution sofar, or the one thing ive found works is:

in AI's init:

this addEventHandler ["HitPart", {EH = _this execVM "CivKilled.sqf"}];

and in CivKilled.sqf :

_killed = ((_this select 0) select 0);

_killer = ((_this select 0) select 1);

hint format ["Guy hit = %1\nShooter = %2", _killed, _killer];

that returns the killer and killed names correctly, but its not ideal.

-------

Did some more testing and theres definitely a ghost in the machine on this one lol

Im using a custom character from our community and setting his load-out, with LEA and loading him with RH M4 RIS.

So i used the normal BIS NATO->Men->Rifleman. but still gave him a loadout = Same result ( Civvies name returns twice.)

So i removed the load-out on him, which i do by adding nul = [this, "SpecOp"] execVM "loadout\gear.sqf"; to his init (thus spawning a stock standard BIS rifleman) and the result was the same, at first.

Then i just tried again with the STD BIS Rifleman and it worked! yay

Then tried it again, and it didnt, So its really intermittent, but if feels like Im getting somewhere.

but to be sure, in the init of my custom character with loadout i checked side and it does return west

Edited by Zeppelin33

Share this post


Link to post
Share on other sites

Works fine for me (stratis)

Victim's initialization Line

this addEventHandler ["killed", {_nul = _this execVM "CivKilled.sqf"}];

CivKilled.sqf

hint format ["Victim = %1\nShooter = %2",(_this select 0),(_this select 1)];

Share this post


Link to post
Share on other sites

Best thing would be to zip the example and post the mission here for testing.

Share this post


Link to post
Share on other sites
Nope still doesnt work. Tried all of it.

Even made a clip to show exactly what im doing and the result.

On the clip you are adding hint, which is supposed to show "Victim = ... and Shooter = ...", the actual hint shows "Guy hit =... and Shooter = ..."?

Share this post


Link to post
Share on other sites

I tried it with vanilla arma and it works fine.

So its probably AGM or some mod doing weird stuff

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  

×