Home   Help Search Login Register  

Author Topic: Killed eventhandler in vehicle  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

Offline retsudo

  • Members
  • *
Killed eventhandler in vehicle
« on: 10 Oct 2010, 16:44:27 »
Hi,
I'm having trouble sorting this out with the combination of MP scripting and the possibility of the killer being in a vehicle.

Basically, I want to detect who killed civilians and if they have killed 3 civilians to send them to a little cutscene.  It worked ok in singleplayer but not on a dedicated server.
All the civilians have a killed eventhandler which creates an array of the things that killed them.  Unfortunately if they are killed by a vehicle gunner this lists the vehicle and not the gunner himself.  I can work around this by just adding all the crew of the vehicle into the array as well and removing the vehicle, but this seems unwieldy and slow.

I think my way of doing this is a pain and if anyone has any better ideas could you outline them (just in general, I should be able to figure out how to do the scripting)

e.g. what I do now is check the array created by the killed eventhandlers via a script running on the server.  If one killer is in the list 3 times then they are sent as a publicvariable, which triggers a trigger (might change this to a publicvariableeventhandler).  The script running off the trigger checks if the player is the same as the killer and if so runs the cutscene.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Killed eventhandler in vehicle
« Reply #1 on: 12 Oct 2010, 21:26:15 »
Quote
but this seems unwieldy and slow.

Uh? Finding the gunner of a vehicle is usually not that slow:

Code: [Select]
if (_unit == vehicle _unit) then { _unit = gunner _unit };
If _unit was a vehicle it's now the vehicle's gunner.
try { return true; } finally { return false; }

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Killed eventhandler in vehicle
« Reply #2 on: 13 Oct 2010, 16:49:20 »
Think you meant:
(_unit != vehicle _unit)

What about vehicles with turrets? I think his original solution of adding all crew to the array is probably better(if crew command returns turret gunners, which I do not know)
« Last Edit: 13 Oct 2010, 16:52:34 by Mr.Peanut »
urp!

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Killed eventhandler in vehicle
« Reply #3 on: 14 Oct 2010, 00:22:03 »
Well, no. I meant what I wrote. But was incorrect (and still is)...  :whistle:

Thinking about the problem for... uhm... actually thinking about the problem reveals that it's not that easy to solve with "Killed", "HandleDamage" or "Fired" events. For example: who to punish if you have two players in one vehicle and both operate guns?

An indirect approach would be to monitor the players' ratings. If you detect a dead civilian and some player's rating is lower than it was last time you checked you (almost certainly) know who to blame.
« Last Edit: 14 Oct 2010, 03:06:59 by Worldeater »
try { return true; } finally { return false; }