Random Spawn Bug
#1

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.
Reply
#2

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();
Reply
#3

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.
Reply
#4

Thanks for trying to help me, but can you please show me little code?
Like how to do those
Please help Abagail
Reply
#5

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)