Improved the speed of code by change the forEach to findIf, it should be work, not tested
spawnInTown.sqf
_citiesTerritories = call cityList;
_citiesTerritories append (call compile preprocessFileLineNumbers "mapConfig\territories.sqf");
_index = _citiesTerritories findIf { _x select 0 == _marker };
if (["TERRITORY_", _location] call fn_startsWith) then
{
_rad = selectMax (markerSize _marker);
_townName = _citiesTerritories select _index select 1;
} else
{
_rad = _citiesTerritories select _index select 1;
_townName = _citiesTerritories select _index select 2;
};
_pos = getMarkerPos _marker;
_notInArea = false;
while { _notInArea } do
{
_playerPos = [_pos,5,_rad,1,0,0,0] call findSafePos;
if (_playerPos inArea _marker) then
{
_notInArea = true;
};
};
if (_preload) then { waitUntil {sleep 0.1; preloadCamera _playerPos} };
waitUntil {!isNil "bis_fnc_init" && {bis_fnc_init}};
player setPos _playerPos;
loadRespawnDialog.sqf
_setPlayersInfo =
{
private ["_location", "_townEntry"];
_location = _this; // spawn beacon object or town marker name
_isBeacon = (typeName _location == "OBJECT");
_friendlyUnits = [];
_friendlyPlayers = 0;
_friendlyNPCs = 0;
_enemyPlayers = 0;
_enemyNPCs = 0;
{
if (alive _x && {_x isKindOf "CAManBase" && {!(_x call A3W_fnc_isUnconscious) && _x inArea _location}}) then
_citiesTerritories = call cityList;
_citiesTerritories append (call compile preprocessFileLineNumbers "mapConfig\territories.sqf");
_towns = [];
{
private "_friendlyPlayers";
_town = _x select 0;
_town call _setPlayersInfo;
if (_friendlyPlayers > 0) then
{
_towns pushBack _town;
};
} forEach _citiesTerritories;
_data = "objectFromNetId " + str netId _location;
}
else
{
_index = _citiesTerritories findIf { _x select 0 == _location };
if (["TERRITORY_", _location] call fn_startsWith) then
{
_text = _citiesTerritories select _index select 1;
} else
{
_text = _citiesTerritories select _index select 2;
}
_data = str _location;
};