SA-MP Forums Archive
Random Spawn - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random Spawn (/showthread.php?tid=180776)



Random Spawn - Rick_Koning - 02.10.2010

Hey,

I'd like to create random spawns when you join the server or get killed etc...
I DID SEARCH BEFORE POSTING. The answers werent clear to me though.

Bai


Re: Random Spawn - [XST]O_x - 02.10.2010

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;
}



Re: Random Spawn - Rick_Koning - 02.10.2010

Well. I have 5 differnet spawns.

What variables should I use then?
Thanks


Re: Random Spawn - nicoud - 03.10.2010

i did this and it wont work


Re: Random Spawn - nicoud - 03.10.2010

: error 017: undefined symbol "RandomSpawn"
: error 029: invalid expression, assumed zero
: warning 215: expression has no effect
: error 017: undefined symbol "RandomSpawn"
: warning 215: expression has no effect
: error 001: expected token: ";", but found "]"
: error 029: invalid expression, assumed zero
: fatal error 107: too many error messages on one line


Re: Random Spawn - Rick_Koning - 03.10.2010

It's in my script with NO errors, but my players still spawn at the AddPlayerSpawn Location, how to solve that ?

Bai


Re: Random Spawn - Rick_Koning - 03.10.2010

Anyone ?


Re: Random Spawn - Mike_Peterson - 03.10.2010

AddPlayerSpawn? custom function or you mean something else?
like AddPlayerClass...


Re: Random Spawn - Rick_Koning - 03.10.2010

I added all random spawns, but the player still spawns at:
AddPlayerClass(266, 1948.236450, -2239.018066, 13.546875, 136.121856, 0, 0, 0, 0, 0, 0);

And it should be spawning @ the random spawns :/


Re: Random Spawn - Mike_Peterson - 03.10.2010

Hey, thats strange since i know AddPlayerClass the co-ords arent the spawning co-ords but the co-ords to select the class (switching skins)
Your sure nothing in a script has a SetPlayerPos on spawn?