Jump to content
Sign in to follow this  
EACC

Help, using Addeventhandler?

Recommended Posts

> Hi!

> Im trying to make a mission with a "Civilian killing penalty" script.

> But when a player on another computer kills a civilian the host gets the

> cuttexts and the actual killer gets the setpos command resulting that

> he's the one going to jail.

> Could be that the script only runs properly on the host computer.

> is there anyway to solve this limitation?

>

> here's the code btw

>

>

> ;;Every civilian on map has this script executed wtih a trigger

>

> Civ.sqs

>

> _Civ = _this select 0

>

> _Civ addEventHandler ["killed",{_this exec "civKill.sqs"}]

> exit

>

>

> __________________________

>

> Civkill.sqs

>

> _killerA = _This select 1

>

> ?(_KillerA == S1) : _KillerI = S1

> ?(_KillerA == S2) : _KillerI = S2

> ?(_KillerA == S3) : _KillerI = S3

> ?(_KillerA == S4) : _KillerI = S4

> ?(_KillerA == S5) : _KillerI = S5

> ?(_KillerA == S6) : _KillerI = S6

>

> _Killer = Gunner (vehicle _KillerI)

>

> ?(Side _Killer == east): exit

> ?(side _Killer == west): goto "exec"

>

> #Exec

> [_Killer] exec "Penalty.sqs"

> exit

>

> ____________________________________

>

> Penalty.sqs

>

> _Killer = _This select 0

>

> #Penalty

>

> ;Messages

> ?_Killer == _Killer:cuttext ["You Have killed a civilian","Plain",2]

> ~4

> ?_Killer == _Killer:cuttext ["Prepare for trial!","Plain",2]

> _Killer action ["Eject",(Vehicle _Killer)]

> _Killer switchmove "FXstandsur"

> ~10

>

> ;Prison

> _Killer setPos (getPos Prison)

> _Killer setdamage 0

> Removeallweapons _Killer

> [_Killer] join grpNull

> _Killer switchmove "Stand"

> ?_Killer == _Killer:cuttext ["You will be back in 1 and a half

> minute","Plain",2]

>

> ~90

>

> ;Goto Base

> ?_Killer == _Killer:cuttext ["You did your time, but you will have no

> privileges to lead a group again","Plain",2]

> _Killer setPos (getPos Base)

>

> #exit

> exit

>

>

>

> Feel free to give suggestions on how to improve the script.

>

> Thank you!

Edited by EACC

Share this post


Link to post
Share on other sites

Okay i got this to work but the message "You killed a civilian" still shows up.

Any solutions on that? :D

And ahh... the solution was to make multiple triggers foreach player that executed the "penalty.sqs" script

Share this post


Link to post
Share on other sites

>

> Civkill.sqs

>

> _killerA = _This select 1 ---> lower case _k <Nevermind - capitilization doesn't seem to matter.>

>

> ?(_KillerA == S1) : _KillerI = S1 ---> upper case _K <Nevermind - capitilization doesn't seem to matter.>

> ?(_KillerA == S2) : _KillerI = S2

> ?(_KillerA == S3) : _KillerI = S3

> ?(_KillerA == S4) : _KillerI = S4

> ?(_KillerA == S5) : _KillerI = S5

> ?(_KillerA == S6) : _KillerI = S6

troubleshoot with: hint format ["%1",_KillerI] <Not applicable anymore.>

It will show you what the Variable _KillerI is.

____________________________________________________________________

> Penalty.sqs

>

> _Killer = _This select 0

>

> #Penalty

>

?_Killer == _Killer is always gonna be true

Edited by WW2Weasel

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×