How to use random spawn locations? - 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)
+--- Thread: How to use random spawn locations? (
/showthread.php?tid=312917)
How to use random spawn locations? -
MSI - 23.01.2012
I have 7 teams, and I want for each team random spawn locations. I mean team USA must have 3 or 4 spawn locations. It must be random choosing.
How to use that?
(rep+)
Re: How to use random spawn locations? -
lordturhan - 23.01.2012
https://sampwiki.blast.hk/wiki/Random
Re: How to use random spawn locations? -
MSI - 23.01.2012
I don't understand that too less explaination.. but thanks for the link
Re: How to use random spawn locations? -
lordturhan - 23.01.2012
Let me explain
pawn Код:
new Float:RandomSpawn[][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}
};
These are the coordinates you need for team.
pawn Код:
public OnPlayerSpawn(playerid)
{
new rand = random(sizeof(RandomSpawn));
// SetPlayerPos to the random spawn data
SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
// SetPlayerFacingAngle to the random facing angle data
SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
return 1;
}
And this set random position when they spawn not too hard to understand.
Also:
https://sampforum.blast.hk/showthread.php?tid=199377
Re: How to use random spawn locations? -
Cameltoe - 23.01.2012
pawn Код:
enum Position_Enum
{
Float:PosX;
Float:PosY;
Float:PosZ;
Float:PosR;
// I would suggest you to use:
/*
Float:Pos[4];
*/
// Instead !
}
new RandomSpawnLocations[][ Position_Enum ] = {
{500, 500, 500, 500},
{0, 0, 0, 0}
};
Now trigger a Random value from the link ^, and Spawn + SetPlayerPos