Random pickup spawns... [NOT SOLVED]
#1

Ok, I am doing a game in which at the very beginning a briefcase pickup spawns:

I want to do something like this:

CreatePickup(1210,3,x,y,z);

how do I make the x,y,z floats random? What I want is for the pickup location to be in one of ten or so places...what do I need to do?
Reply
#2

make a array with locations, than make a random. search for random spawns.
Reply
#3

Ok thanks, and also...is there a way of making it so that when this spawns, a checkpoint shows where it is?
Reply
#4

yes also set a checkpoint to same random location as the pickup.
Reply
#5

Slight problem:

When the game starts, the pickup and the checkpoint are always in the exact same place...it's not random


Ignore indentations please

Код:
enum PickupSpawnInfo
{

	Float:PickupX,

	Float:PickupY,

	Float:PickupZ

}


new Float: gBombPickups[][PickupSpawnInfo] =

{

	{1878.5574,-2102.2798,13.5519},
	{1131.4218,-2037.1725,69.0078},
	{835.7139,-2064.0254,12.8672},
	{369.6759,-2046.0470,7.6719},
	{333.0439,-1516.2767,35.8672},
	{595.3450,-1249.7637,18.2616},
	{857.9083,-1063.5784,25.1016},
	{1116.6335,-862.6241,43.2881},
	{1293.1110,-1080.7866,25.8828},
	{1600.2195,-1522.8777,13.6069}

};
Код:
public OnGameModeInit()
{
      new i, j;

	for (i = 0, j = sizeof(gBombPickups); i < j; i++)

	{

		CreatePickup(1210,3,

			gBombPickups[i][PickupX],

			gBombPickups[i][PickupY],

			gBombPickups[i][PickupZ]);

	}
}
Код:
public OnPlayerSpawn(playerid)
{

new i, j;

	for (i = 0, j = sizeof(gBombPickups); i < j; i++)

	{

		SetPlayerCheckpoint(playerid,
	
	  gBombPickups[i][PickupX],
	  gBombPickups[i][PickupY],
	  gBombPickups[i][PickupZ],
	  1);

	}
}
Reply
#6

wasn't that what you wanted, that the cp leads to the pickup.
Reply
#7

Yes, but the locations of the CP and the pickup aren't random...they keep spawning in the exact same place every time
Reply
#8

Any ideas?
Reply
#9

pawn Код:
new rand = random(sizeof(ggBombPickups));
CreatePickup(1210,3,gBombPickups[rand][0], gBombPickups[rand][1], gBombPickups[rand][2]);
SetPlayerCheckpoint(playerid,gBombPickups[rand][0], gBombPickups[rand][1], gBombPickups[rand][2],1);
Should solve it.
Reply
#10

What is that supposed to do? From the look of the first line it'll crash the compiler...

More explanation would be great, thanks



Ok, I managed to make the pickup random...but now the checkpoint it off
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)