Forum Jump :

Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#1 Posted at 2010-10-22 12:08        
     
This is the third time I try to post!

Help needed with a scrip that punishes players who kill civilians.

Added 6 minutes later:

Now, as the thread is started >.<

I need help with coming up with the following functions in a script:

* register the player who kills a civilian
* strip the player from his weps
* setPos him in a "prison" fot T ammount of seconds
* after time served, return weps and setPos him on insertion point (respawn moves, so not setPos there)

Extras:
* Would be good if repeat offenders get increasingly longer time, 4th civ killed=kick


Background:
I have an MP mission which entails clearing out all enemies from Rahmadi. In the village I have a bunch of civilians walking around doing their thing, and a contingent opfor guarding the village and the chemical plant outside the village. Now, the noCivKill thing is easy to set up with a trigger that ends the mission, but noobs keep coming on and kill civs as soon as they get a gun in their hands because they can't be bothered to read the mission briefing.

Could someone please help me out here?

This post was edited by ogion (2010-10-22 12:15, ago)

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/

Author Message


Posts: 151
Rank:


Level: Muted

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2010-10-22 22:54        
     
Something like the "Evolution" in Arma where if you kill your team mate you lose all your weapons and end up in the banana pole :-) .


Advertisement


Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#3 Posted at 2010-10-23 08:52        
     
Something along those lines, yes.

Added 54 minutes later:

This is how I solved it so far, but the main issue being I have to have a name and a trigger to each and every civ on the map! :S

Please, anyone with a better solution?

disableUserInput true;
player setPos getPos jail;
Hint "You are being punished for killing a civilian";
player setDir 0;
~30
hint "Don't do it again!!!";
disableUserInput false;
player setPos getMarkerPos "in";

Exit

This post was edited by ogion (2010-10-23 09:46, ago)

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/

Author Message


Posts: 429
Rank:


Level: Member

Country: us
Location:
Occupation: Retired
Age: 57
In-game name:

 
#4 Posted at 2010-10-23 10:15        
     
My favorite used a lightning strike and kick from server. Got the point across in very effective fashion. *YES*

I am fear.

Author Message

VIPER[CWW]  

I'm a stable whore


Posts: 2126
Rank:


Level: Member

Country: en
Location:
Occupation:
Age: 28
In-game name: VIPER [RR]

 
#5 Posted at 2010-10-24 23:18        
     
Christ that is awesome Echo, fancy helping a dude out :-D


Author Message

Dead3yez  

I am evil


Posts: 3113
Rank:


Level: Member

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 28
In-game name: dead3yez

 
#6 Posted at 2010-10-24 23:59        
     
First off, the script shown will only work properly in Singleplayer.


Secondly, I think you will have to addMPeventhandler killed to each civilian.

If the units are placed in the editor then use this in init.sqf:
{
  if (side _x == civilian) then {
KilledUnit = _x addMPeventhandler ["killed", {nul = _this execVM "civkilled.sqf"}];
};
} forEach allUnits;

civkilled.sqf

_killer = _this select 1;
if (player == _killer) then {
	disableUserInput true;
	player setPos getPos jail;
	Hint "You are being punished for killing a civilian";
	player setDir 0;
	sleep 30;
	hint "Don't do it again!!!";
	disableUserInput false;
	player setPos getMarkerPos "in";
};

This post was edited by Dead3yez (2010-10-25 16:45, ago)


Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#7 Posted at 2010-10-25 07:15        
     
Now, as I use an sqs as init, and not sqf, this is a slight problem.

what I did was making the first snippet a script of itself as presented, and called it from init.sqs as such:

[] execVM "civcheck.sqf";

However, ArmA keeps spitting errors at me when I go to launch the mission, says missing "}"

What's going wrong here?

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/

Author Message

Dead3yez  

I am evil


Posts: 3113
Rank:


Level: Member

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 28
In-game name: dead3yez

 
#8 Posted at 2010-10-25 16:45        
     
