Jump to content
Sign in to follow this  
Doolittle

"killed" event

Recommended Posts

Hi! I can't figure this "Killed" event. I have a SERVER script that runs where, as people respawn, it adds a "Killed" event to them. So now only the server can see these events?? I have the server then damaging anyone if they kill someone too close to their spawn. The problem is, it doesn't work on a dedicated server. I would spawn in & shoot someone & nothing would happen. It was as if the player, since they never added the event themselves, never felt the effects of the event. I would think that the server setDamaging a player would work over the net.

Does the server not run any events?? And all addEvent's are run on clients only??

Doolittle

Share this post


Link to post
Share on other sites

I'm also finding that you can't moveInDriver anyone from a script running on the SERVER only.

Doolittle

Share this post


Link to post
Share on other sites

II use the "killed" eventhandler in my scripts on a dedicated server only, and the server picks up on it all the time. confused.gif The "killed" handler as far as I know is meant to execute only on the machine where it is installed.

I use moveINDriver all the time also on Ded server, works as well. confused.gif

Share this post


Link to post
Share on other sites

I created a dedicated server and joined it myself. I was able to setpos and setdammage from the client computer but not moveindriver.

-Edit

I also added this to a unit from the client:

A addeventhandler ["Killed",{hint "!!!"}]

Nothing happened when I killed him.

A was playable SoldierEB.(if it matters)

Share this post


Link to post
Share on other sites

According to the command reference manual, "Killed" and "hit" eventhandlers are only executed where they are local...

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

MP notes: "Killed" and "Hit" event handlers are executed where given unit is local. All other event handlers are executed on all computers. Events added by addEventHandler may be different on each computer.<span id='postcolor'>

So when a unit (which is local on server and has a "killed" eventhandler) gets killed, the eventhandler will only run on the server.  Also if the unit is local on a client computer and has a "killed" eventhandler, only the client computer will execute the eventhandler...

...if you are using the "killed" eventhandler to run a script, then maybe you could use Publicvariable command to make the variable available to all computers, I think you will also need a trigger for this, not sure though...

Mujahedeen.

Share this post


Link to post
Share on other sites
Guest BratZ

Does anyone know what the "killed" event gives you? From what I have tried and according to the Comref it only gives the ammo that did the damage (unless you happen to run your plane into the enemy)

Share this post


Link to post
Share on other sites

bn880 and InqWiper, you were right...

I did some more testing and now know for sure: you cannot move a PLAYER controlled unit into a vehicle with moveInWhatever unless the command is being run on that player's computer....i.e....a Server only script cannot move players into vehicles. Very interesting...

As for "Killed"....I see addEventHandler as just like addAction...wherever the command is run, that's the computer that runs it when the event happens. So if...

?not local Server : exit

_this addEvent blah blah.....

Then the server is the only one that has it running...sooooooo...has anyone used "Killed"...attached it to objects & then setDamage to whomever kills those objects?? Anyways..I'm gonna go work on this now.

BratZ...."Killed" gives you killer & killed objects.

Doolittle

Share this post


Link to post
Share on other sites

Sure about that?

Fort me, eventHandlers are run on every clients and server, except "Killed" and "Hit", which are run "only if unit is local". So the execution of eventHandler is not bound to "on which computer eventHAndler is added", but to wether the unit is local or not.

Local units : the player, and if I remember correctly Suma's statement, every unit under his orders and vehicles he commands.

The thing I did not test is if adding eventHandler on server, for example, is reflected on clients? For example, if in init.sqs, I put

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(local server):exit

unit1 addEventHandler ["Hit", {(_this select 0) sideChat "I'm Hit"}]

<span id='postcolor'>

if unit1 is the name of the unit the player has taken control of, will he see himself crying "I'm hit" if he's hit? If yes, my assumption is that the event is run only on his computer (here, the effect is seen by evryone, but if you use hint instead of sideChat, the hint will appear only on hit player's computer).

Share this post


Link to post
Share on other sites

