OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started 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 ?
-
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
-
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"
WHENKILLED.SQS
_man = _this select 0
_killer = _this select 1
_man addEventHandler ["killed", {_man,_killer] exec "killerrating.sqs"}"]
KILLERRATING.SQS
_killer = _this select 1
_killer addrating -9999
And doesn't work! Any example ?
-
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.
-
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
-
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