About the errors, yes there was a missing }, my bad. I corrected that in the script above now.

nul = [] execVM "civcheck.sqf"

  • You need to add a handle like above.
  • Also, in .sqs format, you are not required to use a semi-colon at the end of each line.
  • You can create an .sqs and .sqf init


Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#9 Posted at 2010-10-26 12:53        
     
Still no dice. To clarify: This is for Arma 1, the addMPeventhandler doesn't work.

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/

Author Message

Dead3yez  

I am evil


Posts: 3113
Rank:


Level: Member

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 28
In-game name: dead3yez

 
#10 Posted at 2010-10-26 20:15        
     
Oops, my bad. I never noticed it was for ArmA1.

In that case the script suggested might work best like this.
In your init:
"CivKilledVar" addPublicVariableEventHandler {nul = [_this select 1] execVM "civkilled_x.sqf"};

Create a trigger, side civilian, not present and a radius of 0 so that if covers the map. In the activation use:

{
  if (side _x == civilian) then {
KilledUnit = _x addEventhandler ["killed", {nul = _this execVM "civkilled_x.sqf"; 
CivKilledVar = [_this select  0, _this select 1]; Publicvariable "CivKilledVar"}];
};
} forEach thisList;


_killer = _this select 1;
if (player == _killer) then {
    disableUserInput true;
    player setPos getPos jail;
    Hint "You are being punished for killing a civilian";
    player setDir 0;
    sleep 30;
    hint "Don't do it again!!!";
    disableUserInput false;
    player setPos getMarkerPos "in";
};



Notice I changed civkilled to civkilled_x.....

Hope that works, I think that's the way to get eventhandlers to work in ArmA 1 as I recalled.

This post was edited by Dead3yez (2010-10-27 23:10, ago)


Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#11 Posted at 2010-10-27 13:47        
     


Added 9 minutes later:

COOP8_Secure_the_village.Intro.rar for the entire mission

Added 26 seconds later:

I'm at a loss entierly

This post was edited by ogion (2010-10-27 13:57, ago)

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/

Author Message

Dead3yez  

I am evil


Posts: 3113
Rank:


Level: Member

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 28
In-game name: dead3yez

 
#12 Posted at 2010-10-27 18:53        
     
It's my fault for not proof reading. Here is the correct code.

"CivKilledVar" addPublicVariableEventHandler {nul = [_this select 1] execVM "civkilled_x.sqf"};






Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#13 Posted at 2010-10-27 19:40        
     
Allright, good and well, no more errors. However, I get noting at all actually, no mater how many civs I kill :S

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/

Author Message

Dead3yez  

I am evil


Posts: 3113
Rank:


Level: Member

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 28
In-game name: dead3yez

 
#14 Posted at 2010-10-27 23:15        
     
INIT.
"CivKilledVar" addPublicVariableEventHandler {nul = [_this select 1] execVM "civkilled_x.sqf"};


Create trigger. Trigger name: trig1 , trigger must cover area. Type CIVILIAN. in activation use:
civcheck = true;


INIT or file / function called by init:

{
KilledUnit = _x addEventhandler ["killed", {nul = _this execVM "civkilled_x.sqf"; CivKilledVar = [_this select  0, _this select 1]; Publicvariable "CivKilledVar"}];
} forEach List trig1;


civkilled_x.sqf

I actually tested it all this time so I didn't mess things up again. :-)

Have not tested in MP, but hopefully the public variable EH will take care of that.


Author Message

ogion  



Posts: 115
Rank:


Level: Member

Country: se
Location:
Occupation: Small business owner
Age: 41
In-game name: Ogion [SW]

 
#15 Posted at 2010-10-28 09:48        
     
Ok, so here's the trigger:


This is the init:


And this is what happens.



Like.... wtf?! What's going on here???

This post was edited by Foxhound (2010-10-28 22:00, ago)

"Do, or do not. There is no try!" - Yoda
http://www.silentwarriors.org.uk/