Random
#3

Код:
new Float:Spawns [][4] =
{
    {x, y, z, angle}, //Spawn 1
    {x, y, z, angle}, //Spawn 2
    {x, y, z, angle}  //Spawn 3
}; 

public OnPlayerSpawn(playerid)
{
    new spawn = random(sizeof(Spawns));
    SetPlayerPos(playerid, Spawns[spawn][0], Spawns[spawn][1], Spawns[spawn][2]);
    SetPlayerFacingAngle(playerid, Spawns[spawn][3]);
    return 1;
}
More explanation here: https://sampwiki.blast.hk/wiki/Random

EDIT:

Another easy way of making random spawns:

Код:
public OnPlayerSpawn(playerid)
{
    new spawn = random(3);

    switch(random)
    {
        case 0: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 1
        case 1: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 2
        case 2: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 3
    }
    return 1;
}
Reply


Messages In This Thread
Random - by Hunud - 30.08.2016, 16:56
Re: Random - by Jensenn - 30.08.2016, 17:00
Re: Random - by K0P - 30.08.2016, 17:02
Re: Random - by Logic_ - 30.08.2016, 17:20
Re: Random - by K0P - 31.08.2016, 16:36

Forum Jump:


Users browsing this thread: 1 Guest(s)