Run script on trigger

Tom Hart

New Member
I'd wanted to run some script when people enter certain areas of my map. I'd guess the best way to do this would be attach the scripts to triggers, but I cant find any tutorials on how to do this.

Would it be as simple as running ExecVM "myScript.sqf" on the trigger? Or is there some other way I'd need to do this?
 
Yeah, I wanna put it around our admin base, so people get a warning message, and if they don't leave within e.g. 1 minute they get killed.
 
right so make a new .sqf file called adminbase and inside put that inside scripts folder

put the following inside adminbase.sqf
Code:
if ((getPlayerUID player) in ["********","********","*********",]) exitWith {
titleText ["You are cleared to stay...  Welcome back.", "PLAIN DOWN", 3];
} else {
titleText ["This base is protected by a deadly nerve gas agent.. LEAVE NOW!", "PLAIN DOWN", 3];
sleep 5;
titleText ["Your presence here has been logged!", "PLAIN DOWN", 3];
sleep 5;
titleText ["The NERVE GAS will kill you in less than 20 seconds..!", "PLAIN DOWN", 3];
sleep 10;
titleText ["You now have less than 10 seconds to leave (stay and die!)", "PLAIN DOWN", 3];
sleep 10;
titleText ["GAS! GAS! GAS!", "PLAIN DOWN", 3];
sleep 3;
player setDamage 1;
};


remember to put the uid's in this part and make sure there is no ***** left in side ["7777777","88888888","9999999"]


and inside your mission.sqm under sensors (if you dont have one make one i put mine above markers and below vehicles)
put the following inside mission.sqm
Code:
class Sensors
    {
        items=1;
        class Item0
        {
            position[]={14215.376,136.84589,14137.79};
            a=350;
            b=350;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="starsbase";
            expCond="(vehicle player) in thislist;";
            expActiv="adminbase = [] execVM ""adminbase.sqf"";";
            expDesactiv="terminate adminbase; titleText [""You have left the admin Base!"", ""PLAIN DOWN"", 3];";
            class Effects
            {
                titleType="TEXT";
                titleEffect="PLAIN DOWN";
                title="You are entering a restricted zone please leave.";
            };
        };
    };
};
if this doen't work wait till later and i will skype you and send you my files as im a nice person
 
Wow, thanks a lot. So all I need to do is add my unique_id's in from my database, and change the position[] var to the location I want?
 
I'm having a few problems. Here's what I've got so far

adminbase.sqf
Code:
if ((getPlayerUID player) in ["123382982",]) exitWith {
titleText ["You are cleared to stay...  Welcome back.", "PLAIN DOWN", 3];
} else {
titleText ["This base is protected by a deadly nerve gas agent.. LEAVE NOW!", "PLAIN DOWN", 3];
sleep 5;
titleText ["Your presence here has been logged!", "PLAIN DOWN", 3];
sleep 5;
titleText ["The NERVE GAS will kill you in less than 20 seconds..!", "PLAIN DOWN", 3];
sleep 10;
titleText ["You now have less than 10 seconds to leave (stay and die!)", "PLAIN DOWN", 3];
sleep 10;
titleText ["GAS! GAS! GAS!", "PLAIN DOWN", 3];
sleep 3;
player setDamage 1;
};

mission.sqm
Code:
version=11;
class Mission
{
    addOns[]=
    {
        "chernarus",
        "ca_modules_animals",
        "dayz_code",
        "dayz_weapons",
        "dayz_equip",
        "dayz_vehicles",
        "cacharacters_pmc",
        "ca_modules_functions"
    };
    addOnsAuto[]=
    {
        "dayz_weapons",
        "ca_modules_functions",
        "chernarus"
    };
    randomSeed=11171215;
    class Intel
    {
        briefingName="DayZ Chernarus";
        briefingDescription="DayZ";
        startWeather=0.067362607;
        forecastWeather=0.52341133;
        year=2008;
        month=10;
        day=1;
        hour=12;
    };
    class Groups
    {
        items=2;
        class Item0
        {
            side="WEST";
            class Vehicles
            {
                items=1;
                class Item0
                {
                    position[]={-18709.713,379.10086,25923.943};
                    azimut=-17.0839;
                    id=11;
                    side="WEST";
                    vehicle="Survivor1_DZ";
                    player="PLAY CDG";
                    skill=0.60000002;
                    init="this enableSimulation false;this allowDammage false;this disableAI 'FSM';this disableAI 'ANIM';this disableAI 'MOVE';";
                };
               
            };
        };
        class Item1
        {
            side="LOGIC";
            class Vehicles
            {
                items=1;
                class Item0
                {
                    position[]={708.96582,35.858719,3533.1272};
                    id=50;
                    side="LOGIC";
                    vehicle="FunctionsManager";
                    leader=1;
                    lock="UNLOCKED";
                    skill=0.60000002;
                };
            };
        };
    };
    class Sensors
    {
        items=1;
        class Item0
        {
            position[]={1129.1793,0,7464.4805};
            a=350;
            b=350;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="starsbase";
            expCond="(vehicle player) in thislist;";
            expActiv="adminbase = [] execVM ""adminbase.sqf"";";
            expDesactiv="terminate adminbase; titleText [""You have left the admin Base!"", ""PLAIN DOWN"", 3];";
            class Effects
            {
                titleType="TEXT";
                titleEffect="PLAIN DOWN";
                title="You are entering a restricted zone please leave.";
            };
        };
    };
    class Markers
    {
        items=7;
        class Item0
        {
            position[]={7839.6055,381.33774,8414.7324};
            name="center";
            type="Empty";
        };
        class Item1
        {
            position[]={-18697.58,379.53012,25815.256};
            name="respawn_west";
            type="Empty";
        };
        class Item2
        {
            position[]={4932.3345,0.39950246,1989.1094};
            name="spawn0";
            type="Empty";
        };
        class Item3
        {
            position[]={2236.0391,0.63119155,1923.3735};
            name="spawn1";
            type="Empty";
        };
        class Item4
        {
            position[]={8738.1328,0.45720705,2122.1082};
            name="spawn2";
            type="Empty";
        };
        class Item5
        {
            position[]={10909.267,0.57597214,2422.3096};
            name="spawn3";
            type="Empty";
        };
        class Item6
        {
            position[]={13510.764,0.44504455,5249.3027};
            name="spawn4";
            type="Empty";
        };
    };
};
class Intro
{
    addOns[]=
    {
        "chernarus"
    };
    addOnsAuto[]=
    {
        "chernarus"
    };
    randomSeed=6913869;
    class Intel
    {
        startWeather=0.25;
        forecastWeather=0.25;
        year=2008;
        month=10;
        day=11;
        hour=9;
        minute=20;
    };
};
class OutroWin
{
    addOns[]=
    {
        "chernarus"
    };
    addOnsAuto[]=
    {
        "chernarus"
    };
    randomSeed=4081731;
    class Intel
    {
        startWeather=0.25;
        forecastWeather=0.25;
        year=2008;
        month=10;
        day=11;
        hour=9;
        minute=20;
    };
};
class OutroLoose
{
    addOns[]=
    {
        "chernarus"
    };
    addOnsAuto[]=
    {
        "chernarus"
    };
    randomSeed=4975929;
    class Intel
    {
        startWeather=0.25;
        forecastWeather=0.25;
        year=2008;
        month=10;
        day=11;
        hour=9;
        minute=20;
    };
};

