Jump to content

Recommended Posts

I am having an issue with spawning vehicles at certain spawn markers

 

Let's say there are 5 "shops" all over the map and each has its own spawn, right now a player "buys" a vehicle and it spawns only at Spawn 1

 

I am trying to make it so it would select the nearest spawn to the player (that is pre-defined in  an array)

 

Spoiler

 _spawnPoints = ["Spawn1","Spawn2","Spawn3","Spawn4","Spawn5"];

 

//--- Spawn

if (_spawnPoints isEqualType []) then {

      {

      if ((getMarkerPos _x nearEntities [["Car","Air","Ship"],50]) isEqualTo []) exitWith {_spawnPoint = _x};

      } forEach _spawnPoints;

};

 

 

 

// -- Nato Hunter

if (_className isKindOf "AllVehicles" && (_displayText isEqualTo "Hunter (NATO)"))  then {

  _vehicle = _className createVehicle getMarkerPos _spawnPoint;

  _vehicle allowDamage false;

  _vehicle setDir (markerDir _spawnPoint);

  _vehicle allowDamage true;

}

 

 

Share this post


Link to post
Share on other sites
6 hours ago, General McTavish said:

Let's say there are 5 "shops" all over the map and each has its own spawn, right now a player "buys" a vehicle and it spawns only at Spawn 1

 

Sounds a lot like a life server 🤔. Your problem is that you are simply checking if any of the markers across the map have no entities within 50 meters of them and Spawn1 was probably clear of entities every time you tested it. Instead, you should be checking which markers are closest or within 'x' range of the shop that the player is buying from, then using the near entities command to check if the spawn point is blocked by another vehicle or something.

Share this post


Link to post
Share on other sites

_spawnPoints = ["Spawn1","Spawn2","Spawn3","Spawn4","Spawn5"];

 

when spawn action:

_spawning = _spawnPoints apply { [ str (getMarkerPos _x  nearEntities [["Car","Air","Ship"],50] isNotEqualTo []), getMarkerPos _x distanceSqr player, _x]};
 _spawning sort TRUE;
 _spawnPoint = _spawning #0#2;

 

 

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×