Hmm....well I still think event handlers are only run on the computer that added them in the first place.  I have no proof for this........however, if you think about it, if it was run on all computers then we could do some kind of dynamic chatting from scripts, like:

_obj addEventHandler ["Killed", {hint "Timmy just died!!"}]

..the point being....you really think it is transmitting that whole string of text to all the other people?  I THINK NOT!!  wow.gif   It would be neat....but it's not like that.  sad.gif  You can't even transmit strings via publicVariable.

Doolittle

Share this post


Link to post
Share on other sites

Yes event Handlers are only executed on the network node where they are installed, in addition a "killed" and "hit" event (as per command reference) is suppost to trigger on a local player. (this part I have not tested, but I might soon)

Share this post


Link to post
Share on other sites
Guest BratZ

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (whisperFFW06 @ April 09 2003,13:58)</td></tr><tr><td id="QUOTE">(here, the effect is seen by evryone, but if you use hint instead of sideChat, the hint will appear only on hit player's computer).<span id='postcolor'>

But he said that...has that been tested?

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (whisperFFW06 @ April 09 2003,07:58)</td></tr><tr><td id="QUOTE">Sure about that?

Fort me, eventHandlers are run on every clients and server, except "Killed" and "Hit", which are run "only if unit is local". So the execution of eventHandler is not bound to "on which computer eventHAndler is added", but to wether the unit is local or not.<span id='postcolor'>

No, this is not right, I am sure it is where the handler is added that matters. Maybe the additional claim for HIt and Killed is true as per the command reference.

Okay I have tested a little:

[*]All(?) handlers other than "HIT" or "KILLED" will execute only on network nodes where they are installed. (can be all)

[*]"HIT" and "KILLED" event handlers will ONLY execute where the object effected is local, even if the handler is installed on all nodes.

Example: If you are a server, and a remote PLAYER is "KILLED", you will not have the "KILLED" handler execute on the server, only on that remote PLAYER's machine.

Share this post


Link to post
Share on other sites

Check edited post above. (for those monitoring the thread)

Share this post


Link to post
Share on other sites
Guest jacobaby

The whole caboodle takes some figuring out.

Here's a few other factors.

If you are the leader of an AI pilot, or any AI, they are local to your PC.

If you are leader but the pilot of your vehicle is another human, vehicle is local to that player.

Vehicles are always local to the driver, and as such can switch "locality" from client to client.

An eventhandler which DOES seem to work on all vehicles local or not, is "incoming missile".

INIT eh's in the CPP do not work as INIT field added eventhandlers....

It all gets confusing.

To be honest, to be sure and have a script execute as it should, I would run it from the INIT line, with a wait condition for the damage to be 0,95 or 1 etc.

Then if it has any effects in you want globally seen, they will be exec'd on all pc's.

TJ

Share this post


Link to post
Share on other sites

smile.gif

"Engine" bool:engineState

"GetIn" string:position (1),object:unit

"GetOut" string:position (1),object:unit

"Fired" string:weapon,string:muzzle,string:mode,string:ammo

"IncomingMissile" string:ammo,object:whoFired

"Dammaged" string:selectionName,scalar:howMuch

"Gear" bool:gearState

"Fuel" bool:fuelState

should all work no matter where the object is local. As long as you install the event handler on the proper network nodes.

Yes you have to know what's local to which node, vehicles switching locality is obvious, but then having the Hit or Killed handlers move say from the server (for empty vehicle) to a client node is not very friendly to scripters.

Share this post


Link to post
Share on other sites

To give credit to BIS, from the command reference:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">"Killed" object:killer

"Hit" object:causedBy,scalar:howMuch

"Engine" bool:engineState

"GetIn" string:position (1),object:unit

"GetOut" string:position (1),object:unit

"Fired" string:weapon,string:muzzle,string:mode,string:ammo

"IncomingMissile" string:ammo,object:whoFired

"Dammaged" string:selectionName,scalar:howMuch

"Gear" bool:gearState

"Fuel" bool:fuelState

"Init" No arguments

(1) position can be "driver", "gunner", "commander", "cargo"

MP notes: "Killed" and "Hit" event handlers are executed where given unit is local. All other event handlers are executed on all computers. Events added by addEventHandler may be different on each computer.

<span id='postcolor'>

Basically for very experienced MP scripters this says it all, but it just needs explaining on cause and effect for practical application.

Share this post


Link to post
Share on other sites

Very interesting jacobaby & bn880!

So if Joe adds a GetIn event to a boat....boat addEventHandler ["GetIn", {hint "Hello doggy!"}]....and then Mary goes and gets in the boat, then Joe will see "Hello doggy!" but Mary won't, right??

But say Joe did boat addEventHandler ["Killed", {hint "Yeouch!"}]...now Mary goes an shoots the boat. Joe will not see a message because the boat is not local to him...and Mary won't see anything because she didn't add the event to begin with.

I don't think the event "string" ({hint "Yeouch!"}) is sent to any other computer. Like I said, we can't even send strings via publicVariable!! Hmm...wait so if Mary isn't local, then Joe shouldn't get a message because he'll never know when Mary gets in the boat. Hmm...so I think events only execute on the computer that made the event in the first place. AND, most importantly, events only execute when something the event was cast on is local to the computer which created the event. No wait....that's totally wrong.......AHHHHHH.......it burns!!!!!!!!! Yearghhhhh! Ignore this post.

Basically I just want to attach a killed event to Nancy so that when Joe shoots her, HE will be killed also.

Doolittle

Share this post


Link to post
Share on other sites

If you read carefully, eventhandlers can be and thus are actually local to every node. So no, nothing is sent across the network in the way you were hoping. smile.gif

On Joes node you can do: jeep12 AEH ["GetIn",{hint "hurrah";}] and on Mary's: jeep12 AEH ["GetIn",{hint "booyah";}] and they will each do their own action, hint different strings.

Share this post


Link to post
Share on other sites

Doolittle you have to set up flags for each player like this

MikeKilled = objNull;

MaryKilled = objNull;

MoeKilled = objNull;

MonikaKilled = objNull;

Then if you are Mike, you do this:

#wait

MikeKilled = Player;

PublicVariable "MikeKilled"

@MikeKilled != Player

if (side MikeKilled == WEST) then {bla bla bad boy};

goto #wait

and then in some "Killed" handler you do (Moes handler):

MikeKilled = Moe;

PublicVariable "MikeKilled";

I know you are pretty good at scripting so this is rough. The idea is, you create a flag for each player that is monitored locally and can be set by a Killed handler on a remote node, then it is PublicVariabled across the network.

You can play with metavariables for this.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (bn880 @ April 09 2003,20:30)</td></tr><tr><td id="QUOTE"></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (whisperFFW06 @ April 09 2003,07:58)</td></tr><tr><td id="QUOTE">Sure about that?

Fort me, eventHandlers are run on every clients and server, except "Killed" and "Hit", which are run "only if unit is local". So the execution of eventHandler is not bound to "on which computer eventHAndler is added", but to wether the unit is local or not.<span id='postcolor'>

No, this is not right, I am sure it is where the handler is added that matters.  Maybe the additional claim for HIt and Killed is true as per the command reference.

Okay I have tested a little:

[*]All(?) handlers other than "HIT" or "KILLED" will execute only on network nodes where they are installed. (can be all)

[*]"HIT" and "KILLED" event handlers will ONLY execute where the object effected is local, even if the handler is installed on all nodes.

Example: If you are a server, and a remote PLAYER is "KILLED", you will not have the "KILLED" handler execute on the server, only on that remote PLAYER's machine.<span id='postcolor'>

You know what?

This explains a lot of strange stuffs I did not understand. crazy.gif

Thanks for the clarification, now things are pretty clear.

Next step, triggers and MP tounge.gif

Share this post


Link to post
Share on other sites
Guest jacobaby

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Doolittle @ April 10 2003,01:10)</td></tr><tr><td id="QUOTE">Basically I just want to attach a killed event to Nancy so that when Joe shoots her, HE will be killed also.