When I uploade the pbo file I get stuck on the waiting for host message. Can you see anything wrong there? Also I'm not sure if the coords are correct, in my folder with the beidi file I have a mission.sqf file where I got the coords from.
Code:
_this = createTrigger ["EmptyDetector", [1129.1793, 7464.4805, 0]];
_trigger_0 = _this;

I seem to remember reading something about one file reads them x,y,z and another reads them x,z,y? Did I get the coords correct in the .sqm file?
 
okay heres the fix you had missed some }; and you have a extra , in adminbase.sqf


Code:
    class Sensors
    {
        items=1;
        class Item0
        {
            position[]={1129.1793,0,7464.4805};
            a=350;
            b=350;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="starsbase";
            expCond="(vehicle player) in thislist;";
            expActiv="adminbase = [] execVM ""adminbase.sqf"";";
            expDesactiv="terminate adminbase; titleText [""You have left the admin Base!"", ""PLAIN DOWN"", 3];";
            class Effects
            {
                titleType="TEXT";
                titleEffect="PLAIN DOWN";
                title="You are entering a restricted zone please leave.";
            };
        };
    };
};

adminbase.sqf

Code:
if ((getPlayerUID player) in ["123382982"]) exitWith {
titleText ["You are cleared to stay...  Welcome back.", "PLAIN DOWN", 3];
} else {
titleText ["This base is protected by a deadly nerve gas agent.. LEAVE NOW!", "PLAIN DOWN", 3];
sleep 5;
titleText ["Your presence here has been logged!", "PLAIN DOWN", 3];
sleep 5;
titleText ["The NERVE GAS will kill you in less than 20 seconds..!", "PLAIN DOWN", 3];
sleep 10;
titleText ["You now have less than 10 seconds to leave (stay and die!)", "PLAIN DOWN", 3];
sleep 10;
titleText ["GAS! GAS! GAS!", "PLAIN DOWN", 3];
sleep 3;
player setDamage 1;
};

this should now work and your coordinates will be fine if this does not work PM me your skype name and i will fix it when im back from work
 
I'm almost there now. I'm getting the message from
Code:
class Effects
            {
                titleType="TEXT";
                titleEffect="PLAIN DOWN";
                title="You are entering a restricted zone please leave.";
            };

However I'm not getting any from the adminbase.sqf file. If you could add me on skype and help me with this last bit that would be amazing. I'll PM you my skype name
 
you got this working? I got too the "waiting for host" at dayz.st
Please can u share here if u got this working?
 
ya man i fix the wait for host but when i enter the area i get restricted script msg box pop up?

Code:
if ((getPlayerUID player) in ["xxxxxx" , "xxxxxxx" , "xxxxxxx" , "xxxxxxx" , "xxxxxxx"]) then {
titleText ["Welcome IDC Members. Please enjoy your stay.", "PLAIN DOWN", 3];
} else {
titleText ["You are entering a restricted area, LEAVE OR DIE", "PLAIN DOWN", 3];
sleep 10;
titleText ["You have less than 30 seconds to leave, THIS IS NO JOKE YOU WILL DIE!", "PLAIN DOWN", 3];
sleep 15;
removeAllWeapons player;
titleText ["You were warned!", "PLAIN DOWN", 3];
sleep 10;
titleText ["DIE!", "PLAIN DOWN", 3];
sleep 5;
player setDamage 1;
};
.
 
Back
Top