Random SetPlayerPos
#1

Hey.

I'm currently having trouble with trying to work out how to make it so only one player can spawn in random spawn position.

Let's say we have an array for spawns, which are random.
I want it so if one player has spawned in a random spawn position set by the random array that another play can't spawn in that position but move on to the next random position and spawn them there.

Any ideas on how I could do this?
Reply
#2

Still unable to work this out.
Reply
#3

You would do it similar to how it's done on the random spawns on the wiki with a slight difference:

pawn Код:
new Float:RandomSpawn[][4] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335}, //array slot 0
    {-2454.2170, 503.8759, 30.0790, 267.2932}, //array slot 1
    {-2669.7322, -6.0874, 6.1328, 89.8853} //array slot 2
};
#define MAX_SPAWNS 3
new rSpawn;

public OnPlayerSpawn(playerid) //Or wherever you want to random spawn them.
{

    SetPlayerPos(playerid, RandomSpawn[rSpawn][0], RandomSpawn[rSpawn][1],RandomSpawn[rSpawn][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    rSpawn++; //Next array slot.
    if(rSpawn == MAX_SPAWNS) rSpawn = 0;
    //If we get to the end of the array, it's reset to 0.
    //This means if you have over 3 players then it's going to spawn at least 2 people at the same place.
    return 1;
}
Reply
#4

You sir, are a legend.

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)