LunchboxCharlie Posted June 3, 2014 Report Share Posted June 3, 2014 We have AGN safe zones, but I believe this will work with just vanilla Dayz Epoch since the 'canbuild' function is from Epoch. Works perfect on our server (Doubletapdayz: Lunchbox and HisShadow). Special thanks to: Halvhjearne, who helped me fix my issue. You rock. Tested with: 1.0.4.2a and DZAI How it works: AI are removed when in range of the script while in a safe zone. Limitations: Player must be in a safe zone for it to run. safezoneai.sqf Quote // Despawn AI around safezones (Lunchbox). if (isNil 'no_ai_loop') then {no_ai_loop = true;}; while {true} do { waitUntil { !canbuild }; _pos = getPos (vehicle player); _nearunits = _pos nearEntities ["Man",50]; // Increase or decrease the number to adjust the range (in meters). _unitskilled=[]; { if ((_x in allunits) and !(_x in Agents) and !(_x in playableunits))then{ deletevehicle _x; }; } forEach _nearunits; sleep 1; }; Place file in the scripts folder, if it doesn't exist in your missions file create a folder called scripts. Paste into the isdedicated portion of your init.sqf of your missions file: [] execVM "scripts\safezoneai.sqf"; Link to comment Share on other sites More sharing options...
Csus Posted June 3, 2014 Report Share Posted June 3, 2014 nice idea :) a lot of the AI spawning scripts around use variables to detect and keep track of how many AI are currently spawned in, so, by just deleting the AI the script will never be told there is one less AI lurking around. after a while this could add up to whole groups of AI that simply won't reappear on the server until restart because the server has no clue there's more AI spawns available to it. I'd recommend teleporting the AI very high up somewhere and letting them fall to their death, this way the script can keep track of it. I made something like this for our server, using DZAI and I learned very quickly just how fast the server can become void of AI if you just delete them. Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 3, 2014 Author Report Share Posted June 3, 2014 nice idea :) a lot of the AI spawning scripts around use variables to detect and keep track of how many AI are currently spawned in, so, by just deleting the AI the script will never be told there is one less AI lurking around. after a while this could add up to whole groups of AI that simply won't reappear on the server until restart because the server has no clue there's more AI spawns available to it. I'd recommend teleporting the AI very high up somewhere and letting them fall to their death, this way the script can keep track of it. I made something like this for our server, using DZAI and I learned very quickly just how fast the server can become void of AI if you just delete them. I haven't experienced anything like that yet, I'll keep an eye on it. :) This will work fine with DZAI however. As soon as a player leaves the area it despawns them anyway and will respawn as soon as another player comes into the area. For the static spawns however, as for dynamic, I'll have to watch for it. Link to comment Share on other sites More sharing options...
Halvhjearne Posted June 3, 2014 Report Share Posted June 3, 2014 my experience its not good to have this running like this as it might delete a lot of unintended stuff ... what i did was add it to a hit event handeler and if its not a player or agent, then delete you can also do it this way, but i suggest you add (!isAgent _x) so it wont delete traders aswell Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 3, 2014 Author Report Share Posted June 3, 2014 my experience its not good to have this running like this as it might delete a lot of unintended stuff ... what i did was add it to a hit event handeler and if its not a player or agent, then delete you can also do it this way, but i suggest you add (!isAgent _x) so it wont delete traders aswell Yeah, I just found that out, lol. I had it in there originally, accidentally took it out (Probably for testing), but fixing it now. Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 3, 2014 Author Report Share Posted June 3, 2014 my experience its not good to have this running like this as it might delete a lot of unintended stuff ... what i did was add it to a hit event handeler and if its not a player or agent, then delete you can also do it this way, but i suggest you add (!isAgent _x) so it wont delete traders aswell isAgent isn't working for DZAI, back to the drawing board, lol. Link to comment Share on other sites More sharing options...
Halvhjearne Posted June 3, 2014 Report Share Posted June 3, 2014 isAgent isn't working for DZAI, back to the drawing board, lol. im not sure what you mean ... unless DZAI spawns agents instead of units (which i doubt very much), then this should work. as i see it the 3 obvius sollutions are: 1. add hit event handler to the player that will delete or ignore hits from ai while in safezone 2. add fired event handler to your ai and if in a safezone bullet is deleted (this will require a lot more work) 3. a while loop like you originally suggested, deleting units around the player that is not player or agent. Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 3, 2014 Author Report Share Posted June 3, 2014 im not sure what you mean ... unless DZAI spawns agents instead of units (which i doubt very much), then this should work. as i see it the 3 obvius sollutions are: 1. add hit event handler to the player that will delete or ignore hits from ai while in safezone 2. add fired event handler to your ai and if in a safezone bullet is deleted (this will require a lot more work) 3. a while loop like you originally suggested, deleting units around the player that is not player or agent. It does spawn them as units, however when I use: // Despawn AI around safezones (Lunchbox). if (isNil 'no_ai_loop') then {no_ai_loop = true;}; while {true} do { waitUntil { !canbuild }; _pos = getPosATL (vehicle player); _ai = _pos nearEntities ["Man",350]; // Change number for range. {if ((!isPlayer _x) && (!isAgent _x)) then {deletevehicle _x;};} forEach _ai; sleep 1; }; It doesn't work, for some odd reason which stumps me. Also added isagent without the exclamation mark, lol. Link to comment Share on other sites More sharing options...
Halvhjearne Posted June 4, 2014 Report Share Posted June 4, 2014 It does spawn them as units, however when I use: It doesn't work, for some odd reason which stumps me. Also added isagent without the exclamation mark, lol. not sure why it wont work for you ... it should work like that, but heres how i did it, the first time i attempted something like this: _pos = getPos (vehicle player); _nearunits = _pos nearEntities ["Man",50]; _unitskilled=[]; { if ((_x in allunits) and !(_x in Agents) and !(_x in playableunits))then{ deletevehicle _x; }; } forEach _nearunits; i think i still use simmular code to delete them in the hit event handler (just without the nearby check) Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 4, 2014 Author Report Share Posted June 4, 2014 not sure why it wont work for you ... it should work like that, but heres how i did it, the first time i attempted something like this: _pos = getPos (vehicle player); _nearunits = _pos nearEntities ["Man",50]; _unitskilled=[]; { if ((_x in allunits) and !(_x in Agents) and !(_x in playableunits))then{ deletevehicle _x; }; } forEach _nearunits; i think i still use simmular code to delete them in the hit event handler (just without the nearby check) Worked beautifully, thank you. :) Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 4, 2014 Author Report Share Posted June 4, 2014 nice idea :) a lot of the AI spawning scripts around use variables to detect and keep track of how many AI are currently spawned in, so, by just deleting the AI the script will never be told there is one less AI lurking around. after a while this could add up to whole groups of AI that simply won't reappear on the server until restart because the server has no clue there's more AI spawns available to it. I'd recommend teleporting the AI very high up somewhere and letting them fall to their death, this way the script can keep track of it. I made something like this for our server, using DZAI and I learned very quickly just how fast the server can become void of AI if you just delete them. I just checked, the deleted AI do re-spawn. Link to comment Share on other sites More sharing options...
Halvhjearne Posted June 4, 2014 Report Share Posted June 4, 2014 thanks for the credits, but this is nothing really and there is possibly a better way to do this ... also, it might not be the best idea to be dependent on canbuild ... that might end up deleteing ai in some unintended areas/situations Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted June 4, 2014 Author Report Share Posted June 4, 2014 thanks for the credits, but this is nothing really and there is possibly a better way to do this ... also, it might not be the best idea to be dependent on canbuild ... that might end up deleteing ai in some unintended areas/situations Yeah this is actually a temporary solution, which we will be building on. :) Link to comment Share on other sites More sharing options...
Halvhjearne Posted June 4, 2014 Report Share Posted June 4, 2014 You could look for "agent _x in Agents" but not for "_x in Agents" so this: !(_x in Agents). will always return true; This should be working fine: { if ((!isPlayer _x) && (!isNull (group _x))) then { deletevehicle _x; }; } forEach (player nearEntities ["Man",50]); and not sure about deleteVehicle at the moment because of:https://dev.withsix.com/issues/72574 im pretty sure i tested that quite thoroughly, when i first wrote that loop like a over a year ago (when i first started writing arma scripts) and im pretty sure that without this !(_x in agents), that loop was deleteing traders. edit: (tbh idk really know how agents work, the documentation is pretty scattered and does not make much sence, i would asume it is used in same manner as allunits or playableunits) today i would have prob did it more like this: { if (!(isPlayer _x) and !(isAgent _x))then{ deletevehicle _x; }; } forEach (player nearEntities ["Man",50]); Worked beautifully, thank you. :) btw, this is variable is uneeded and was from me doing some debug and counting the units i deleted, it is completely irrelevant to the script: _unitskilled=[]; Link to comment Share on other sites More sharing options...
Halvhjearne Posted June 4, 2014 Report Share Posted June 4, 2014 but you can only check "isAgent" on a teammember not a random unit :P however it is fine as long as it works :unsure: it seems you are right on that and thats propperbly why his original script did not work in the first place. actually i did not know that it only worked for team members and was assuming it was same use as isPlayer just for agents. (since this pretty much reduces its usefulness to nearly nothing). anyway my guess is this is still the best shot for now, since i dont belive an agent have a group afaik and even tho agents can be quite a large array to check: { if (!(isPlayer _x) and !(_x in Agents))then{ deletevehicle _x; }; } forEach (player nearEntities ["Man",50]); Link to comment Share on other sites More sharing options...
Buck0 Posted June 23, 2014 Report Share Posted June 23, 2014 it seems you are right on that and thats propperbly why his original script did not work in the first place. actually i did not know that it only worked for team members and was assuming it was same use as isPlayer just for agents. (since this pretty much reduces its usefulness to nearly nothing). anyway my guess is this is still the best shot for now, since i dont belive an agent have a group afaik and even tho agents can be quite a large array to check: { if (!(isPlayer _x) and !(_x in Agents))then{ deletevehicle _x; }; } forEach (player nearEntities ["Man",50]); deletes my traders :( Link to comment Share on other sites More sharing options...
Chris9183 Posted April 24, 2015 Report Share Posted April 24, 2015 I'd like to have this script working on my server...doesn't seem to work anymore. Anyone have any idea what needs to be changed for it to work? Link to comment Share on other sites More sharing options...
Guest Posted April 25, 2015 Report Share Posted April 25, 2015 Hi, that Script was not very well planned. A loop in a loop and double counting all units is not really needed. private ["_pos","_range"]; //_pos = [123,456,789]; _pos = getMarkerPos "MarkerName"; _range = 1000; { if(!(isAgent _x)) then { deletevehicle _x; }; } count (_pos nearEntities ["CaManBase", "Man", _range]); Link to comment Share on other sites More sharing options...
Chris9183 Posted April 25, 2015 Report Share Posted April 25, 2015 Unfortunately that script doesn't work...zombies everywhere in the trader zones. :( Link to comment Share on other sites More sharing options...
Guest Posted April 25, 2015 Report Share Posted April 25, 2015 Unfortunately that script doesn't work...zombies everywhere in the trader zones. :( It is for AI, not for Zombies :) Link to comment Share on other sites More sharing options...
Chris9183 Posted April 25, 2015 Report Share Posted April 25, 2015 I've looked everywhere for a "zombie shield" kind of script just for safe zones, but the ones I've tried must be outdated because they don't work. Just something that will despawn zombies in addition to AI if they enter a certain radius within the safe trader zones. I used to have a perfect script for this last year when I was playing, but of course since it worked so well, I'll never find it again. lol Link to comment Share on other sites More sharing options...
Halvhjearne Posted April 25, 2015 Report Share Posted April 25, 2015 I've looked everywhere for a "zombie shield" kind of script just for safe zones, but the ones I've tried must be outdated because they don't work. Just something that will despawn zombies in addition to AI if they enter a certain radius within the safe trader zones. I used to have a perfect script for this last year when I was playing, but of course since it worked so well, I'll never find it again. lol _pos = getPos (vehicle player); _zombies = _pos nearEntities ["zZombie_Base",50]; {deletevehicle _x;} forEach _zombies; Link to comment Share on other sites More sharing options...
Chris9183 Posted April 25, 2015 Report Share Posted April 25, 2015 _pos = getPos (vehicle player); _zombies = _pos nearEntities ["zZombie_Base",50]; {deletevehicle _x;} forEach _zombies; So if I drop this code into my AGN safe trader script it will work? Or does it need to be its own separate script? By looking at that code I assume it will despawn all zombies within a 50 yard radius of the safe zone? Link to comment Share on other sites More sharing options...
Guest Posted April 25, 2015 Report Share Posted April 25, 2015 No, that script will add a infinite zed shield on the player each time he enters a vehicle. Link to comment Share on other sites More sharing options...
Chris9183 Posted April 25, 2015 Report Share Posted April 25, 2015 No, that script will add a infinite zed shield on the player each time he enters a vehicle. Oh.. that's definitely not what I was looking for, but at least he was nice enough to try for me. I found what I was looking for though...I dug through an old nekro'd thread and found a script that, when added to AGN's safe zone script, despawns zombies around the trade zone when a player enters the trade zone. It's working. My server doesn't require plotpoles to build, so it shouldn't start despawning zombies when you get near someone else's buildings...assuming that's what the canbuild thing does. //DELETE ZOMBIES if (isNil "canbuild") then { canbuild = true; }; while {!canbuild} do { _entity_array = (getPos player) nearEntities ["CAManBase",100]; { if (_x isKindof "zZombie_Base") then { deletevehicle _x; }; } forEach _entity_array; sleep 4; }; //DELETE ZOMBIES Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now