[Release] Safezones

kikyou2

Valued Member!
First of all much thanks to felixberndt who made this possible (Thread http://opendayz.net/threads/safezone.8190/ ).

If you want to do a Safezone at a special place you got to create a text file with this content

Code:
//Base protection for Players with Eventhandler
//
//requires Trigger with activation BLUEFOR and OPFOR with name Basis_West and Basis_East
//
// you can't fire out of your own Base
//
//Those who hit or kill Enemy in it's Base, will be killed
//
// Parameters: [name of the side trigger for the Base Area]
//
//Center_West:
//if (playerSide == WEST) then {[Basis_West] execVM "safezone.sqf"};
//
//Center_East:
//if (playerSide == EAST) then {[Basis_East] execVM "safezone.sqf"};
 
 
Private ["_Basis","_EH_Fired","_EH_Hit","_EH_Killed"];
 
 
_Basis = _this select 0; //Basisname
 
while {true} do
  {
    //wait until Player is in base, then start Eventhandler
    waitUntil {vehicle player in list _Basis};
    player groupchat "i am in Baseshield!";
    _EH_Fired  = vehicle player addEventHandler ["Fired", { NearestObject [_this select 0,_this select 4] setPos[0,0,0]}];
    _EH_Hit    = vehicle player addEventHandler ["Hit",  {_this select 1 setdammage 1; player setDammage 0; vehicle player setDammage 0}];
    _EH_Killed = vehicle player addEventHandler ["Killed",{_this select 1 setdammage 1}];
    //wait until Player left base, then delete EventHandler
    waitUntil {! (vehicle player in list _Basis)};
    player groupchat "i have left Baseshield!";
    player removeEventHandler ["Fired", _EH_Fired];
    player removeEventHandler ["Hit",  _EH_Hit];
    player removeEventHandler ["Killed",_EH_Killed];
  }

After that rename it to "safezone.sqf" and save it.

After that go to your Server Files and unpack your Mission File ( stored at /MPMissions/) with an Tool like PBO Manager. At the main folder where your mission.sqm is you have to also place the safezone.sqf.

Now you open the mission.sqm with an Editor like Notepad++ and press CTRL+F and search for "sensors".

There you will see all the Markers of your Mission File. At the beginning you will see something like this:


Code:
class Sensors
{
items=10;


The number which is after the = must match how many items you have afterwards. The first item start at #0 so just have to look at the last item and then add +1.

Example:

Last item is #9. Then you have to set items=10

That is what you have to know when we add now some more markers. In my example I added the safezone script for the Epoch Mod Tradercities.

The last item in my mission.sqm at the sensor part was class item6 and I wanted to add 3 new markes for 3 new safezones so I got to start with class Item7.


Code:
class Item7
        {
            position[]={4069.8455,365.19922,11661.84};
            a=140;
            b=140;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            text="Basis_West";
            name="Basis_West";
            expActiv="if (playerSide == WEST) then {[Basis_West] execVM ""safezone.sqf""};";
            class Effects
            {
            };
        };
        class Item8
        {
            position[]={11469.787,317.32358,11356.751};
            a=140;
            b=140;
            activationBy="ANY";
repeating=1;
            interruptable=1;
            age="UNKNOWN";
            text="Basis_East";
name="Basis_East";
            expActiv="if (playerSide == WEST) then {[Basis_East] execVM ""safezone.sqf""};";
            class Effects
            {
            };
        };
  class Item9
        {
            position[]={6345.6113,306.13721,7808.5073};
            a=140;
            b=140;
            activationBy="ANY";
repeating=1;
            interruptable=1;
            age="UNKNOWN";
            text="Basis_South";
name="Basis_South";
            expActiv="if (playerSide == WEST) then {[Basis_South] execVM ""safezone.sqf""};";
            class Effects
            {
            };
        };


position[]={Here you have to put in the Coordinates for the Savezone Spot};
a= and b= Its the range of the savezone
text=""; and name=""; are all editable at your needs. But don't forget to change the name in the Line of expActiv= if you change it.
playerSide == WEST this is very important for every marker you set - its indifferent how you name the marker.

If you put all your markers in which you need and edited the items= counter at the bottom of the sensor part you're ready to go.

You may want to repack the Missionfile to a .pbo but you needn't if you call the folder right as the pbo was called ( no .pbo ending is needed).

Also you will want to add an line to the script.txt if you have BattlEye turned on or you will be kicked for script restriction #41.

Open scripts.txt and search for "5 setDamage" at the very end of the line add

Code:
!"vehicle player addEventHandler ["Hit",  {_this select 1 setdammage 1; player setDammage 0; vehicle player setDammage 0}]"

Do the same for "5 setDammage" if you have one.

Save it and restart the Server. You shouldn't have a script restriction anymore.

Known Issues:
Zombies can attack Players inside the Safezone but the Player can't attack the zombie. Currently working on a solution for this.

Hope that helps!

Regards kikyou2
 
Back
Top