This should do the trick. I commented everything to show what's going on.
new SimSet(mySpawnPointSet); //this will keep track of our spawns
datablock fxDtsBrickData(mySpawnPointData : brickSpawnPointData) //we're copying all fields from the normal spawn brick
{
uiName = "My Spawn Point"; //let's change the UI Name
};
function mySpawnPointData::onAdd(%this,%obj)
{
mySpawnPointSet.add(%obj); //add the brick to our spawn set
}
package mySpawnPoint
{
function GameConnection::getSpawnPoint(%this)
{
%spawnCount = mySpawnPointSet.getCount();
if(%this.useMySpawnPoint && %spawnCount > 0) //does the client use the special spawn, and are there any?
{
%spawn = mySpawnPointSet.getObject(getRandom(0,%spawnCount - 1)); //pick a random spawn in the set
return %spawn.getSpawnPoint(); //return the spawn transform
}
else
return parent::getSpawnPoint(%this); //nope, just return the normal spawn point
}
};
activatePackage(mySpawnPoint);