Doolittle<span id='postcolor'>

In that case you can use a little trick.

I made a CSAR mission for the NAM pack, which had a clause that if anybody happened to go in too heavy and killed the POW, you had the option to courtmartial them.

This uses the fact that the killer of the unit is identified in the eventhandler, local or not.

so;

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

this addEventHandler [""killed"",{_this exec ""maryKilled.sqs""}]  

<span id='postcolor'>

and in Marykilled.sqs you need something like;

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

killer = _this select 1

? JOESgroup != group killer:goto "works"

killera = driver killer

Publicvariable "killera"

? IsNull killer:goto "works"

killera addscore -30 (or addrating -10000)

marydead = true

publicvariable "marydead"

exit

#works

~5

hint "Killer un-identified"

exit

<span id='postcolor'>

Get the idea? You can even get the killers ID if he is in a vehicle etc.

HTH

TJ

Share this post


Link to post
Share on other sites
smile.gif seems like the same thing, anyway, I think Doolittle tries to create pretty universal scripts for MP games. Somehow both of the suggestions above may be hard to implement without some unique metaviariable work, to make them universal.

Share this post


Link to post
Share on other sites

That's for such universal particularity that I'm curious about triggers implementation.

This would be to add a generic unit loss counter, and if possible per weapons statistics.

