Randomized Spawnpoints, help needed.
#1

Hello,

I want to put these coцrdinates in OnPlayerSpawn, and i want them to be triggered randomly. Meaning that if a player spawns, he spawns randomly in one of these locations:

Код:
-1969.4608,288.1015,35.1719
2136.7170,1444.0112,10.8203
2178.7769,1679.3088,11.0469
2335.3645,2454.5911,14.9688
-2282.6096,84.1550,35.1641
-2280.0745,180.2939,35.1641
-2706.3408,372.5084,4.9748
-1619.8474,681.7193,7.1875
-2624.6348,1408.9037,7.1016
-2444.0889,751.0832,35.1786
1762.2603,-1901.8314,13.5648
1215.2671,-2037.0580,67.3133
892.3240,-1638.9484,14.9574
Yes, i have searched. Any help is much appreciated.
Reply
#2

look at lvdm gamemode, there is random player spawn
Reply
#3

Код:
new RandomSpawn = random(1);
  			if (RandomSpawn == 0)
				{
  			  InCar[playerid] = false;
					SetPlayerPos(playerid, x,y,z);
					SetPlayerFacingAngle(playerid, a);
					SetCameraBehindPlayer(playerid);
				}
you could use that format
copy and paste this part
Код:
if (RandomSpawn == 0)
				{
  			  InCar[playerid] = false;
					SetPlayerPos(playerid, x,y,z);
					SetPlayerFacingAngle(playerid, a);
					SetCameraBehindPlayer(playerid);
				}
everytime you make a new spawn
change the If(randomSpawn == ) to the next integer or else it wont work

and when your dont dont forget to change this part
Код:
random(1);
change the number to however many spawns you have

yes it starts counting at 0
Reply
#4

Put this with the other new's
pawn Код:
new Float:RandomSpawns[2][3] = {
{X, Y, Z}, // Change X, Y, Z.
{X, Y, Z}
};
Put this In"OnPlayerSpawn"
pawn Код:
new rand;
rand = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
Reply
#5

Stah: I understand your code, but do i need to put all spawns in;

SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);

?

I mean it as in counting on, after RandomSpawns[rand][2] going on to RandomSpawns[rand][3] and so on? Or is 0-1-2 enough?

I have 13 spawns.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)