Jump to content
TheGeneral2899

[SOLVED](MP) If players leaves area, kill them

Recommended Posts

Hey everyone,

 

I have a trigger 20 x 20 that acts as an area where the players are restricted to stay inside (Note players as it is for multiple playable units).     The intention is to check if any of the players on lets say Independent team leave the area, then kill that specific player who left the area.  I have this working for a specific unit, however lack the knowledge how to pull the list of all players (something like {_x in thisList} count (playableUnits + switchableUnits) > 0;  or something like ({alive _x} count units groupname; 

 ), and then only specifically kill that player who leaves.

 

Any help would be much appreciated!

Share this post


Link to post
Share on other sites

Place a trigger and set its size.

Leave everything else as default other than to change..

Its Condition to : !isNull player

Its OnAct to :

thisTrigger triggerAttachVehicle [ player ];
thisTrigger setTriggerActivation [ "VEHICLE", "NOT PRESENT", true ];
thisTrigger setTriggerStatements ["this", "
    triggerAttachedVehicle thisTrigger setdamage 1;
", ""];

 

Now as all triggers are local on each machine when a player joins the !isNull player will fire off the trigger.

The onAct then re-purposes the trigger by attaching the player to it as its vehicle and setting its statements so it only monitors for the player ( VEHCILE ).

When the player is NOT PRESENT the triggers statement will kill the triggers attached vehicle ( the player ).

Share this post


Link to post
Share on other sites
1 hour ago, killzone_kid said:

It might be nice to give player warning that he left the area and time to return

 

so wrap OnAct code in spawn and put there some message with sleep ?

Share this post


Link to post
Share on other sites

@Larrow - Awesome!  It works like a charm.  Thanks so much for this.  Really appreciate the explanation as well as I am still learning.

@killzone_kid - That is a plan of mine.  I also managed to do that when this whole thing was targeting one VIP player.   If he steps out of the trigger area, it would spawn some text informing him.  And then a second trigger that checked if the VIP was not in the area, would wait 15 seconds (if the criteria still matched) and then would kill them.   Any ideas on how best to achieve this?    Also with the idea that it would take effect for all of the players.   They are on IND team and can make them any group via "this group alpha;" if need be for example.

 

Share this post


Link to post
Share on other sites

Solved the warning message to the player issue by utilizing the same method as Larrow mentioned above.

 

Thanks so much for this guys!  Hope I can return the favor to the community

Share this post


Link to post
Share on other sites
On 23/02/2017 at 6:44 PM, killzone_kid said:

It might be nice to give player warning that he left the area and time to return

How much hand holding does Sir require? :smile_o:

thisTrigger triggerAttachVehicle [ player ];
thisTrigger setTriggerActivation [ 'VEHICLE', 'NOT PRESENT', true ];
thisTrigger setTriggerStatements ["this", "
	'!!STOP !!' hintC composeText [  
		'Where are you going Soldier', 
		parsetext '<br />------------------------<br />', 
		'Return to the AO immediately or Face the firing squad'
	];
	player setVariable [ 'trig', thisTrigger ];
	hintC_arr_EH = findDisplay 72 displayAddEventHandler ['unload', {
		_arrow = 'Sign_arrow_direction_green_F' createVehicleLocal ( player modeltoworld [ 0, 3, 0.4 ] );
		_EH = addMissionEventHandler [ 'EachFrame', {
				( player getVariable 'info' ) params[ '_arrow', '_EH', '_endTime' ];
				if !( isNil '_arrow' ) then {
					if ( time > _endTime ) then {
						player setdamage 1;
						deleteVehicle _arrow;
						removeMissionEventHandler[ 'EachFrame', _EH ];
						player setVariable [ 'info', nil ];
					}else{
						_arrow setPosATL ( player modelToWorld [ 0, 3, 0.4 ] );
						_arrow setDir ( player getDir ( player getvariable 'trig' ));
					};
				};
		}];
		player setVariable [ 'info', [ _arrow, _EH, time + 15 ] ];
	}];
", "
	( player getVariable 'info' ) params[ '_arrow', '_EH' ];
	if !( isNil '_arrow' ) then {
		hint '';
		deleteVehicle _arrow;
		removeMissionEventHandler[ 'EachFrame', _EH ];
		player	setVariable [ 'info', nil ];
	};
"];

 

  • Like 5

Share this post


Link to post
Share on other sites

Larrow you are exceptional with the codes and scripts! This is an excellent area defining system. Your time and work is greatly appreciated. Thank you. 

Share this post


Link to post
Share on other sites

Note: put sqf files in C:\Users\USERNAME\Documents\Arma 3 - Other Profiles\ARMAUSERNAME\mpmissions\MISSIONNAME

 

enter_zone.sqf:

private "_duration";
_duration = _this select 0;
//function:
TAG_fnc_coloredCountdownHint = {
    _color = "#45f442";//green
    _timeLeft = TAG_fnc_countdownEndTime - time;
    if (_timeLeft < 16) then {_color = "#eef441";};//yellow
    if (_timeLeft < 6) then {_color = "#ff0000";};//red
    if (_timeLeft < 0) exitWith {
        //exit and remove eventhandler while politely closing the door
        removeMissionEventhandler ["EachFrame",_thisEventHandler];
        hintSilent parseText format ["<t color='%1'>--- Time is up! ---</t>",_color];
        player setDamage 1;
    };
    hintSilent parseText format ["Time Left:<br/><t color='%1'>--- %2 ---</t>", _color, [(_timeLeft/3600),"HH:MM:SS"] call BIS_fnc_timetostring];
};

//calling the function:
TAG_fnc_countdownEndTime = time + _duration;
eventHandlerId = addMissionEventHandler ["EachFrame",{[] call TAG_fnc_coloredCountdownHint}];

 

leave_zone.sqf:

removeMissionEventhandler ["EachFrame",eventHandlerId];
_color="#45f442";
hintSilent parseText format ["<t color='%1'>--- You're Clear ---</t>",_color];
_time = 5;
while {_time > 0} do {
    _time = _time - 1;  
    sleep 1;
};
hintSilent "";

 

Trigger:

condition : this

On Activation: enterzone = [10]execVM "enter_zone.sqf";

On Deactivation: leavezone = []execVM "leave_zone.sqf";

 

Share this post


Link to post
Share on other sites
3 hours ago, Austin Olson said:

\Arma 3 - Other Profiles\

Only if you have setup secondary profiles, else its \Arma 3\

 

3 hours ago, Austin Olson said:

\mpmissions\

Only if you particularly chose to save it there, by default 3Den always points to \Missions\ when saving.

 

Once you have saved your mission you can always use Scenario > Open Scenario Folder to open the correct folder.

 

3 hours ago, Austin Olson said:

_time = 5;
while {_time > 0} do {
    _time = _time - 1;  
    sleep 1;
};
hintSilent ""; 

Just...

sleep 5;
hintSilent "";

 

3 hours ago, Austin Olson said:

Trigger:

condition : this

On Activation: enterzone = [10]execVM "enter_zone.sqf";

On Deactivation: leavezone = []execVM "leave_zone.sqf";

Dependant on how this is setup, the code could apply to all players when just one player enters your trigger zone in MP.

Condition is this yet you do not say what the Activation type is.

 

 

3 hours ago, Austin Olson said:

 _color = "#45f442";//green
    _timeLeft = TAG_fnc_countdownEndTime - time;
    if (_timeLeft < 16) then {_color = "#eef441";};//yellow
    if (_timeLeft < 6) then {_color = "#ff0000";};//red

You can always use linearConversion to slowly adjust color from green through yellow to red over time. Not important just a nice addition.

Spoiler


TAG_info = [ time, time + 30 ];

addMissionEventHandler[ "EachFrame", {
	TAG_info params[ "_start", "_end" ];
	
	_midTime = _start + (( _end - _start ) / 2 );
	_r = linearConversion[ _start, _midTime, time, 0, 1, true ];
	_g = linearConversion[ _midTime, _end, time, 1, 0, true ];
	
	hintSilent parseText format[ "Time Left:<br/><t color='%1'>--- %2 ---</t>", [ _r, _g, 0 ] call BIS_fnc_colorRGBtoHTML,  [ (( _end - time ) / 3600 ), "HH:MM:SS" ] call BIS_fnc_timeToString ];
	
	if ( time >= _end ) then {
		removeMissionEventHandler[ "EachFrame", _thisEventHandler ];
		hint "Time Up!!!";
	};
}];

Example to run from debugConsole in mission preview.

 

  • Like 1

Share this post


Link to post
Share on other sites

@Larrow
Hey there! Thank you so much for this script, it works perfectly. I only have one question.

I am making a PVP game and I only want specific players to not be able to exit the zone, I also don't want any other player to recieve that restriction if they enter the zone.
Could you tell me how?

Share this post


Link to post
Share on other sites
13 hours ago, Dante0 said:

I only want specific players to not be able to exit the zone,

What denotes a specific player? their side, some array holding a list of players?

 

It's most likely best to change the condition of the placed trigger from !isnull player to something else ie !isnull player && side group player == west for example if it's side based.

It all depends on your criteria of specific players.

Share this post


Link to post
Share on other sites

@Dante0 If your players are not expected to fly, then you could use the default "Zone Protection/Restriction" modules. These either repeat a message to the player, or spawn a mine at their feet. They are linked to either players, a group, or a side. See link for explanation how to use:

 

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

×