Home   Help Search Login Register  

Author Topic: fired EH  (Read 1658 times)

0 Members and 1 Guest are viewing this topic.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
fired EH
« on: 17 Jan 2008, 15:58:41 »
Tryin to get my head around MP Event Handler scripting & was wondering how i could find out who dammaged an Editor defined Object & then awarding that person, say...-10 or +10 points for instance sake?

I have an MP mission where a number of Editor placed radios are acting as explosive devices & if they take dammage from a Player they explode - though i have no probs detecting the dammage...was simply wondering how to detect which player dammage the Object so that he/she may be penilized/merited?

(I figured this would be the best place to ask, as i have obtained very helpful advice & knowledge at OFPEC in the past...for any helpful advice in clarifying my lasted query please let it be known that it is most pre-thankfully received!)
« Last Edit: 17 Jan 2008, 16:04:26 by Carroll »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fired EH
« Reply #1 on: 17 Jan 2008, 16:01:46 »
try with "Hit" EH.

Passed array: [unit, causedBy <- this is what you are looking for, damage]

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: fired EH
« Reply #2 on: 17 Jan 2008, 16:06:23 »
can you please give me an example Mandoble, for example;

Say Bob dammages Object1....take -10 points off Bob

Object1 addEventHandler ["Object1", {(_this select 0) > 0.2}] exec "Explosion.sqs"....am i close with putting this into Object1's INIT field?

though a number of errors are presented to me in testing :scratch:
« Last Edit: 17 Jan 2008, 16:20:53 by Carroll »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fired EH
« Reply #3 on: 17 Jan 2008, 16:18:59 »
Code: [Select]
object1 addEventHandler ["Hit", {(_this select 1) addScore -10}];

Note that "Hit" EH executes locally to the object being hit and addScore has also local effects. So probably you will need to tweak the code a bit to make sure the score added to the unit is broadcasted everywhere.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: fired EH
« Reply #4 on: 17 Jan 2008, 16:29:11 »
Okay, thankyou for the correct syntax, that puts me in a stright line from my previous post, however you suggest that i "tweak the code a bit" to make sure that the score is broadcast every where...is it possible that you could teach me how to do this, or if not, at least show me how this EH can add say '-10 points to Bob'?

Please tell me if i am close;
Quote
object1 addEventHandler ["Hit", {(_this select 1) exec "Bob.sqs"}] - Put in INIT field of Object1

;Bob.sqs
Bob addScore -10
[] exec "Object1Explosion.sqs"
exit
« Last Edit: 17 Jan 2008, 16:34:41 by Carroll »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: fired EH
« Reply #5 on: 17 Jan 2008, 16:34:32 »
Wrong aproach.

The one that caused the damge is retrieved in _this select 1 by the code that is executed when "Hit" event happens.
So, _this select 1 might be Bob or Peter, etc.

what I mean is that addScore adds score locally to the passed unit, and Hit EH is executed locally in the machine where the damaged object is local.

So, for example you have Bob, who is a player, and Bob hits a building, which is local to the server. The code of the EH is executed in the server, and in the server Bobs gets -10 points. Now that modification of the score might not been broadcasted to Bob's computer, so might be Bob cannot see he now has 10 points less. This is something you should try online.

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: fired EH
« Reply #6 on: 17 Jan 2008, 16:39:27 »
Okay thanks for your help, atleast you have me looking in the right direction. I'll do some more testing keeping these things in mind & see if i can find my solution, until then i'll keep this topic open.....