Jump to content
Sign in to follow this  
nullsystems

Killed eventhandler returns victim as civ

Recommended Posts

Hola,

Just playin around with killed eventhandlers on enemy units.

However, when they are dead they are alway returned as CIV.

I understand why, the wiki tells us all dead units will be CIV.

Im trying to get a killed eventhander which will detect if the dead guy was enemy to the killer.

_victim = _this select 0

?(side _victim == sideEnemy): hint format["%1 just shot an ememy!",_killer];

This is the method I would like to use but I know it doesnt work, does anyoneknow of a specific command without me having to go into setting public variables?

Share this post


Link to post
Share on other sites

Maby this is helpfull:

Init of the enemy: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed",{_this exec "killer.sqs"}]

killer.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_victim = _this select 0

_killer = _this select 1

#killer

hint format ["Warning!\n%1 Enemy killed by (WEST)\n%2 ",name _victim,name _killer]

Exit

source: ofpec_forums

Share this post


Link to post
Share on other sites

Yes, I can see what your saying.

However, this is for a pvp mission.

I should of been clearer...

You see, each player can go in and out of "enemy" status.

So I need some active detection in the script run by the killed event.

I cant add a specific punishment to all players incase they aren't enemy at the time.

sad_o.gif

thank you smile_o.gif

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">bluArray=[];{if (side _X == west) then {bluArray=bluArray+[_X];_X addeventhandler ["Killed",{if ((_this select 1) in bluArray and (_this select 0) in bluArray) then {(_this select 1) sideChat "oops"}}]}} forEach (this nearObjects ["man",200])

All west side men within 200 meters of the init vehicle will be put into an array called bluArray. Those units will also be added a killed eventhandler which checks if the killer is in the same array (on the same side).

Share this post


Link to post
Share on other sites

When you set the eventhandler, the side is known, so you could use that information to pass through to the script that handles the "killed" event.

Quick & dirty example:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(side this == WEST): this addEventHandler ["killed",{[_this, WEST] exec "killer.sqs"}]

?(side this == EAST): this addEventHandler ["killed",{[_this, EAST] exec "killer.sqs"}]

killer.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_victim = (_this select 0) select 0

_killer = (_this select 0) select 1

_side = _this select 1

?(_side != side _killer): hint format["%1 just shot an ememy!",_killer]

Share this post


Link to post
Share on other sites

Watch the source link, i cut the script to the minimum but i think in the full version is exactly what u need?

Share this post


Link to post
Share on other sites

wow lots to take in, ok ill have a look in a mo while i settle down with some coffee...thanks for the update. will get back to you wink_o.gif

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  

×