OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: robertoHrvat on 01 Oct 2011, 18:40:59

Title: addrating advanced system
Post by: robertoHrvat on 01 Oct 2011, 18:40:59
Hello,
my question is: How to make player addrating -9999 when he kill "somebody"
- not (alive name) is here not what im think on, im editing FTA Life Simulation and I was added weapon shop in and my problem is to i still don't know how to make that addrating when player kill somebody, anybody! Only one man. Then police on same side will start to shoting player!

Or easier to explain what i want: When some man have been killed, his killer get -9999 rating then police will shoting him! Is that possible ?
Title: Re: addrating advanced system
Post by: Gruntage on 01 Oct 2011, 20:39:21
It certainly is possible. If I were to do this I would place a 'killed' eventhandler in the init of everyone but the player. What this does is execute a script whenever a loon with the eventhandler is killed.

Hope that helps

Gruntage
Title: Re: addrating advanced system
Post by: robertoHrvat on 02 Oct 2011, 09:41:36
I believe it will works, but can you please make some example with that eventhandler ? I was never using eventhandlers in making a mission.
I tried this: I created man with init: [this] exec "whenkilled.sqs"

Code: [Select]
WHENKILLED.SQS
_man = _this select 0
_killer = _this select 1
 _man addEventHandler ["killed", {_man,_killer] exec "killerrating.sqs"}"]

Code: [Select]
KILLERRATING.SQS
_killer = _this select 1

_killer addrating -9999

And doesn't work! Any example ?
Title: Re: addrating advanced system
Post by: Inlesco on 02 Oct 2011, 15:40:07
ROH, your second code about consequences of killing a unit does not work because the element you've chosen is marked as "1", it should be "_this select 0" and I'm sure it will work properly then.
Title: Re: addrating advanced system
Post by: robertoHrvat on 02 Oct 2011, 19:48:27
Yes I know, im not very good in that select 0,1,2 ... Anyway I am looking for some script to when civilian die his killed get rating -9999
Title: Re: addrating advanced system
Post by: Raptorsaurus on 18 Oct 2011, 21:02:40
Robert,

Try the attached demo mission. Copy the trigger to the center of your mission map and put the script civkilled.sqs in you mission folder. The trigger is activated by civilian(s) present and adds the event handler "killed" to each civilian using this code on the "On Activation" line:
civ_units = thisList; {_x addEventHandler ["killed", {_this exec "civkilled.sqs"}]} forEach civ_units