Home   Help Search Login Register  

Author Topic: Jail West Players Only  (Read 2421 times)

0 Members and 1 Guest are viewing this topic.

Offline Bailey

  • Members
  • *
Jail West Players Only
« on: 30 Aug 2008, 09:32:03 »
Code: [Select]
if player ==West than
_killer = _this select 0
~1
hint format [ "ATTENTION!\n%1 has killed a civilian! He will go to Jail for his crime!",(name _killer)]
~3
?_killer==player:titlecut ["","BLACK OUT",3]
~4
removeallweapons _killer
_killer setpos (getpos jail)
~1
?_killer==player:titlecut ["","BLACK IN",3]
Exit
 

 With this code i am trying to send West players to jail Only not East.

Help on this issue would be great.


Thnx luke,

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Jail West Players Only
« Reply #1 on: 30 Aug 2008, 13:13:27 »
The first parameter sent to the killed handler is the victim, not the killer.

Note also that the killer is the same as the victim if the civilian was run over. This does mean you can run civilians over with impunity, but is a limit with the game. If you have vehicles in the mission and think this will be a problem, you can assume that the driver of the nearest "LandVehicle", assuming it is within a few metres of the victim, was, in fact, the killer.

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 will go to Jail for his crime!",(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 go to Jail for your crime!"

~3
titlecut ["","BLACK OUT",3]
~4
removeallweapons _killer
_killer setpos (getpos jail)
~1
titlecut ["","BLACK IN",3]
« Last Edit: 30 Aug 2008, 17:26:11 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Bailey

  • Members
  • *
Re: Jail West Players Only
« Reply #2 on: 30 Aug 2008, 17:23:50 »
Code: [Select]
? side _killer != west : exit Used this part of the code and it worked a treat :)

EDIT (Spooner): Removed unnecessary quoting.

Code: [Select]
player = _this select 0
? side player != west : exit
player disableUserInput true;
~1
hint format [ "ATTENTION!\n%1 has killed a civilian! He will go to Jail for 2 Minutes! Enjoy The Music!",(name player)]
~3
?player:titlecut ["","BLACK OUT",3]
~4
player setpos (getpos jail)
~1
?player:titlecut ["","BLACK IN",3]
~120
player disableUserInput false;
player setdammage 1;
Exit

Ok i'm still having a problem with this, if someone else kills a civ i lose UserInput and nothing happens to them? this is in each civ Init

Code: [Select]
civ1 addEventHandler ["killed",{[_this select 1] exec "scripts\jail.sqs"}] 
 I dont no much about Global veribles so any help with this would be great :)
« Last Edit: 03 Sep 2008, 10:25:18 by Spooner »

Offline Bailey

  • Members
  • *
Re: Jail West Players Only
« Reply #3 on: 03 Sep 2008, 10:23:15 »
Code: [Select]
_victim = _this select 0
_killer = _this select 1
? side _killer != west : exit
_killer setpos (getpos jail)
disableUserInput true
Removeallweapons _killer
hint format [ "ATTENTION!\n%1 has killed a civilian! He will go to Jail for 2 Minutes! Enjoy The Music!",(name _killer)]
~120
disableUserInput false
_killer setDammage 1 
Exit


Ok i am still having the same problem i have looked at this alot and can not see whats wrong. Only i lose my UserInput still and also lose my weapon however the _killer does go to to jail and does show his name as the killer? After the ~120 pause i get my UserInput pack. However no weapon lose or UserInput lose for the person that done the killing.


Any help would be great, thnx


This is in my Init. file

Code: [Select]
civ1 addEventHandler ["killed",{[_this select 0, _this select 1] exec "scripts\jail.sqs"}];

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Jail West Players Only
« Reply #4 on: 03 Sep 2008, 10:32:40 »
I have already shown you how to deal with the MP aspects of this in my earlier example script. Please don't just ignore my answers and complain that your script still doesn't work. In my example, just replace,

Code: [Select]
removeallweapons _killer
_killer setpos (getpos jail)
with
Code: [Select]
_killer setpos (getpos jail)
disableUserInput true
Removeallweapons _killer
~120
disableUserInput false
_killer setDammage 1
(and update the hints appropriately) to get the effect you are now trying to achieve.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Bailey

  • Members
  • *
Re: Jail West Players Only
« Reply #5 on: 03 Sep 2008, 10:59:30 »
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 will go to Jail for his crime!",(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 go to Jail for your crime!"

~3
titlecut ["","BLACK OUT",3]
~4
_killer setpos (getpos jail)
disableUserInput true
Removeallweapons _killer
~120
disableUserInput false
_killer setDammage 1
~1
titlecut ["","BLACK IN",3]