I have to set up a template mission where at the end of the mission, a complete listing of units losses (per type and per side) would be showed, and if I can, a complete per weapon statistic of player.

The template would be empty, after that, each side leader of our campaign would place his availables units and we would merge to get the final mission and play it. So I'm not aware of all the units present.

First thing I set up was a large trigger including the whole map and triggered by anybody, to get the whole list of objects.

Will the list be the same on every computer, or will I have to work server side only, and publicVariable using meta variables?

I have too to add an action on all APCs and Tanks to give them special Optics capabilities (maxed/normal viewDistance option).

Whis'

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (whisperFFW06 @ April 10 2003,12:27)</td></tr><tr><td id="QUOTE">This would be to add a generic unit loss counter, and if possible per weapons statistics.

I have to set up a template mission where at the end of the mission, a complete listing of units losses (per type and per side) would be showed, and if I can, a complete per weapon statistic of player.

The template would be empty, after that, each side leader of our campaign would place his availables units and we would merge to get the final mission and play it. So I'm not aware of all the units present.

First thing I set up was a large trigger including the whole map and triggered by anybody, to get the whole list of objects.

Will the list be the same on every computer, or will I have to work server side only, and publicVariable using meta variables?

I have too to add an action on all APCs and Tanks to give them special Optics capabilities (maxed/normal viewDistance option).

Whis'<span id='postcolor'>

In case you do not know, to PV a metavariable is easy, say you made a metaviariable: theVar = format ["primWeapon_soldier%1",_x];

you can PV it like this: PublicVariable theVar;

The problem is synchronizing everything to make sure your variables do not conflict etc. At the CoC we have developed a Network Services system for OFP which can do some astonishing things in OFP MP (designed specifically for extreme problems mission editors face in MP, like you), but I can't release it as it is not Beta tested nor finalized, nor have we discussed releasing it (I imagine it will be though, since the CoC is all about adding to the OFP community). It would not solve your every problem that's for sure, you would still have to code in the logic of your system(like the handlers), the benefit of the Network Services would be they provide some neat ways of communicating data and events between network nodes/server.

Getting the list of all vehicles should be done on the server only, don't forget to wait until the trigger is filled with something.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">don't forget to wait until the trigger is filled with something.<span id='postcolor'>

Huuu... Do you mean be sure to keep "this" in condition field of trigger (and not putting true), or adding some delay in the trigger by setting min/avg/max time entries? Or something else...

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  

×