Jump to content
Yolo Joe

Vehicle and player safezone?

Recommended Posts

Hi! 

 

I want to make a safezone in my mission that prevents all players and vehicles inside a trigger area to not take any damage. I want it to be similar to King Of The Hill's safezone system. 

I tried "this allowDamage false;" on Blufor present within a trigger, but damage do not get enabled again when leaving. The zafezone also needs to work for any vehicle inside the area even without players in them.

How can I achieve this? Any help would be appreciated! 

Share this post


Link to post
Share on other sites

I just tried using the "Set Vehicle Damage" and "Set character Damage" modules and set it to "Objects in synchronized triggers", synced it to a trigger with type: none and activation: none. Didnt work.

Share this post


Link to post
Share on other sites

You'd need the trigger to be ANYBODY PRESENT otherwise it won't actually find anything, and I'm not sure that'll detect empty vehicles.  Isn't there a friendly fire module?

 

I've seen scripts like this, but I usually got around the problem by not playing with people who view shooting up bases as a valid gameplay style. :)

Share this post


Link to post
Share on other sites

You'd need the trigger to be ANYBODY PRESENT otherwise it won't actually find anything, and I'm not sure that'll detect empty vehicles.  Isn't there a friendly fire module?

I think the problem with the modules is that it only activates once. I need them to stay active all the time..

Share this post


Link to post
Share on other sites

Isn't there a friendly fire module?

I just checked, the friendly fire module just fails the mission if you kill a friendly.

Share this post


Link to post
Share on other sites

this addEventHandler ["Fired",
{
 _firer = _this select 0;
 _ammo = _this select 6;
 
 spawn [_ammo, _firer]
 {
  params ["_ammo", "_firer"];

  while {!isNull _ammo} do
  {
   if ((_ammo distance yourtrigger) < 300) then
   {
    if((random 100) < 50) then 
    {
     // return to sender (idea by Greenfist)
     _ammo setVelocity (velocity _projectile vectorMultiply -1.01);
     _ammo = objNull;
    }
    else
    {
     deleteVehicle _ammo;
     
     // airlift upto 1000m above ground
     _firer setPosAGL ((getPosATL _firer) vectorAdd [0,0,1000]);
     
     _ammo = objNull;

     //do a nice touch down :-)

     spawn [_firer]
     {
      params ["_firer"]
      while{alive _firer} do
      {
       _firer setVelocity ((velocity _firer) vectorAdd [0,0,-1]);

       sleep 0.2;
      };
     };
    };
   }; 
  };
 };
}];

add that eventhandler to each player and to each gunned vehicle.

 

there is a 50% chance that the bullet will return to sender and onother 50% that it ll be deleted and the sender lifts up to the air and learns what a nice touchdown is...

 

maybe buggy but can be fixed if so

 

EDIT: I used the variable

yourtrigger

to measure the distance between the bullet and the trigger. you can choose any name u want and its not neccessary that it a trigger, it can be a simple pen too. but it should stay at the position where the safezone should be around.

Share this post


Link to post
Share on other sites

I found a script that works for player invincibility in safe zones. Everything I need now is a way to prevent placed vehicles from blowing up inside the zone. 

Share this post


Link to post
Share on other sites

Possibly the same scripts since everything is just an object.  Can you post what you're using please?

Share this post


Link to post
Share on other sites

Possibly the same scripts since everything is just an object.  Can you post what you're using please?

http://www.armaholic.com/page.php?id=30691

 
; make sure script only runs on clients
if (isDedicated) then {goto "ExitHere"};
 
 
#StartLoop
; set varis to be used by script
_NKZver = "1.16"
_getdistance = 0;
_NKZflag=9;
_vp="";
 
; text in use flags
_inflag = 9;
_outflag = 9;
 
