Base AI Guards

blckeagls

New Member
This script spawns an AI in an area. When a specific player enters the area, the weapons are remove. When he leaves the area, the weapons are put back.

This is ran from my server_functions.sqf.

The AI Spawn, but weapons do not change.

Does anyone know what this doesn't work?

HTML:
waitUntil {count playableunits > 0};
private ["_ai1","_playernear","_playerUID","_aiGroup"];
_aiGroup = createGroup resistance;

_ai1 = ObjNull;
"Bandit1_DZ" createUnit [[6535,5600,0], _aiGroup, "_ai1=this", 1, "PRIVATE"];
_ai1 enableAI "TARGET";
_ai1 enableAI "AUTOTARGET";
_ai1 enableAI "MOVE";
_ai1 enableAI "ANIM";
_ai1 enableAI "FSM";
_ai1 allowDammage true;
_ai1 setCombatMode "RED";
_ai1 setBehaviour "COMBAT";
_ai1 addweapon "M24";
_ai1 addMagazine "5Rnd_762x51_M24";
_ai1 addMagazine "5Rnd_762x51_M24";
_ai1 addMagazine "5Rnd_762x51_M24";

if ((getPlayerUID player) in ["11030056"]) then {
    while {true} do {
        if (((player distance [6535,5600]) < 300)) then {
            waitUntil {(player distance [6535,5600]) > 300)};
                _ai1 addweapon "M24";
                _ai1 addMagazine "5Rnd_762x51_M24";
                _ai1 addMagazine "5Rnd_762x51_M24";
                _ai1 addMagazine "5Rnd_762x51_M24";
        };
       
        if (((player distance [6535,5600,0]) > 300)) then {
            waitUntil {(player distance [6535,5600,0]) < 300)};
                    removeAllWeapons _ai1;
        };
   
    };
};
 
Back
Top