Jump to content

Narines

Member
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Narines

  1. Nice it is working. But after putting the code it in the init.sqf inside my missionPBO folder my custom mapmarker will not work anymore.

    I start them by using null =[] execVm "SR.sqf"; in the same init.sqf.

    Any ideas why this happening to me? Removing the code from you will turn everything back and it is working fine again.

     

    greetz

    lahlor

     

    Woah. Guess I was more tired than I thought when I posted this last night.

     

    I forgot a ';' at the end of 'if(isServer)then{};'.

     

    The code you should put at the top of your init.sqf is the following :

    if (isServer) then {
    
        execVM "\q\addons\traderATMs\init.sqf";
    
    };
    

    Will update the info in my previous posts. Real sorry for that. 

  2. BE filter scripts? as my players are getting kicked off

     

    If it kicks you players, it is because you didnt call the sqf inside the "if(isServer)then{}" condition.

     

    Make sure you put the exact code below on the first line of your init.sqf 

     

     **NOTE - I changed the installation method so make sure you are using the new method or the following code won't work. Check initial post for installation instructions.**

    if (isServer) then {
    
        execVM "\q\addons\traderATMs\init.sqf";
    
    };
    
  3. Surely an even better place for it would be creating an atms.sqf inside a custom pbo in @Epochhive\addons\ - I run all my map edits from there, and it seems to work quite well :)

     

    It would be a better place since it wouldn't add to the mission file size.

    Thx for the suggestion, I am just starting with arma 3 scripting.

     

    **EDIT - I applied your suggestions and changed the installation instructions in initial post. Thanks**

  4. Same problem here with the map vehicles being inaccessible after about 30 minutes into a server start.  The vehicles will be there and if no one has interacted with them before the 25-30 minute mark you will be able to get into the vehicle but thats it.  Once in you cant get out, move, start engine, etc.  Going to lobby and coming back in puts you outside the vehicle but if you try to delete the vehicle with admin tools a "object does not exist" message appears.

     

    This is a good mission add on but with vehicles getting bugged after 25 minutes or so we cant run on the server  :(

     

    I don't have this problem. I even made tests on my local server where I kill AI, get vehicle, lock vehicle, delog, restart server, relog and wait for 1h before interacting with it. Still working fine.

  5. Hi ! First, thank you for your great script !

     

    I've been using it on my server and I made a few modifications that solves a couple of problems.

     

    More precisely, I found why the AI was not behaving normally.

     

    It had to do with the fact that you were calling setcombatmode "RED"; on a unit instead of a group. (https://community.bistudio.com/wiki/setCombatMode). Thanks to Mister T for his script "Roaming AI in towns". That's where I got the hint from.

     

    I also changed how spawnVehicle is called to make sure that the AI controlling the vehicles are in the same group than the other AIs. This way, they strat chasing the player if he hits any other target.

     

    I thought I would share this with the community so here is the link for the updated "custom_server.pbo" file.

     

    https://dl.dropboxusercontent.com/u/63143678/custom_server.zip

     

    Here is, in more details, the modifications I made (I added comments starting with //NARINES// for every modification I made):

    AI.sqf (same with AI1.sqf)

    //Defines private variables so they don't interfere with other scripts
    private ["_pos","_i","_weap","_ammo","_other","_skin","_aiGroup","_ai1","_magazines","_players","_owner","_ownerOnline","_nearEntities"];
    
    //Gets variables passed from spawnai.sqf/spawnai1.sqf
    _pos = _this select 0;
    _weap = _this select 1;
    _ammo = _this select 2;
    _other = _this select 3;
    _skin = _this select 4;
    _aiGroup = _this select 5;
    
    //NARINES// - ADDED THOSE 3 LINES
    _aiGroup setcombatmode "RED";
    _aiGroup allowfleeing 0;
    _aiGroup setspeedmode "FULL";
    
    //Creating the AI Unit
    _ai1 = ObjNull;
    //Creates the AI unit from the _skin passed to it
    "i_g_soldier_unarmed_f" createUnit [_pos, _aiGroup, "_ai1 = this", 0.7, "COLONEL"];
    //Cleans the AI to a fresh spawn
    removeBackpackGlobal _ai1;
    removeAllItemsWithMagazines  _ai1;
    //_ai1 AddUniform _skin;
    _ai1 forceAddUniform _skin;
    
    //Stops the AI from being cleaned up
    _ai1 setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai1 setVariable["LAST_CHECK",1000000000000];
    
    //Sets AI Skills
    _ai1 enableAI "TARGET";
    _ai1 enableAI "AUTOTARGET";
    _ai1 enableAI "MOVE";
    _ai1 enableAI "ANIM";
    _ai1 enableAI "FSM";
    _ai1 allowDammage true;
    //NARINES// - REMOVED THE FOLLOWING
    //_ai1 setCombatMode "RED"; 
    _ai1 setBehaviour "COMBAT";
    
    sleep 1; //For some reason without this sometimes they don't spawn the weapon on them
    
    //Adds 5 magazines to AI Unit
    _ai1 addMagazine _ammo;
    _i = 0;
    while {_i < 4} do {
        _i = _i + 1;
        _ai1 addItem _ammo;
    };
    
    
    //Adds the weapon specified to it from spawnai.sqf/spawnai1.sqf
    _ai1 addWeaponGlobal  _weap;
    //diag_log format["AI1.sqf - AI %2 to recieve this weapon: %1",_weap,_ai1];// For debug
    sleep 1; //For some reason without this sometimes they don't spawn the weapon on them
    //_currentweapon = currentMuzzle _ai1;// For debug
    //diag_log format["AI1.sqf - AI %2 recieved this weapon: %1",_currentweapon,_ai1];// For debug
    
    
    //adds items to AI.  _other = ["ITEM","COUNT"]
    _i = 0;
    while {_i < (_other select 1)} do {
        _i = _i + 1;
        _ai1 addItem (_other select 0)
    };
    
    //Sets a variable that this is an AI... Can be used for other scipts to determine if its an AI unit
    _ai1 setVariable ["AI",true,true];
    
    //Gives the AI unlimited Ammo
    _ai1 addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
    
    
    //AI Cleanup script
    _ai1 spawn {
        waitUntil{!alive _this};
        _this setOwner 1;
        sleep blck_aiCleanUpTimer;
        deleteVehicle _this;
    };
    
    //NARINES// - REMOVED THE FOLLING BLOCK. I ASSUME IT IS USELESS SINCE EPOCH FIXED THE AI NOT DAMAGING THE PLAYER
    /*//Prevents players from having AI God Mode
    while {true} do {
        _players = [];
        _nearEntities = count (_ai1 nearEntities [["MAN"],1000]);
        //diag_log format["_nearEntities: %1",_nearEntities];  //Used for testing
        {
            if (isPlayer _x) then {
             _players = _players + [_x];
            };
        } foreach (_ai1 nearEntities [["MAN"],1000]);
        //diag_log format["Nearplayers: %1",_players]; //Used for testing
        if ((count _players) > 0) then {
            _owner = _players call BIS_fnc_selectRandom;
            _ai1 setOwner (owner _owner);
        };
        //diag_log format["_ai1 %2 Owner: %1",owner _ai1, _ai1]; //Used for testing
        waitUntil{_nearEntities != count (_ai1 nearEntities [["MAN"],1000])};
    };*/
    

     

    spawnVehicle.sqf

    //Debug information
    diag_log format["SpawnVehicles _this: %1",_this];
    
    //Gets position information from spawnai1.sqf
    _pos = _this select 0;
    
    //Creates a group for Vehicles
    //NARINES// - REMOVED THE FOLLOWING
    //_aiGroup = createGroup RESISTANCE; 
    
    //NARINES// -ADDED THE FOLLOWING
    _aiGroup = _this select 1;
    
    //NARINES// - ADDED THE FOLLOWING 3 LINES
    _aiGroup setcombatmode "RED";
    _aiGroup allowfleeing 0;
    _aiGroup setspeedmode "FULL";
    
    _ai = ObjNull;
    
    //Finds a safe positon in area to spawn
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    
    //Spawns 1 AI Unit
    "O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai = this", 0.1, "PRIVATE"];
    removeBackpackGlobal _ai;
    removeAllItemsWithMagazines  _ai;
    _ai setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai setVariable["LAST_CHECK",1000000000000];
    _ai enableAI "TARGET";
    _ai enableAI "AUTOTARGET";
    _ai enableAI "MOVE";
    _ai enableAI "ANIM";
    _ai enableAI "FSM";
    _ai allowDammage true;
    _ai setCombatMode "RED";
    _ai setBehaviour "COMBAT";
    _ai setVariable ["AI",true,true];
    
    
    //Spawns 1 AI Unit
    _ai1 = ObjNull;
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    "O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai1 = this", 0.1, "PRIVATE"];
    removeBackpackGlobal _ai1;
    removeAllItemsWithMagazines  _ai1;
    _ai1 setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai1 setVariable["LAST_CHECK",1000000000000];
    _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 setVariable ["AI",true,true];
    
    
    //Spawns 1 AI Unit
    _ai2 = ObjNull;
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    "O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai2 = this", 0.1, "PRIVATE"];
    removeBackpackGlobal _ai2;
    removeAllItemsWithMagazines  _ai2;
    _ai2 setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai2 setVariable["LAST_CHECK",1000000000000];
    _ai2 enableAI "TARGET";
    _ai2 enableAI "AUTOTARGET";
    _ai2 enableAI "MOVE";
    _ai2 enableAI "ANIM";
    _ai2 enableAI "FSM";
    _ai2 allowDammage true;
    _ai2 setCombatMode "RED";
    _ai2 setBehaviour "COMBAT";
    _ai2 setVariable ["AI",true,true];
    
    
    //Spawns 1 AI Unit
    _ai3 = ObjNull;
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    "O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai3 = this", 0.1, "PRIVATE"];
    removeBackpackGlobal _ai3;
    removeAllItemsWithMagazines  _ai3;
    _ai3 setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai3 setVariable["LAST_CHECK",1000000000000];
    _ai3 enableAI "TARGET";
    _ai3 enableAI "AUTOTARGET";
    _ai3 enableAI "MOVE";
    _ai3 enableAI "ANIM";
    _ai3 enableAI "FSM";
    _ai3 allowDammage true;
    _ai3 setCombatMode "RED";
    _ai3 setBehaviour "COMBAT";
    _ai3 setVariable ["AI",true,true];
    
    //Spawns 1 AI Unit
    _ai4 = ObjNull;
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    "O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai4 = this", 0.1, "PRIVATE"];
    removeBackpackGlobal _ai4;
    removeAllItemsWithMagazines  _ai4;
    _ai4 setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai4 setVariable["LAST_CHECK",1000000000000];
    _ai4 enableAI "TARGET";
    _ai4 enableAI "AUTOTARGET";
    _ai4 enableAI "MOVE";
    _ai4 enableAI "ANIM";
    _ai4 enableAI "FSM";
    _ai4 allowDammage true;
    _ai4 setCombatMode "RED";
    _ai4 setBehaviour "COMBAT";
    _ai4 setVariable ["AI",true,true];
    
    
    //Spawns 1 AI Unit
    _ai5 = ObjNull;
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    "O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai5 = this", 0.1, "PRIVATE"];
    removeBackpackGlobal _ai5;
    removeAllItemsWithMagazines  _ai5;
    _ai5 setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _ai5 setVariable["LAST_CHECK",1000000000000];
    _ai5 enableAI "TARGET";
    _ai5 enableAI "AUTOTARGET";
    _ai5 enableAI "MOVE";
    _ai5 enableAI "ANIM";
    _ai5 enableAI "FSM";
    _ai5 allowDammage true;
    _ai5 setCombatMode "RED";
    _ai5 setBehaviour "COMBAT";
    _ai5 setVariable ["AI",true,true];
    
    
    //Spawns a AI Vehicle
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    _veh = ObjNull;
    _veh = createVehicle["B_G_Offroad_01_armed_F", _safepos, [], 0, "NONE"];
    _veh setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _veh setVariable["LAST_CHECK",1000000000000];
    //Moves 2 AI units into vehicle
    _ai moveInAny _veh;
    _ai1 moveInAny _veh;
    //So Vehicle doesnt despawn
    EPOCH_VehicleSlotsLimit = EPOCH_VehicleSlotsLimit + 1;
    EPOCH_VehicleSlots pushBack str(EPOCH_VehicleSlotsLimit);
    _slot = EPOCH_VehicleSlots select 0;
    _veh setVariable ['VEHICLE_SLOT',_slot,true];
    EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
    EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
    publicVariable 'EPOCH_VehicleSlotCount';
    _veh call EPOCH_server_setVToken;
    //Creates vehicle inventory
    clearWeaponCargoGlobal    _veh;
    clearMagazineCargoGlobal  _veh;
    clearBackpackCargoGlobal  _veh;
    clearItemCargoGlobal       _veh;
    
    
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    _veh = ObjNull;
    _veh = createVehicle["B_G_Offroad_01_armed_F", _safepos, [], 0, "NONE"];
    _veh setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _veh setVariable["LAST_CHECK",1000000000000];
    _ai2 moveInAny _veh;
    _ai3 moveInAny _veh;
    EPOCH_VehicleSlotsLimit = EPOCH_VehicleSlotsLimit + 1;
    EPOCH_VehicleSlots pushBack str(EPOCH_VehicleSlotsLimit);
    _slot = EPOCH_VehicleSlots select 0;
    _veh setVariable ['VEHICLE_SLOT',_slot,true];
    EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
    EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
    publicVariable 'EPOCH_VehicleSlotCount';
    _veh call EPOCH_server_setVToken;
    clearWeaponCargoGlobal    _veh;
    clearMagazineCargoGlobal  _veh;
    clearBackpackCargoGlobal  _veh;
    clearItemCargoGlobal       _veh;
    
    _safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
    _veh = ObjNull;
    _veh = createVehicle["B_G_Offroad_01_armed_F", _safepos, [], 0, "NONE"];
    _veh setVariable["LASTLOGOUT_EPOCH",1000000000000];
    _veh setVariable["LAST_CHECK",1000000000000];
    _ai4 moveInAny _veh;
    _ai5 moveInAny _veh;
    EPOCH_VehicleSlotsLimit = EPOCH_VehicleSlotsLimit + 1;
    EPOCH_VehicleSlots pushBack str(EPOCH_VehicleSlotsLimit);
    _slot = EPOCH_VehicleSlots select 0;
    _veh setVariable ['VEHICLE_SLOT',_slot,true];
    EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
    EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
    publicVariable 'EPOCH_VehicleSlotCount';
    _veh call EPOCH_server_setVToken;
    clearWeaponCargoGlobal    _veh;
    clearMagazineCargoGlobal  _veh;
    clearBackpackCargoGlobal  _veh;
    clearItemCargoGlobal       _veh;
    

     

    spawnai.sqf (same with spawnai1.sqf)

    //Sets Private Variables to they don't interfere when this script is called more than once
    private["_pos","_weaponlist","_ammolist","_skinlist","_itemlist","_randomNumberWeapon","_randomNumberSkin","_randomNumberItem","_numbertospawn","_whichweap","_whichitem","_whichskin","_weapon","_ammo","_item","_skin","_i"];
    
    //Gets variables passed form SM1.sqf
    _pos = _this select 0;
    _numai1 = _this select 1;
    _numai2 = _this select 2;
    _weaponList = _this select 3;
    _spawnVehicle = _this select 4;
    
    //Spawns correct ammount of AI
    if (_numai2 > _numai1) then {
        _numbertospawn = floor( (random (_numai2 - _numai1) + _numai1 ) );
    } else {
        _numbertospawn = _numai2;
    };
    
    //Creates a group to make them attack players
    _aiGroup = createGroup RESISTANCE;    
    
    //Counter variable
    _i = 0;
    
    //Spawns the correct number of AI Units
    while {_i < _numbertospawn} do {
        _i = _i + 1;
        
        
        //Weapons Selects    
        _whichweap = _weaponList call BIS_fnc_selectRandom;
        //diag_log format["AI Got this weapon array: %1",_whichweap];// For debug
        
        //assigns class name based on random number generated
        _weapon = _whichweap select 0;
        //diag_log format["AI Got this weapon: %1",_weapon];// For debug
        
        //This isnt reall needed anymore -- but it needs to have something passed
        _ammo = _whichweap select 1;
        //diag_log format["AI Got this weapon magazine: %1",_ammo];// For debug
        
        //Selects a random item from blck_AIItemList to add to the AI...
        _item = blck_AIItemList call BIS_fnc_selectRandom;
        //diag_log format["AI Got this item: %1",_item];// For debug
        
        //Selects a random skin
        _skin = blck_SkinList call BIS_fnc_selectRandom;
        //diag_log format["AI Got this skin: %1",_skin];// For debug
        
        //Finds a safe positon to spawn the AI in the area given
        _safepos = [_pos,0,27,1,0,2000,0] call BIS_fnc_findSafePos;
        
        //Spawns the AI units
        [_safepos,_weapon,_ammo,_item,_skin,_aiGroup] execVM "\q\addons\custom_server\AIMission\AI1.sqf";
    };
    
    
    if (_spawnVehicle) then {
        //Finds  a safe postion to spawn the vehicles
        _safepos = [_pos,0,27,1,0,2000,0] call BIS_fnc_findSafePos;
        //Spawns the vehicles
    //NARINES// - REMOVED THE FOLLOWING
    //[_safepos] execVM "\q\addons\custom_server\AIMission\spawnVehicle.sqf";
    //NARINES// - ADDED THE FOLLOWING
        [_safepos, _aiGroup] execVM "\q\addons\custom_server\AIMission\spawnVehicle.sqf";
    };
    

  6. Hi,

     

    This script is extremely simple.

     

    1 - In '@epochhive/addons' add the following pbo (traderATMs.pbo) :

     

    https://dl.dropboxusercontent.com/u/63143678/epoch_scripts/traderATMs.pbo

     

    2 - In your 'MPMissions' folder, unpack 'epoch.Altis.pbo'

     

    3 - In your unpacked 'epoch.Altis' folder, open init.sqf and add the following at the very top :

    if (isServer) then {
        execVM "\q\addons\traderATMs\init.sqf";
    };
    

    Note : if there is no init.sqf in the root of your unpacked 'epoch.Altis' folder, just create one.

     

    4 - Repack 'epoch.Altis' into 'epoch.Altis.pbo'

     

    That's it !

     

    **EDIT** Optimized following Kroenen's suggestions

×
×
  • Create New...