Jump to content

Recommended Posts

Hi everyone,

 

I've tried, by many ways, to make a protection zone. It means a zone where players don't take damage and the projectiles, like bullets and grenades, disappears. I want to make it activated by a trigger.

 

Do you have a suggestions ? Or maybe a code completly prepared. :)

 

Thanks a lot.

Share this post


Link to post
Share on other sites

Use GrenadeStop.sqf, you can find it everywhere on google by searching for more than a few seconds.

Share this post


Link to post
Share on other sites
27 minutes ago, Midnighters said:

I challenge you to try and make it yourself. 

here is some starters:

FiredNear (event handler)

or

HandleDamage (Event Handler)

 

there is many different ways I could see this being done. 

I like challenges but i'm very not a good programmer. I can do some lines by my self but not more. ^^"

Share this post


Link to post
Share on other sites

I have got a little problem with the GrenadeStop script. When i tried it, the game say there's a problem with the ligne 27. I've 3 safe zones, each got proper radius. Can you help ?

 

Spoiler

The code : if ({(_this select 0) distance getMarkerPos (_x select 0) < _x select 1} count SAFETY_ZONES > 0) then

 

Share this post


Link to post
Share on other sites

3 areas? Let's say triggers or markers

Something like:

player addEventHandler ["firedman",
  {
    _plyr = _this select 0;
    _projectile = _this select 6;
    if (_plyr inArea "marker1" or _plyr inArea trigger1) then {
      deleteVehicle _projectile;
      hintC "Don't fire inside the base!"
    }
}];

 

Share this post


Link to post
Share on other sites
1 minute ago, pierremgi said:

3 areas? Let's say triggers or markers

 

      deleteVehicle _projectile;

Yes, it's 3 triggers. ^^

And is your code made for vehicle or players and vehicles ?

Share this post


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

I've tried, by many ways, to make a protection zone.

 

Do you have a suggestions ?

 

 

You should put up your code and then people can make suggestions based on what you have tried.

Share this post


Link to post
Share on other sites
3 minutes ago, das attorney said:

 

 

You should put up your code and then people can make suggestions based on what you have tried.

Yeap but i've tried with triggers in first after i'd search for scripts. ^^"

Share this post


Link to post
Share on other sites
5 hours ago, reapertitanium said:

Yes, it's 3 triggers. ^^

And is your code made for vehicle or players and vehicles ?

So, players on foot or in vehicles.

Just adjust the condition to your three triggers. Place this code in init.sqf or even any trigger, activated of course.

This code doesn't prevent a shot by a unit inside the area, just preventing players firing when in the area.

 

You can adapt this for a sanctuary:
 

0= [] spawn {
  while {true} do {
   sleep 2;
   {
     if !(_x getVariable ["MGIttd",false]) then {
       _x setVariable ["MGIttd",true];
       _x addEventHandler ["firedman", 
        { 
          _shooter = _this select 0; 
          _projectile = _this select 6;
          _target = if (isplayer _shooter) then [{cursorTarget},{ assignedTarget _shooter}];
          call {
            if (_projectile inArea trigger1 or _projectile inArea trigger2 or _projectile inArea trigger3) exitWith {
              deleteVehicle _projectile;
              if (isPlayer _shooter) then {
                "Don't fire inside the base!" remoteExec ["hintC",_shooter]
              }
            };
            if (_target inArea trigger1 or _target inArea trigger2 or _target inArea trigger3) exitWith {
              deleteVehicle _projectile;
              if (isPlayer _shooter) then {
                "Don't fire inside the base!" remoteExec ["hintC",_shooter]
              }
            };
            [_shooter,_projectile] spawn {
              params ["_shooter","_projectile"];
              waitUntil {_projectile inArea trigger1 or _projectile inarea trigger2 or _projectile inArea trigger3 or isnull _projectile};
              if (!isNull _projectile) then {
                deleteVehicle _projectile;
                if (isPlayer _shooter) then {
                  "Don't fire inside the base!" remoteExec ["hintC",_shooter]
                }
              };
            };
          };  
       }]
      }
    } forEach allUnits;
  }
};

With this code, even a sniper or an artillery shooting from a remote position, to units inside the bases (triggers areas), can't hurt anybody.

As the projectile is delete crossing the area, don't expect firing at an enemy at the opposite location of you through the base.

 

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, reapertitanium said:

I've tried, by many ways, to make a protection zone

 

Unless you absolutely must have a trigger script, I hope this helps

"ProtectionZone_F" createVehicle [4456, 5640, 0];

 

Share this post


