dayZ (arma) AI Controlled Bus Route.

Need some help. Right now the bus spawns in Berezino, but doesn't go anywhere. If you try to get in, it instantly explodes. I'll post up everything I can to make this a quick fix. I think something is just out of place.

In my init I have...
if ((!isServer) && (isNull player) ) then
    waitUntil {!isNull player};
    waitUntil {time > 3};

if ((!isServer) && (player != player)) then
    waitUntil {player == player};
    waitUntil {time > 3};

if (isServer) then {
    //Bus Route
    [true] execVM "busroute\init_bus.sqf";
    _serverMonitor = [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
    "PVDZ_sec_atp" addPublicVariableEventHandler {
        _x = _this select 1;
        if (typeName _x == "STRING") then {
            diag_log _x;
        else {
            _unit = _x select 0;
            _source = _x select 1;
            if (((!(isNil {_source})) AND {(!(isNull _source))}) AND {((_source isKindOf "CAManBase") AND {(owner _unit != owner _source)})}) then {
                diag_log format ["P1ayer %1 hit by %2 %3 from %4 meters",
                    _unit call fa_plr2Str,  _source call fa_plr2Str, _x select 2, _x select 3];
                if (_unit getVariable["processedDeath", 0] == 0) then {
                    _unit setVariable [ "attacker", name _source ];
                    _unit setVariable [ "noatlf4", diag_ticktime ]; // server-side "not in combat" test, if player is not already dead

if (!isDedicated) then {[] execVM "Scripts\kh_actions.sqf";
    //Conduct map operations
    waitUntil {!isNil "dayz_loadScreenMsg"};
    dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");

    //Bus Route
    [] execVM "busroute\player_axeBus.sqf";

    //Run the player monitor
    _id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
    _playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
        "heliCrash" addPublicVariableEventHandler {
        _list = nearestObjects [_this select 1, ["CraterLong"], 100];
        {deleteVehicle _x;} foreach _list;
    if (dayz_antihack == 1) then {
    [] execVM "\z\addons\dayz_code\system\antihack.sqf";
Under //Check for hackers I have this
       "//Check for hackers" \n
       " {" \n
       "  if(vehicle _x != _x && !(vehicle _x in _safety) && (typeOf vehicle _x) != ""ParachuteWest"" && (vehicle _x getVariable [""DZAI"",0] != 1)) then {" \n
       "        diag_log (""CLEANUP: KILLING A HACKER "" + (name _x) + "" "" + str(_x) + "" IN "" + (typeOf vehicle _x));" \n
       "           (vehicle _x) setDamage 1;" \n
       "           _x setDamage 1;" \n
       "     };" \n
       " } forEach allUnits;" \n
       "" \n
       "dayz_serverObjectMonitor = _safety;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
I have tried it as [""Sarge"",0] and as [""DZAI"",0] (I run DZAI on my server. Could not get Sarges to work)

Oddly as well, somehow trying to add the ai bus has affected our admin tools because now when we spawn a vehicle it either disappears a few seconds after entering it or explodes instantly when you do.
Last edited:


Well-Known Member
The dzai thing in the check for hackers isnt correctly since your habe an old dzai update .

Cant remember exactly ,but i think you dont need the check for hacker thing with dzai since 1.8

Gesendet von meinem GT-I9100 mit Tapatalk
Hi Axeman

Love your ai bus stop service, thanks for sharing.

Just wondering if you ever got the horn beeping code to work. Tried pasting the code into init_bus.sqf & created hail_bus.sqf but there is no bus beeping....

Was I right to replace:
if (isServer) then {
//Bus Route
[true] execVM "busroute\init_bus.sqf";

if (!isDedicated) then {
//Bus Route
[] execVM "busroute\player_axeBus.sqf";
with this:
if (!isDedicated) then {
//Client Bus
    ["","","",[false,objNull]] execVM "busroute\init_bus.sqf";
thanks for your help

Beeping horn, this is a mixture of the horn beeping, testing lights flashing and trying to get the bus to stop for a survivor.

This bit of code is under testing and am not sure how it will work on a busy live server as it currently creates a gameLogic for each survivor just to beep the horn. Would like to try creating a gameLogic with the server and try and use that, or detect an existing gameLogic.

if (!isDedicated) then {
//Client Bus
    ["","","",[false,objNull]] execVM "busroute\init_bus.sqf";
private ["_center","_group","_pos","_gameLogic","_player","_objBus","_isBus","_nrPlayer","_range","_busVar","_beepHorn","_axBusDriver","_beepCount","_busObj"];

_array = _this select 3;
_player = _array select 1;
_range = 25;
_beepCount = 0;
_center = createCenter sideLogic;
_group = createGroup _center;
_pos = [0, 0, 0];
_gameLogic = _group createUnit ["LOGIC",_pos , [], 0, ""];
//_beepHorn = compile loadFile "busroute\beep_horn.sqf";
while {true}
    if (!isNull player) then
        _nrPlayer = vehicle player;
        _objBus = nearestObjects [_nrPlayer, ["Ikarus_TK_CIV_EP1"], _range];
        if(count _objBus >0)then{
                if(str(_x getVariable ["axBusGroup","NONE"]) != "NONE")then{
                hint format ["Bus Found: Vel:%1",velocity _x];
                sleep .5;
                //[_nrPlayer,_objBus] call _beepHorn;
                _axBusDriver = driver _x;
                //Beep Horn
                    if(_nrPlayer distance _x >10 && _beepCount < 3)then{
                    _gameLogic action ["useWeapon",_x,_axBusDriver,0];
                    _gameLogic action ["useWeapon",_x,_axBusDriver,1];
                    _gameLogic action ["useWeapon",_x,_axBusDriver,2];
                    hint format["Beeping Horn:Count:%1",_beepCount];
                    sleep .5;
                //Try to Flash Lights (Not yet tested at night). Needs time detection or just night time flashing ?
                    _axBusDriver action ["LightOn",_x];
                    sleep .3;
                    _axBusDriver action ["LightOff",_x];
                    _busObj = _x;
            }forEach _objBus;
        _isBus = false;
        player removeAction axeHailBus;
        if (_player != player && _isBus) then
            _player = player;
            axeHailBus = player addAction ["<t color=""#ffff33"">" + ("Hail Bus") + "</t>", "busroute\hail_bus.sqf",[_busObj,_gameLogic],-19,false];
And hail_bus.sqf
_array=_this select 3;
_bus = _array select 0;
_gameLogic = _array select 1;
_waitTime = 25;
_finTime = time + _waitTime;
_axBusDriver = driver _bus;
_gameLogic action ["useWeapon",_bus,_axBusDriver,0];
player removeAction axeHailBus;
_nspeed_x = 0;
_nspeed_y = 0;
axBus lockDriver false;
_axBusDriver assignAsCargo axBus;
_axBusDriver moveInCargo axBus;
axBus lockDriver true;
//_axBusDriver disableAI "MOVE";
//_axBusDriver stop true;
while {!_done}
_speed_x = (velocity _bus) select 0;
_speed_y = (velocity _bus) select 1;
if (_speed_x > 0) then {_nspeed_x = _speed_x / 1.01;};
if (_speed_y > 0) then {_nspeed_y = _speed_y / 1.01;};
_bus setVelocity [_nspeed_x,_nspeed_y,0];//Not yet tried setting velocity to driver
sleep .1;
axBus lockDriver false;
_axBusDriver assignAsDriver axBus;
_axBusDriver moveInDriver axBus;
axBus lockDriver true;
_gameLogic action ["useWeapon",_bus,_axBusDriver,0];
sleep .1;
//_axBusDriver enableAI "MOVE";
//_axBusDriver stop false;
Here is a set of test wayPoints (for Chernarus)
axBusRouteWaypoints = [[12981.6,10062.9,_axWPZ],[12963.9,10209.5,_axWPZ]];//Test Waypoints
The bus will loop the block at the start point..
I had this back when there were AI forces that attacked players who shot at the bus....miss those days. Used it on a Chernarus Life server (HNSC Life) and it gave quite a scare; at one point the choppers and HMMWVs destroyed the military base because they fired on the bus, it was quite hilarious. Otherwise, great work, and I'll be making some changes and posting them on here soon.
There was the question in this thread how to add a marker to the moving bus, so anyone can check where it is actually.
This would be a really cool feature, but unfortunately I'm not a scripter at all to achieve this.

Maybe someone can have a look at the Radio Communication Script:
The code for this purpose is in there, but how to implement it to the Bus Script?
Thx in advance!


Well-Known Member
It's not hard to do.

Put a while loop in that watches for the bus to be alive.

Inside it, delete the waypoint, them place the waypoint, the sleep for a second or so and let it loop.
There was the question in this thread how to add a marker to the moving bus, so anyone can check where it is actually.
This would be a really cool feature, but unfortunately I'm not a scripter at all to achieve this.

Maybe someone can have a look at the Radio Communication Script:
The code for this purpose is in there, but how to implement it to the Bus Script?
Thx in advance!
Also a modified admin tools esp script could work,maybe need the player have gps to track bus
Well, nice, thx for your answers.
From the logical I understand how it would work, but as I pointed out I'm no scripter and really don't know how to set up these little lines of code...
From the RC script I dragged this code:
RC_addMarker = {
  _unit = _this select 0;
  _index = _this select 1;
  _pos = getPosASL _unit;
  _pos resize 2;
  _marker = createMarkerLocal [_index, _pos];
  _index setMarkerTypeLocal RC_markerType;
  if (RC_markerShowName) then {
     _index setMarkerTextLocal name _unit;
  _index setMarkerColorLocal RC_markerColor;
  _index setMarkerAlphaLocal RC_markerAlpha;
  _index setMarkerDirLocal getDir _unit;
  _index setMarkerSizeLocal [RC_markerSize,RC_markerSize];
  _index setMarkerPosLocal _pos;
Also this code could be useful maybe?
[] spawn {
while {not isnull unit} do { "markerUnit" setmarkerpos getpos unit; sleep 0.5; };
Maybe someone can put these things together?
Thx again...
in the script that creates the bus, assingn a name to the bus itself such as theBus.

now create a script called busloc.sqf and in your init.sqf
execvm "busloc.sqf";

the busloc.sqf file

if (isserver) exitwith{};
while (true) do {
_markerpos = createmarker["buslocation",getpos theBus];
sleep 1;
and of course you have to add some cod e for the marker type etc.
Last edited:
yeah, ...
put that first in the code block so it deletes then creates a new one.
I don't think it would matter if the bus object is null, would just be no marker. and a few errors in the log during startup. Unless the bus gets destroyed ....
Well, first of all the bus is indestructable!
I'm not sure how to assign a name for the bus.
Should it look like this?
thebus = "Ikarus_TK_CIV_EP1";
The bus script itself includes these code lines already:
_axeBusUnit = objNull;
_axeBus = "Ikarus_TK_CIV_EP1" createVehicle _axeBuspawnpos;
Here is the whole file:
  private ["_axeBusUnit","_firstRun","_dir","_axWPZ","_unitpos","_rndLOut","_ailoadout","_aiwep","_aiammo","_axeBus","_axeBusGroup","_axeBuspawnpos","_axeBusWPradius","_axeBusWPIndex","_axeBusFirstWayPoint","_axeBusWP","_axeBusRouteWaypoints","_axeBusDriver","_axeBusLogicGroup","_axeBusLogicCenter"];
   _axeBusUnit = objNull;
//   _axeBusGroup = createGroup RESISTANCE;
   _axeBusGroup = createGroup WEST;
   _axeBuspawnpos = [13128.2,10381.9,0];
   _unitpos = [13125.2,10416,0];
   _axeBusWPradius = 2;//waypoint radius
   _axeBusDriver = objNull;
   //Set Sides
   _firstRun = _this select 0;
   createCenter RESISTANCE;
   RESISTANCE setFriend [WEST,1];//Like Survivors..
   RESISTANCE setFriend [EAST,0];//Don't like banditos !
   WEST setFriend [RESISTANCE,1];
   EAST setFriend [RESISTANCE,0];
   //Load Bus Route
   _axeBusWPIndex = 2;
   _axeBusFirstWayPoint = [13101.4,10339.1,_axWPZ];
   _axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex];
   _axeBusWP setWaypointType "MOVE";
   _axeBusRouteWaypoints = [[12984,8362.67,_axWPZ],[13279.1,6991.32,_axWPZ],[13464.2,6255.24,_axWPZ],[13386.8,5405.25,_axWPZ],[12025.6,3481.76,_axWPZ],[10504.4,2324.99,_axWPZ],[10321.8,2149.75,_axWPZ],[10028,2071.8,_axWPZ],[9503.53,2028.21,_axWPZ],[6587.65,2884.59,_axWPZ],[6354.47,2452.24,_axWPZ],[4565.79,2432.13,_axWPZ],[1907.21,2240.25,_axWPZ],[1689.06,2209.53,_axWPZ],[1845.55,2219.14,_axWPZ],[1940.8,2255.24,_axWPZ],[3559.56,2448.9,_axWPZ],[4541.37,2443.16,_axWPZ],[5816.09,2167.39,_axWPZ],[6408.19,2685.99,_axWPZ],[6570.5,2877.59,_axWPZ],[9945.28,2049.85,_axWPZ],[10283.4,2146.71,_axWPZ],[10389.4,2221.85,_axWPZ],[10498.9,2320.29,_axWPZ],[10888.2,2772.58,_axWPZ],[12025.9,3485.04,_axWPZ],[13005.9,3816.02,_axWPZ],[13451.5,6211.28,_axWPZ],[13419.9,6557.19,_axWPZ],[13287.7,6961.19,_axWPZ],[12930.4,10133,_axWPZ]];
   _axeBusWP = _axeBusGroup addWaypoint [_x, _axeBusWPradius,_axeBusWPIndex];
   _axeBusWP setWaypointType "MOVE";
   _axeBusWP setWaypointTimeout [20, 30, 35];
   diag_log format ["BUS:Waypoint Added: %2 at %1",_x,_axeBusWP];
   } forEach _axeBusRouteWaypoints;
   //Create Loop Waypoint
   _axeBusWP = _axeBusGroup addWaypoint [_axeBusFirstWayPoint, _axeBusWPradius,_axeBusWPIndex+1];
   _axeBusWP setWaypointType "CYCLE";
   //Create Bus
   _dir = 244;
   _axeBus = "Ikarus_TK_CIV_EP1" createVehicle _axeBuspawnpos;
   _axeBus setDir _dir;
  _axeBus setPos getPos _axeBus;
  _axeBus setVariable ["ObjectID", [_dir,getPos _axeBus] call dayz_objectUID2, true];
  _axeBus setFuel .3;
   _axeBus allowDammage false;
   //Uncomment for normal dayZ
   //dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_axeBus];
   //For Epoch - Comment out for normal dayZ | Credit to Flenz
   PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_axeBus];
   [_axeBus,"Ikarus_TK_CIV_EP1"] spawn server_updateObject;
   //Make Permanent on some builds.. No Need really,
   //dayzSaveVehicle = _axeBus;
   //publicVariable "dayzSaveVehicle";
   _axeBus addEventHandler ["HandleDamage", {false}];   
   _axeBus setVariable ["axBusGroup",_axeBusGroup,true];
   _axeBus setVariable ["isAxeAIBus",1,true];
   //Create Driver and Drivers Mate
   for [{ x=1 },{ x <3 },{ x = x + 1; }] do {
     _rndLOut=floor(random 3);
     switch (_rndLOut) do
      case 0: {["AK_47_M","30Rnd_762x39_AK47"]};
      case 1: {["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD"]};
      case 2: {["Remington870_lamp","8Rnd_B_Beneli_74Slug"]};
     "BAF_Soldier_L_DDPM" createUnit [_unitpos, _axeBusGroup, "_axeBusUnit=this;",0.6,"Private"];
     _axeBusUnit enableAI "TARGET";
     _axeBusUnit enableAI "AUTOTARGET";
     _axeBusUnit enableAI "MOVE";
     _axeBusUnit enableAI "ANIM";
     _axeBusUnit enableAI "FSM";
     _axeBusUnit allowDammage true;

     _axeBusUnit setCombatMode "GREEN";
     _axeBusUnit setBehaviour "CARELESS";
     //clear default weapons / ammo
     removeAllWeapons _axeBusUnit;
     //add random selection
     _aiwep = _ailoadout select 0;
     _aiammo = _ailoadout select 1;
     _axeBusUnit addweapon _aiwep;
     _axeBusUnit addMagazine _aiammo;
     _axeBusUnit addMagazine _aiammo;
     _axeBusUnit addMagazine _aiammo;

     //set skills
     _axeBusUnit setSkill ["aimingAccuracy",1];
     _axeBusUnit setSkill ["aimingShake",1];
     _axeBusUnit setSkill ["aimingSpeed",1];
     _axeBusUnit setSkill ["endurance",1];
     _axeBusUnit setSkill ["spotDistance",0.6];
     _axeBusUnit setSkill ["spotTime",1];
     _axeBusUnit setSkill ["courage",1];
     _axeBusUnit setSkill ["reloadSpeed",1];
     _axeBusUnit setSkill ["commanding",1];
     _axeBusUnit setSkill ["general",1];
     _axeBusUnit assignAsCargo _axeBus;
     _axeBusUnit moveInCargo _axeBus;
     _axeBusUnit addEventHandler ["HandleDamage", {false}];
     _axeBusGroup selectLeader _axeBusUnit;
     _axeBusDriver = _axeBusUnit;
     _axeBusDriver addEventHandler ["HandleDamage", {false}];
     _axeBus addEventHandler ["killed", {[false] execVM "custom\busroute\init_bus.sqf"}];//Shouldn't be required
     //Test - Allow dev time to get in bus
     sleep 36;
     _axeBusUnit assignAsDriver _axeBus;
     _axeBusUnit moveInDriver _axeBus;
   waitUntil{!isNull _axeBus};
   //diag_log format ["AXLOG:BUS: Bus Spawned:%1 | Group:%2",_axeBus,_axeBusGroup];
   //Monitor Bus
   while {alive _axeBus} do {
   //diag_log format ["AXLOG:BUS: Tick:%1",time];
     //Fuel Bus
     if(fuel _axeBus < 0.2)then{
     _axeBus setFuel 0.3;
     //diag_log format ["AXLOG:BUS: Fuelling Bus:%1 | Group:%2",_axeBus,_axeBusGroup];
     //Keep Bus Alive - Shouldn't be required.
     if(damage _axeBus>0.4)then{
     _axeBus setDamage 0;
     //diag_log format ["AXLOG:BUS: Repairing Bus:%1 | Group:%2",_axeBus,_axeBusGroup];
     //Monitor Driver
     if((driver _axeBus != _axeBusDriver)||(driver _axeBus != _axeBusUnit))then{
     //diag_log format ["AXLOG:BUS: Driver Required:%1",driver _axeBus];
     units _axeBusGroup select 0 assignAsDriver _axeBus;
     units _axeBusGroup select 0 moveInDriver _axeBus;

   sleep 3;
that line that says _axbus = createvehicle ...
put a line after that.
theBus = _axbus;

the difference between _axbus and theBus is that a variable that starts with an underscore is a local variable, its only visible in the file its declared in. when you create a variable without an underscore its global and can be accessed from any other file on the computer.


Well-Known Member
There are some wonderfull tutorials on scrippting in Arma 2. You should read a few. I would start with variables. It will make a big difference to you.
Sure, but unfortunately I haven't that much time due to work and other server stuff to learn more about scripting.
Even when I would learn a bit about this stuff I would never be able to write a script on my own.
Also, all that code and brackets are really confusing and annoying sometimes, happened so often that I forgot a damn bracket and I had to restart the server again, apologizing to the peeps online...

But however, I would really appreciate some help again to set up the marker for it.
I know some commands and I also checked Bohemia sites for them, but I didn't figure out how to use them in the correct way.

I tried this and failed, nothing popped up:
if (isserver) exitwith{};
while (true) do {
_markerpos = createmarker["MTVR",getpos theBus];
"MTVR" setMarkerType "mil_dot";
"MTVR" setMarkerColor "ColorRed";
sleep 1;
I even don't know if it's the right file to assign the marker...
The theBus = _axbus; I put in the way you told me.