Close all doors on server startup

roarnesbo

Member
Hi! Found this old post on the ofpec forums. Its just one reply with a "solution", and its like this:
Code:
Huh,
I see, this is an old one. So what, I'm gonna reply anyway.
Closing doors, well, that's not an easy one, thanks to BIS. I mean, basically, all you need is this:
Code:
_houses = [1000,1000] nearobjects ["house", 1000000];
{
_x animate ["door", 0];
sleep 0.0001;
} foreach _houses;
Or so you think! Problem: BIS forgot to use a standard or nomenclature for their buildings. So, some doors are named "door", some are named "dvere", then we have "door01" or "door_01" and so on. It's a mess!
And it gets even worse! On ArmA 2 buildings, the parameter to close a door is 0, while on OA buildings, the parameter is 1! Dear BIS, how can you possibly confuse 0s and 1s?!?
Whatever! So, after a long period of trying, this came out:
 
Code:
 
_houses = [1000,1000] nearObjects ["house", 1000000];
_zeroes = ["dvere","dvere1l","dvere1r","dvere2l","dvere2r","dvere_spodni_r","dvere_spodni_l","dvere_vrchni","vrata1","vrata2","vratal1","vratar1","vratal2","vratar2","vratal3","vratar3"];
_ones = ["door","door_1_1","door_1_2","door_2_1","door_2_2","dvere1","dvere2","dvere3","dvere4","dvere5","dvere6","dvere7","dvere8","dvere9","dvere10","dvere11","dvere12","dvere13","dvere14","doorl","doorr","door_01","door01_a","door_02","door02_a","door_03","door_04","door_05","door_06","door_1a","door_1","door_2"];
{
_y = _x;
{_y animate [format ["%1", _x], 0]} foreach _zeroes;
{_y animate [format ["%1", _x], 1]} foreach _ones;
sleep 0.0001;
} foreach _houses;
 
As far as I know, it works on most buildings. No, wait, I think forgot about the LHD. Ach, not that important, eh? If there's more missing, or not working at all, just let me know.
Good day,
mr_book
 
EDIT: I just found out that above script doesn't work on both Utes and Chernarus. A (rather unsatisfying) workaround is:
 
Code:
 
{
_y = _x;
{_y animate [format ["%1", _x], 0]} foreach _zeroes;
if ((worldname=="Utes") or (worldname=="Chernarus")) then
{
  {_y animate [format ["%1", _x], 0]} foreach _ones;
} else
{
  {_y animate [format ["%1", _x], 1]} foreach _ones;
};
sleep 0.0001;
} foreach _houses;
 
It does work now, although it looks really messed up. Take it or leave it, the choice is yours.

I've tried adding it directly to init.sqf, doing execVM, #include, but I don't know how this stuff works, so some help would be appreciated :p

And if we leave this here, it could be useful for other people as well :)

This will eliminate the "Lets just run through a building and all the zombies will go away" tendencies :p
 
Back
Top