Author Topic: Easy-ish way to create a new spawn brick?[Solved]  (Read 825 times)

Hello all!

I've recently been looking into creating a new spawn brick that will function outside of a minigame that when a client with a certain variable will spawn on the brick but others will default to the regular spawns.

Eg;
%client.test = 1; will spawn at the new brick
%client.test = 0; will spawn that the regular position

I have looked at personal spawn bricks and such but they are all pretty long and tedious processes, any easier way you guys know of to do it?
« Last Edit: March 26, 2013, 04:31:56 PM by Yola² »

Tag the spawn brick to the client or use some other method, package gameconnection::spawnplayer and after the parent set the user's position to that brick.

Tag the spawn brick to the client or use some other method, package gameconnection::spawnplayer and after the parent set the user's position to that brick.
That's not too horrid of an idea, appreciated

This should do the trick. I commented everything to show what's going on.

Code: [Select]
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);

I found this little piece of code that should help with making the bricks.
Code: [Select]
datablock fxDTSBrickData(NAMEHERESpawnPointData : brickSpawnPointData) //Edit "NAMEHERE" field.
{
category = "special"; //Edit category here
subCategory = "spawns"; //Edit subcategory here.
uiName = "YOUR DESIRED NAME"; //Edit name here..
typeofspawn = "spawntype"; //Maybe a extra variable to keep track if this is a certain type of spawn?
};

Also another quick note, you may want to put this in a isObject check.

Edit: Greek beat me to it.. x.x

This should do the trick. I commented everything to show what's going on.

Code: [Select]
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);

Or you can do it a lot more dynamically like Greek showed lol.

This should do the trick. I commented everything to show what's going on.

Code: [Select]
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);
Worked perfectly!

Thanks