Home   Help Search Login Register  

Author Topic: Jail Script not working, could use some help.  (Read 1448 times)

0 Members and 1 Guest are viewing this topic.

Offline Landdon

  • Members
  • *
Jail Script not working, could use some help.
« on: 06 Jan 2009, 09:12:51 »
Hello All,

I'm have a bit of a problem get a piece of script to work in a mission which is using the ACE Mod.  The goal of the script is to place a blufor troop in a stockade if they kill a Civilian.  I have gotten this script to work before but is was without using the ACE Mod and please bear in mind I am no where near a scripting expert.  I most grateful for any help can can be provided.

In my init.sqf file I have the following line:

Code: [Select]
_allCivs = [civ1,civ2,civ3,civ4,civ5,civ6,civ7,civ8,civ9,civ10,civ11,civ12,civ13,civ14,civ15, civ16,civ17,civ18,civ19,civ20,civ21,civ22,civ23,civ24,civ25,civ26,civ27,civ28,civ29, civ30,civ31,civ32,civ33,civ34,civ35,civ36,civ37,civ38,civ39,civ40,civ41,civ42, civ43,civ44,civ,45,civ46,civ47,civ48];

[_allCivs] exec "scripts\initPunish.sqs";

The initPunish.sqs has the following:

Code: [Select]
_civs = _this select 0;

; Add all the killed handlers to the civs. Could run this in their inits instead; it really makes no difference.

{ _x addEventHandler ["KILLED", { _this exec "scripts\gotoJail.sqs"; killedCiv = _this; publicVariable "killedCiv"; }]; } forEach _civs;

; Only clients need to know about deaths.

? isServer and (isNull player) : exit;

; Make sure we don't hear about the death should the player JIP into the game a long time after the death occurred.

; Note that this will mean you *could* kill with impunity for the first 10 seconds after JIP, but...*shrugs*

~10

; Be informed whenever some civilian is killed.

"killedCiv" addPublicVariableEventHandler { (_this select 1) exec "scripts\gotoJail.sqs" };

And my gotJail.sqs has the following:

Code: [Select]
_victim = _this select 0

_killer = _this select 1

; If the killer wasn't killed directly by another player, then that is fine and ignored.

? _killer == _victim : exit

; If the killer wasn't on the west side, then that is fine.

? side _killer != west : exit

; Everyone except the killer gets one message and doesn't go to jail.

~1

? _killer != player : hint format [ "ATTENTION!\n%1 has killed a civilian! He has been sent to Confinement to await court-martial!",(name _killer)]; exit

; Only if you are actually the killer, will you get the personal message and go to jail.

hint "ATTENTION!\nYou have killed a civilian! You will be sent to Confinement to await court-martial!"

~3

titlecut ["","BLACK OUT",3]

~4

_killer setpos (getpos jail)

disableUserInput true

Removeallweapons _killer

~5

disableUserInput false

_killer setDammage 0

~1

titlecut ["","BLACK IN",3]

I have a game logic called "jail" place where I wish the Culprit to be placed.  Thank again for any help in resolving this issue.
« Last Edit: 06 Jan 2009, 09:43:27 by bedges »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Jail Script not working, could use some help.
« Reply #1 on: 06 Jan 2009, 10:40:21 »
What is what is not working? At first sight the code seems right for me.

Offline Landdon

  • Members
  • *
Re: Jail Script not working, could use some help.
« Reply #2 on: 06 Jan 2009, 12:54:31 »
That is just what is puzzling me as well.  When I shoot a civilian the guy will fall down and die (maybe not immedately), but nothing happens to me.  I'm wondering if the ACE MOD, is somehow preventing the script from working somehow?  I just don't know enough to figure it out or a work around at the moment.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Jail Script not working, could use some help.
« Reply #3 on: 06 Jan 2009, 13:50:46 »
Try to put a Sleep 10; just before [_allCivs] exec "scripts\initPunish.sqs"; in your init.sqf. Might be ACE is removing event handlers of units at initialization time.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Jail Script not working, could use some help.
« Reply #4 on: 06 Jan 2009, 18:18:53 »
Is the player always on the WEST side, since this is hard-coded in the script?
Code: [Select]
? side _killer != west : exit

Just remove that line if you want any player who kills civilians to be punished (or change west to the appropriate side).

(If I remember right, these scripts were originally made by DaChevs and "fixed" to actually work by me).

Are you killing them with UGL grenades (these are createVehicle in ACE to simulate self-arming grenades)?

The other likelyhood would be that you aren't actually killing the civilians! In ACE there is a wounding system, so when someone drops, it is likely that they are bleeding or stunning, rather than dead. Make sure you shoot them a lot to make sure you finish them off.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Landdon

  • Members
  • *
Re: Jail Script not working, could use some help.
« Reply #5 on: 07 Jan 2009, 02:11:08 »
Spooner and Mandoble,

I'm not certain exactly were I got if from, I think I got it from the OPEC website, most probally from a mission.  And rest assured, I am certainly not attempting to take credit for it.  In this case, the players are always on the westside for this mission.  I am shooting the target with a rifle, one of the ACE weapons not a grenade launcher.  Thanks for the tip on making it affect all player, I one day may need that as well, and I didn't know UGL grenades are using the creatVehicle command.   The folks here at OPEC are extremely helpful.  I am going to try and put a Sleep 10; just before [_allCivs] exec "scripts\initPunish.sqs"; in my init.sqf as suggested.  I believe that is
Code: [Select]
~10
Then I will blast the poor AI on full auto at close range and see if that solve it.  Thanks again!