Random Spawn Bug - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Spawn Bug (
/showthread.php?tid=563411)
Random Spawn Bug -
Flokx - 15.02.2015
How can I make something like when you make like random spawn, only one player will spawn on one place.
Like if I put this values as random spawns
121,21,12 //I want only 1 player to spawn here
121,212,12, //I want 2nd player to spawn here
12121,2121,121 //I want 3rd player to spawn here
12,12,12112 //I want 4th player to spawn here
So no one spawn in the same place. Please some help.
Re: Random Spawn Bug -
Dokins - 15.02.2015
There are several ways you can do this.
Assign variables to make them dynamic.
You can use 'static' co-ordinates and place them between brackets.
You could use a switch combined with Random();
Re: Random Spawn Bug -
Abagail - 15.02.2015
You should use an array that stores coordinates, and a boolean or integer value.
Then you can loop the array, and find a coordinate with an unset boolean / integer value. Then, set the integer's value to 1 when spawning with said coordinate.
Re: Random Spawn Bug -
Flokx - 15.02.2015
Thanks for trying to help me, but can you please show me little code?
Like how to do those

Please help Abagail
Re: Random Spawn Bug -
Abagail - 15.02.2015
pawn Код:
#define MAX_SPAWNS 3
enum SpawnEnum
{
Float: x,
Float: y,
Float: z;
}
new SpawnData[][SpawnEnum] = {
{121,21,12},
{123,23,22}
}
new CoordinateUsed[MAX_SPAWNS];
public OnPlayerSpawn(playerid)
{
for (new i = 0; i != MAX_SPAWNS; ++i)
{
if(!CoordinateUsed[i]))
{
SetPlayerPos(i, SpawnData[i][x], SpawnData[i][y], SpawnData[i][z]);
CoordinateUsed[i] = 1;
return 1;
}
}
SetPlayerPos(playerid, 0, 3, 3); // If there are no array spawns left, TP them here.
return 1;
}
Then make sure to set CoordinateUsed to 0 when they are no longer occupying the spawn. Your welcome!