; get params
_NKZmarker = _this select 0;
_NKZdistance = _this select 1;
_NKZTextIn = _this select 2;
_NKZTextOut = _this select 3;
_NKZvech = _this select 4;
 
 
; checks to ensure both parameters (#1 & #2) have been set
if ((isNil "_NKZmarker") or(isNil "_NKZdistance")) then {goto "ParaError"};
 
 
; checks to see if text exist, if not flag as such so no hint will show
 
; checks for inside zone text
if (isNil "_NKZTextIn") then {_inflag = 0};
if (!isNil "_NKZTextIn") then {_inflag = 1};
 
; checks for outside zone text
if (isNil "_NKZTextOut") then {_outflag = 0};
if (!isNil "_NKZTextOut") then {_outflag = 1};
 
 
; check for vechile protection here - if missing, set to 'off'
if (isNil "_NKZvech") then {_NKZvech = 0};
if (_NKZvech == 0) then {_vp="Vehicle Protection Is:  *Off*"};
if (_NKZvech == 1) then {_vp="Vehicle Protection Is:  *On*"};
 
 
 
; startup notice
systemchat format ["No Kill Zone Script v%2 Active For '%1'",_NKZmarker, _NKZver];
systemchat format ["---  %1  ---",_vp];
 
 
 
; start the checking here
#LoopHere
 
_objcoords = getMarkerPos _NKZmarker;
_getdistance = player distance _objcoords;
 
if (_getdistance <= _NKZdistance) then {goto "InsideTheZone"};
if (_getdistance > _NKZdistance) then {goto "OutsideTheZone"};
goto "LoopHere";
 
 
; comes here if player is inside the set zone
#InsideTheZone
if (_NKZflag == 9) then {_NKZflag = 0};
if (_NKZflag == 0) then {player allowdamage false};
if ((_NKZflag == 0) && (_NKZvech == 1)) then {vehicle player allowdamage false};
if ((_NKZflag == 0) && (_inflag == 1)) then {hint _NKZTextIn};
_NKZflag = 1;
goto "LoopHere";
 
 
; comes here if player is outside the set zone
#OutsideTheZone
if (_NKZflag == 9) then {goto "LoopHere"};
if (_NKZflag == 1) then {player allowdamage true};
if ((_NKZflag == 1) && (_NKZvech == 1)) then {vehicle player allowdamage true};
if ((_NKZflag == 1) && (_outflag == 1)) then {hint _NKZTextOut};
_NKZflag = 0;
goto "LoopHere";
 
 
 
; comes here if the params are not set
#ParaError
hint format ["You Did Not Use Correct Parameters!\n\n\nMarker Name:  %1\n\nDistance:  %2\n\nPlease Correct And Try Again!\n",_NKZmarker, _NKZdistance];
goto "ExitHere";
 
 
 
; master exit point
#ExitHere

Init.sqf:

 

["respawn_west", 200,"You have entered the safe zone","You have left the safe zone", 1] exec "NoKillZone.Sqs";

Share this post


Link to post
Share on other sites

I want to make a safezone in my mission that prevents all players and vehicles inside a trigger area to not take any damage.

 

I suppose adding a Protection Zone object from Eden editor Assets > Props > Signs > Helpers does not ... help ?

 

 

Nikander

Share this post


Link to post
Share on other sites

I suppose adding a Protection Zone object from Eden editor Assets > Props > Signs > Helpers does not ... help ?

 

 

Nikander

That definitely helps! It does not prevent players from exploding their own vehicles by crashing it though  :wacko:

  • Like 1

Share this post


Link to post
Share on other sites

I suppose adding a Protection Zone object from Eden editor Assets > Props > Signs > Helpers does not ... help ?

 

 

Nikander

Make 20 of them or 40 with copy and paste then select all 40, copy and paste again, 40 at once, now you can easily make the safe zone as big as it needs to be without having problems with anti hack. Make them into a big square blob, copy and paste the blob till its the size you want. Then select all and make them invisible so you don't have to see that pink.

 

I found all but one of the safe zone scripts did the job after you drove into them and they worked on players who spawned into them but a vehicle that spawns into any of the safe zones is not protected until it leaves and then comes back. The other script made the vehicles indestructible everywhere, I don't know how it did it.

 

I think I figured out why for the other scripts. Every vehicle in ARMA is spawned before any script you use runs, even the vehicles you use show/hide on, they are still there. You on the other hand spawn in later so the script has run.

 

I don't make missions, don't care for coop/AI, I am trying to make multiplayer battles so that is what this pertains to. I assume it would still be true with missions.

Share this post


Link to post
Share on other sites

what is the code for have safe zone with trigger for players and vehicles?

Share this post


Link to post
Share on other sites

this work for players only..how can i add vehicles too?thank you

Share this post


Link to post
Share on other sites

Wrote a script which should handle a safezone for all vecs and units without the use of the described protection zone of eden. You only need a trigger which fits your desired safezone area and substitute YourTriggerName with your triggers name :-)

This is not tested.

_trigger = YourTriggerName;

_trigger spawn
{
 _old_safezone = [];
 while {true} do
 {
  _new_safezone = ((allUnits append vehicles) - allDead) select {(_x inArea _this) and !(_x in _old_safezone)};
  _left_safezone = _old_safezone select {!(_x inArea _this)};
  _old_safezone = _old_safezone select {_x inArea _this} append _new_safezone;

  {
   if (local _x) then {_x allowDamage false;}
   else {[_x, false] remoteExec ["allowDamage", _x];};
  } count _new_safezone;

  {
   if (local _x) then {_x allowDamage true;}
   else {[_x, true] remoteExec ["allowDamage", _x];};
  } count _left_safezone;
  sleep (5 + random 5);
 };
};

 

Edited by sarogahtyp
1. Script updated to respect locality 2. Inserted spawn

Share this post


Link to post
Share on other sites
6 minutes ago, roby7979 said:

oh ok i put it in init. and rename my trigger ?

I think

initServer.sqf

is a good place for it.

 

You can rename your trigger into YourTriggerName or you just edit line one of the script and change YourTriggerName in whatever your trigger is named.

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

×