Jump to content
Sign in to follow this  
santafee

Killed by Trigger Question

Recommended Posts

Situation: 2 Squads, Alpha and Bravo assigned with

Alpha=group this;

Bravo=group this;

6 enemy Tanks

If any of the groupmembers of bouth groups get killed by any of the 6 tanks, the trigger fires. Thanks in advance..!

Share this post


Link to post
Share on other sites

If it matters that they are killed by a tank you'd need to use eventHandlers, but if you just want to see if any of them die you can use a simple trigger.

Share this post


Link to post
Share on other sites

its important that the trigger gets only fired if they are killed by one of the 6 tanks, got a code for that? im a "not so good-scripter.."^^;-(

i would have tried to connect stuff, but so far i only found a killed, not killed by eventhandler code..

this addEventHandler ["Killed", Man1]

means that something happens if man 1 killed the units, but how do i make a trigger fires then with code..?

Edited by Himmelsfeuer

Share this post


Link to post
Share on other sites

From the wiki for addEventHandler:

this addEventHandler ["killed", "hint format['Killed by %1',_this select 1]"]

If no one beats me to it, a better example coming, gotta run to a meeting though. :)

Share this post


Link to post
Share on other sites

yea thats the eventhandler i saw, but it doesnt fire a trigger for my example, neither it only fires only if Squad Alpha or Bravo get killed one of the six tanks.;-) but thanks for the try allready

Share this post


Link to post
Share on other sites

this addEventHandler ["killed",{if ((_this select 1) in units alpha || (_this select 1) in units bravo) then {*insert whatever code you want here*}}]

Note that this will fire each time someone is killed. If you only want it to fire once, then you will need to make part of your custom code remove the event handlers for everyone.

Share this post


Link to post
Share on other sites

thanks, but the code is not ok in the Initline somehow.

also i would need it fired only if one of Alpha or Bravo Squad is killed by any of the 6 tanks with names..iknow its a bit complicated..^^

Share this post


Link to post
Share on other sites

As not quite said in the wiki, _this select 0 is the killed, and _this select 1 is the killer in the 'killed' EH, so can be used to find whatever variables you're after - they're all held in the EH (ie. side, type, name, etc. of killed or killer). Trigger by script - it can be fired by init.sqf. The 'something = something else' in the wiki is for initline, but then you'd need to do it for everyone.

Share this post


Link to post
Share on other sites
also i would need it fired only if one of Alpha or Bravo Squad is killed by any of the 6 tanks

Ah. I misunderstood you. In that case, put the following in your init.sqf somewhere:

{_x addEventHandler ["killed",{if (_this select 1) in [tank1,tank2,tank3,tank4,tank5,tank6] then {*insert custom code here*}}]} forEach (units Alpha + units Bravo)

Share this post


Link to post
Share on other sites

have you tested it? cause its not working for me..thx

Share this post


Link to post
Share on other sites

Could you be more specific? What's not working? Does the custom code not fire at all when a unit is killed? Do you get any script error messages?

Share this post


Link to post
Share on other sites
{_x addEventHandler ["killed",{if ((_this select 1) in [t1,t2,t3,t4,t5,t6]) then {hint format["%1 killed by %2",_this select 0, _this select 1];}}]} forEach (units Alpha + units Bravo)

Share this post


Link to post
Share on other sites

yep the code just didnt fire for me, i inserted a hint first as code, then i tried to delete a vehicle, nothing worked. thanks kyliana, but i need something where i can enter my code in, not only the hint format, who killed who.

Share this post


Link to post
Share on other sites

Just replace the hint code with whatever you want?

Share this post


Link to post
Share on other sites

still not working, this is in my init.sqf:

{_x addEventHandler ["killed",{if ((_this select 1) in [t1,t2,t3,t4,t5,t6]) then {Hint"SUPER DU AFFE!"}}]} forEach (units Alpha + units Bravo)

in the mission test t1 kills the whole group which is assigned by

alpha=group this, but the hint doenst appear.

Share this post


Link to post
Share on other sites

Himmelsfeuer, that line as you have it written is working for me, odd, did you rename your tanks from "tank1" to "t1"?

Share this post


Link to post
Share on other sites

Was that paste or did you just type this without a space?

Hint"SUPER DU AFFE!"

Share this post


Link to post
Share on other sites
Was that paste or did you just type this without a space?

Hint"SUPER DU AFFE!"

Actually worked with or without a space.

Share this post


Link to post
Share on other sites

Roger that, then he has prolly messed up something else in his init.sqf.

PS. Everyone editing should start their game with -showScriptErrors

Share this post


Link to post
Share on other sites

eh i dont get it. i tried it several times now, looks like i miss something, the hint doesnt appear...:confused:

i dont have to replace the _x with some name right? its just that the ev is assigned at all, i dont know whats wrong ......

Share this post


Link to post
Share on other sites

The line works me also. Make sure that all of the tank names are correct and that you are naming the groups before adding the event handlers.

Also, how are the tanks killing the units? If it's by running them over, then it won't count. A unit that gets run over is considered to have killed itself by the game.

Share this post


Link to post
Share on other sites

http://rapidshare.com/files/409435704/KilledTest.Chernarus.rar

this is a quick test, i dont get whats wrong...thank you..!

---------- Post added at 06:16 PM ---------- Previous post was at 06:14 PM ----------

ehh...my fault, if only 1 unit isnt named, the eventhandler is not added.

sorry for being a stupid nub:p

thanks guys!:)

Share this post


Link to post
Share on other sites

Ah, yes. Default names screw up everything because they have spaces. This is one really stupid part of the scripting language.

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  

×