Jump to content
Sign in to follow this  
icebreakr

[playername] killed an innocent civilian...

Recommended Posts

Is it possible to put trigger when civilian is not alive, that we see who killed him?

Share this post


Link to post
Share on other sites

try putting this in the civvies init

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed", {hint format["%1 killed by %2",_this select 0, _this select 1]}]

Share this post


Link to post
Share on other sites
try putting this in the civvies init

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed", {hint format["%1 killed by %2",_this select 0, _this select 1]}]

I have this in one of my MP coop missions but for some reason the message isn't displayed to all players. It only displays the message when an AI unit kills a civilian.

Would this work?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed", {TitleText format["%1 killed by %2",_this select 0, _this select 1],"plain down"}]

Share this post


Link to post
Share on other sites

you could be right evil, mp is not my bag, and maybe the hint will only display local to the killer. maybe titletext will display to all.

anyway there both there now for future reference. wink_o.gif

Share this post


Link to post
Share on other sites

Killed, for some reason, is local.  The Dammaged eventhandler would be great except it doesn't say who the killer is.

What I did to get around this is I put a killed eventhandler on the unit to watch.  You can put the EH on only the local Civilian if you want.

Then on each client, make a loop that you exec from init.sqs.

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

#Init

unit_killed = objNull

#Monitor

~1

?isNull unit_killed : goto "Monitor"

player groupchat Format ["The civilian %1, was killed by %2.",unit_killed,unit_killer]

goto "Init"

In the script for the killed EH, it grabs the killed and the killer.  Simply have it do this:

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

_killed = _this select 0

_killer = _this select 1

unit_killed = _killed; publicVariable "unit_killed"

unit_killer = _killer; publicVariable "unit_killer"

Exit

Now, in MP whenever a unit with the killed EH is killed, it'll publicvar the information and the script running on each client will give them a message.

I've done this before for other missions to track civilian deaths where it would deduct points from a team that killed civilians.

Share this post


Link to post
Share on other sites

I'm very new with scripting and would like to use karrilions code but I am having some problems.

Let's call this script monitor.sqs

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

#Init

unit_killed = objNull

#Monitor

~1

?isNull unit_killed : goto "Monitor"

player groupchat Format ["The civilian %1, was killed by %2.",unit_killed,unit_killer]

goto "Init"

And call this one killerkilled.sqs

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

_killed = _this select 0

_killer = _this select 1

unit_killed = _killed; publicVariable "unit_killed"

unit_killer = _killer; publicVariable "unit_killer"

Exit

Now, when you say "on each client, make a loop that you exec from init.sqs." does this mean that we need to add the line [] exec monitor.sqs anywhere in the init.sqs file?

Also, when you say "In the script for the killed EH, it grabs the killed and the killer.  Simply have it do this". Does this mean that we need to make the killerkilled.sqs with the code you made, and exec this file in the civilians init field? Kinda like this?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["killed", {hint format["%1 killed by %2",_this select 0, _this select 1]}]; [] exec "killerkilled.sqs"

Sorry if these sound like stupid questions, I can't wait to learn scripting better!

Share this post


Link to post
Share on other sites

Sorry, guess I wasn't totally clear on how to use the killed EH.

First, in the mission editor, put this in the init field of each civilian you want to track like so:

<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 "Killed.sqs"}]

You could also give each civilian a name and then add the event handler from init.sqs or another script:

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

man1 addEventHandler ["killed",{_this exec "Killed.sqs"}]

Whichever way you do it doesn't matter, but if the civilians aren't respawning, which I'm assuming they're not, then adding it in the init field is easier.  Then just copy and paste the civs you want.  Then you need the Killed.sqs script and it would be something like this:

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

_killed = _this select 0

_killer = _this select 1

unit_killer = _killer

publicVariable "unit_killer"

unit_killed = _killed

publicVariable "unit_killed"

Exit

Then from init.sqs you'd need to add a line to exec the monitor for each client:

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

[] exec killmonitor.sqs

Then create the killmonitor.sqs file with the following code in it:

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

#Init

unit_killed = objNull

unit_killer = objNull

#Monitor

~1

?isNull unit_killed || isNull unit_killer : goto "Monitor"

player groupchat Format ["The civilian %1, was killed by %2.",unit_killed,unit_killer]

goto "Init"

The monitor will loop and check for both unit_killed and unit_killer to become non-null objects and then name them.  Note that if a unit is killed by being run over, then it might assign a dummy name.  That was the case in OFP.  I'd see messages that so-and-so was killed by Igor Menendez or something, or one of the stock names of the units in OFP.

Share this post


Link to post
Share on other sites
Then from init.sqs you'd need to add a line to exec the monitor for each client:

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

[] exec killmonitor.sqs

Awesome!!! Thanks!!!  notworthy.gif

Last question (I hope).

When you say that we need to add the line [] exec killmonitor.sqs for each client in the init.sqs, do you mean that I need to add this line 32 times because I could potentialy have this many players playing the mission?

For example:

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

[ap1] exec killmonitor.sqs

[ap2] exec killmonitor.sqs

[ap3] exec killmonitor.sqs

[ap...] exec killmonitor.sqs

Or do I just need to add the line once in init.sqs to make it "public"?

Share this post


Link to post
Share on other sites

No. The mission automatically execs init.sqs on the server and all clients.

If it's a dedicated server, then it's exec'd locally on the server, and each client execs the script on their own computer.

If you're hosting a session, then it exec's locally on your machine, which is also the local server, and on each client.

So just put it in once:

[] exec "killmonitor.sqs"

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  

×