Random Spawn
#2

https://sampwiki.blast.hk/wiki/Random

Seems like you hadn't searched hard enough, it was right in the wiki.

If you don't understand:

pawn Код:
new Float:RandomSpawn[][4] = //This is a variable that holds the information of the random spawns, save as much positions as you want.

/*The first square brackets stands for the amount of random spawns, it's optional, the second brackets however are not optional and must be filled, they hold how much information pieces each one of the variables hold. 4 In this specific case, x(1),y(2),z(3) and facing angle(4).*/
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
pawn Код:
public OnPlayerSpawn(playerid)
{
    new rand = random(sizeof(RandomSpawn)); // it randomizes between the three lines of positions we've inserted above.
   
   
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    /*This is sending the player to the randomized position, [rand] is a random we've declared above, it's randomized between the 3 lines of positions we have.
    0 means the first piece of information from the line we've just randomized, the first one as you remember, is the X position,so on for 1 and 2.
 */


     SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]); //As we've explained, now the fourth piece of information from the randomized line, which is the facing angle.
     
    return 1;
}
Reply


Messages In This Thread
Random Spawn - by Rick_Koning - 02.10.2010, 20:38
Re: Random Spawn - by [XST]O_x - 02.10.2010, 20:48
Re: Random Spawn - by Rick_Koning - 02.10.2010, 22:08
Re: Random Spawn - by nicoud - 03.10.2010, 02:07
Re: Random Spawn - by nicoud - 03.10.2010, 02:21
Re: Random Spawn - by Rick_Koning - 03.10.2010, 09:21
Re: Random Spawn - by Rick_Koning - 03.10.2010, 11:24
Re: Random Spawn - by Mike_Peterson - 03.10.2010, 11:26
Re: Random Spawn - by Rick_Koning - 03.10.2010, 15:02
Re: Random Spawn - by Mike_Peterson - 03.10.2010, 15:05

Forum Jump:


Users browsing this thread: 4 Guest(s)