Link to post
Share on other sites
On 4/18/2017 at 11:46 PM, pierremgi said:

So, players on foot or in vehicles.

Just adjust the condition to your three triggers. Place this code in init.sqf or even any trigger, activated of course.

This code doesn't prevent a shot by a unit inside the area, just preventing players firing when in the area.

 

You can adapt this for a sanctuary:
 


0= [] spawn {
  while {true} do {
   sleep 2;
   {
     if !(_x getVariable ["MGIttd",false]) then {
       _x setVariable ["MGIttd",true];
       _x addEventHandler ["firedman", 
        { 
          _shooter = _this select 0; 
          _projectile = _this select 6;
          _target = if (isplayer _shooter) then [{cursorTarget},{ assignedTarget _shooter}];
          call {
            if (_projectile inArea trigger1 or _projectile inArea trigger2 or _projectile inArea trigger3) exitWith {
              deleteVehicle _projectile;
              if (isPlayer _shooter) then {
                "Don't fire inside the base!" remoteExec ["hintC",_shooter]
              }
            };
            if (_target inArea trigger1 or _target inArea trigger2 or _target inArea trigger3) exitWith {
              deleteVehicle _projectile;
              if (isPlayer _shooter) then {
                "Don't fire inside the base!" remoteExec ["hintC",_shooter]
              }
            };
            [_shooter,_projectile] spawn {
              params ["_shooter","_projectile"];
              waitUntil {_projectile inArea trigger1 or _projectile inarea trigger2 or _projectile inArea trigger3 or isnull _projectile};
              if (!isNull _projectile) then {
                deleteVehicle _projectile;
                if (isPlayer _shooter) then {
                  "Don't fire inside the base!" remoteExec ["hintC",_shooter]
                }
              };
            };
          };  
       }]
      }
    } forEach allUnits;
  }
};

With this code, even a sniper or an artillery shooting from a remote position, to units inside the bases (triggers areas), can't hurt anybody.

As the projectile is delete crossing the area, don't expect firing at an enemy at the opposite location of you through the base.

 

How do i make this script work on a dedicated server ? sir       its the best safe zone script i have tested <3

Share this post


Link to post
Share on other sites
56 minutes ago, JIMMI DEE BILLY BOB said:

How do i make this script work on a dedicated server ? sir       its the best safe zone script i have tested <3

 

If placed in init.sqf, this should work on dedi. Did you experience some difficulties? Don't forget to adapt your triggers and name them in editor and in script (here: trigger1, trigger2, trigger3).

  • Like 1

Share this post


Link to post
Share on other sites

 

I want to be honest and say I do not know what I'm doing. Your script is the only one I use without a longer guide, so I had to ask you, otherwise I would hit the wall with my project. I'm newbie here, but I've noticed that you add help to almost all threads I have seen here .... And I am very grateful for your answer ... thank you...

Your script works great, but it does not stop MLRS, but it's okay, it's to OP anyway :D

 

I use 6 safe zones and they all work well, you've described everything so well in this thread, so it was quite easy to get to work. I just dont understand server side, that's my problem :D

 

 

 

Share this post


Link to post
Share on other sites

init.sqf runs for server and clients in any case. there is no trouble to add some EH like firedMan on a server. On dedicated, there is no player, so this EH will not fire from this PC but will fire on clients.

 

For MLRS, sometimes the EH returns a null object for the fired rocket. Especially when on 1st muzzle (default one, shortest range, firing against close base) . I didn't test all situation but I'm rather sure that fired object changes when in flight (deployed fins or else). Then the former object is already deleted (and replaced) before entering the area. I don't have a solution for that at this time.

 

I'm not sure you can make a scenario for MP if you don't have any skill about MP editing/scripting. Have a look at forum. There are plenty of useful hints.

Share this post


Link to post
Share on other sites
10 minutes ago, pierremgi said:

init.sqf runs for server and clients in any case. there is no trouble to add some EH like firedMan on a server. On dedicated, there is no player, so this EH will not fire from this PC but will fire on clients.

 

For MLRS, sometimes the EH returns a null object for the fired rocket. Especially when on 1st muzzle (default one, shortest range, firing against close base) . I didn't test all situation but I'm rather sure that fired object changes when in flight (deployed fins or else). Then the former object is already deleted (and replaced) before entering the area. I don't have a solution for that at this time.

 

I'm not sure you can make a scenario for MP if you don't have any skill about MP editing/scripting. Have a look at forum. There are plenty of useful hints.

 

I've made one, I'll just figure out how to make it run optimally on a dedicated server ... it takes a long time to learn something as complex as scripts ... 

 

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

×