Ok i have tried this and only i get the message that the person has killed and nothing happens to the person. However if i kill someone i got to jail and it works fine.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Jail West Players Only
« Reply #6 on: 03 Sep 2008, 12:37:38 »
What you are saying doesn't really make sense. I think you are saying that:
* If someone else kills a civ, then you get a message that they have killed, but they don't get a message or go to jail.
* If you kill a civ, then you get a message and go to jail, but no-one else sees a message.

If this is what you mean, then the problem with this is that you and someone else shouldn't be getting different effects, since, to the other person's perspective, they are getting:
* If someone else kills a civ, then they get a message and go to jail, but I don't see a message.
* If you kill a civ, then you don't get a message or go to jail, but I see a message.

Questions:
* Are both players dedicated clients, or are you the host and the other a dedicated client? Is everyone in the mission at the start, or did one or other of you JIP?
* Are both players actually on west side?

Anyway, I suspect that something else in the mission is having an unseen effect here. Is it possible you could attach the test mission you are using to develop this script and maybe I can see where the problem is? Essentially, it seems that the other player isn't adding the killed event handlers, so they are never being told about deaths.

One other thing you could try first is replacing the stuff in the init file:
Code: (init.sqs) [Select]
civ1 addEventHandler ["killed",{[_this select 0, _this select 1] exec "scripts\jail.sqs"}];
civ2 addEventHandler ["killed",{[_this select 0, _this select 1] exec "scripts\jail.sqs"}];
with
Code: (in every civilian init) [Select]
this addEventHandler ["killed",{[_this select 0, _this select 1] exec "scripts\jail.sqs"}];
(I think this will be the problem if you are hosting for another player or if the other player JIPPED and you didn't).
« Last Edit: 04 Sep 2008, 15:46:25 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Bailey

  • Members
  • *
Re: Jail West Players Only
« Reply #7 on: 04 Sep 2008, 07:10:11 »
Answer TO Questions;

* I am the Host and everyone is at the start
* Both are on the West side, i have tried the other way around.


I have tried making a test missions putting 2 West Units down and have my Jail Marker. I place a Civilian with all that we have discussed so far in scripts in the mission folder and it still does the same thing.

 :dunno:

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Jail West Players Only
« Reply #8 on: 04 Sep 2008, 23:25:12 »
OK, now I get to apologise :dunno: I had a complete brain-fart on this, in spite of having done something very similar myself less than a week ago and got it right without thinking about it (yeah, complacency is...bleh)!

The truth is that KILLED handlers are only fired on the machine on which the thing that was killed is local. Since AI live on the server, it was working fine in SP or on the MP host machine.

Code: (init.sqs) [Select]
; Add all the killed handlers to the civs. Could run this in their inits instead; it really makes no difference.
civ1 addEventHandler ["KILLED", { _this exec "scripts\jail.sqs"; killedCiv = _this; publicVariable "killedCiv"; }];
civ2 addEventHandler ["KILLED", { _this exec "scripts\jail.sqs"; killedCiv = _this; publicVariable "killedCiv"; }];

; 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, but...*shrugs*
~10;
; Be informed whenever some civilian is killed.
"killedCiv" addPublicVariableEventHandler { (_this select 1) exec "scripts\jail.sqs" };

The last version of code for jail.sqs is fine already ;P
« Last Edit: 04 Sep 2008, 23:30:11 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Bailey

  • Members
  • *
Re: Jail West Players Only
« Reply #9 on: 06 Sep 2008, 06:41:53 »
Ok no need to apologise at all im the one with out a clue.... Unfortunatly  the script is still not working i still lose my UserInput. I really have no idea at where to go with this as i have already tried so many different ways and i really no nothing about scripting. Funny thing was i was just stuffing around moving the _killer parts with _player and the other way around an it suddnely started working even though both Userinputs where on false...lol... But after restarting it was no good again.. Any way Spooner i am open to any sujestions at this time.. sooooo lost.

 :dunno:
« Last Edit: 06 Sep 2008, 07:57:18 by Bailey »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Jail West Players Only
« Reply #10 on: 06 Sep 2008, 15:50:52 »
OK, I've attached my test mission (basically just what I've given you already, but with minor changes, such as only jailing for 5 seconds rather than four minutes, which is more sensible during testing). It works fine in SP and MP (from 10 seconds after you join the game).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Bailey

  • Members
  • *
Re: Jail West Players Only
« Reply #11 on: 07 Sep 2008, 13:18:40 »
 :clap: :good:

Thanks so much, that did it :)