OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: retsudo 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.
-
but this seems unwieldy and slow.
Uh? Finding the gunner of a vehicle is usually not that slow:
if (_unit == vehicle _unit) then { _unit = gunner _unit };
If _unit was a vehicle it's now the vehicle's gunner.
-
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)
-
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' rating (http://community.bistudio.com/wiki/rating)s. 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.