Random Spawns, Need help please. -
Outbreak - 19.02.2009
Hey, i'm trying to set up some random spawns, 6 of them...
6 players spawn at the same time, but none of thme can spawn on the same place as eachother.
I'm trying to get it so each time they spawn its different, random. But no other play can spawn in the same place.
How could i do this please?
Re: Random Spawns, Need help please. -
Nero_3D - 19.02.2009
pawn Code:
const MAX_POSITIONS = 3;
static Float:Positions[MAX_POSITIONS][4] =
{
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0},
{0.0, 0.0, 0.0, 0.0}
}, bool:taken[MAX_POSITIONS];
new freePos;
for(; freePos < MAX_POSITIONS; freePos++)
if(!taken[freePos]) break;
if(freePos == MAX_POSITIONS) return; //no free positions left
SetPlayerPos(playerid, Positions[freePos][0], Positions[freePos][1], Positions[freePos][2]);
SetPlayerFacingAngle(playerid, Positions[freePos][3]);
taken[freePos] = true;
Re: Random Spawns, Need help please. -
Outbreak - 19.02.2009
THanks for the reply.
This works partly.
I put it in like this..
pawn Code:
stock SpawnPlayerInMinigun(playerid)
{
const MAX_POSITIONS = 12;
static Float:Minigunspawns[MAX_POSITIONS][4] =
{
{2606.2012,2725.6223,23.8222,13.2314},{2590.4138,2719.8047,10.8203,180.1702},
{2619.6592,2708.9177,25.8222,195.3502},{2591.0515,2800.7275,10.8203,89.1443},
{2592.0317,2724.0625,10.9844,39.3620},{2653.7820,2723.7656,19.3222,287.7489},
{2542.4048,2807.4819,10.8203,329.6895},{2618.5669,2721.3716,36.5386,80.9590},
{2648.2996,2731.5466,10.8203,307.8025},{2556.0271,2710.1548,10.9844,56.4777},
{2626.6411,2840.9756,10.8203,70.1659},{2595.8225,2800.8164,10.8203,270.0378}
}, bool:taken[MAX_POSITIONS];
new freePos;
for(; freePos < MAX_POSITIONS; freePos++)
if(!taken[freePos]) break;
if(freePos == MAX_POSITIONS) return; //no free positions left
SetPlayerPos(playerid, Minigunspawns[freePos][0], Minigunspawns[freePos][1], Minigunspawns[freePos][2]);
SetPlayerFacingAngle(playerid, Minigunspawns[freePos][3]);
taken[freePos] = true;
}
The only problem is when there are more than 4 players requesting one of the random spawns, it doesnt work. they dont spawn anywhere. Instead they stay where they are.
Re: Random Spawns, Need help please. -
Nimphious - 19.02.2009
Quote:
Originally Posted by Outbreak
THanks for the reply.
This works partly.
I put it in like this..
pawn Code:
stock SpawnPlayerInMinigun(playerid) { const MAX_POSITIONS = 12; static Float:Minigunspawns[MAX_POSITIONS][4] = { {2606.2012,2725.6223,23.8222,13.2314},{2590.4138,2719.8047,10.8203,180.1702}, {2619.6592,2708.9177,25.8222,195.3502},{2591.0515,2800.7275,10.8203,89.1443}, {2592.0317,2724.0625,10.9844,39.3620},{2653.7820,2723.7656,19.3222,287.7489}, {2542.4048,2807.4819,10.8203,329.6895},{2618.5669,2721.3716,36.5386,80.9590}, {2648.2996,2731.5466,10.8203,307.8025},{2556.0271,2710.1548,10.9844,56.4777}, {2626.6411,2840.9756,10.8203,70.1659},{2595.8225,2800.8164,10.8203,270.0378} }, bool:taken[MAX_POSITIONS]; new freePos; for(; freePos < MAX_POSITIONS; freePos++) if(!taken[freePos]) break; if(freePos == MAX_POSITIONS) return; //no free positions left SetPlayerPos(playerid, Minigunspawns[freePos][0], Minigunspawns[freePos][1], Minigunspawns[freePos][2]); SetPlayerFacingAngle(playerid, Minigunspawns[freePos][3]); taken[freePos] = true; }
The only problem is when there are more than 4 players requesting one of the random spawns, it doesnt work. they dont spawn anywhere. Instead they stay where they are.
|
well maybe because you only have 6 random spawns, maybe just make heaps more?
Re: Random Spawns, Need help please. -
Outbreak - 19.02.2009
6 random sapwns was an example. in the code i posted there are 12.
I've sussed out whats wrong i think...
Once a space is used, it doesnt get cleared. So. i just need to set them back to free space..
I think..
Not sure how to clear it though, after the soawns have already been used once
Re: Random Spawns, Need help please. -
Outbreak - 20.02.2009
Hmm, this doesn't work...
I dunno why its happening but when the spawns have been used once, they cannot be used again at all...
Is there a way i can get the spawns to be used over and over again, but only one person at a time can be spawned in each place?
Its for some minigames, the only thing wrong is the spawns..
Re: Random Spawns, Need help please. -
Nero_3D - 20.02.2009
pawn Code:
SpawnPlayerInMinigun(playerid)
{
const MAX_POSITIONS = 12;
static Float:Minigunspawns[MAX_POSITIONS][4] =
{
{2606.2012,2725.6223,23.8222,13.2314},
{2590.4138,2719.8047,10.8203,180.1702},
{2619.6592,2708.9177,25.8222,195.3502},
{2591.0515,2800.7275,10.8203,89.1443},
{2592.0317,2724.0625,10.9844,39.3620},
{2653.7820,2723.7656,19.3222,287.7489},
{2542.4048,2807.4819,10.8203,329.6895},
{2618.5669,2721.3716,36.5386,80.9590},
{2648.2996,2731.5466,10.8203,307.8025},
{2556.0271,2710.1548,10.9844,56.4777},
{2626.6411,2840.9756,10.8203,70.1659},
{2595.8225,2800.8164,10.8203,270.0378}
}, Current_Cell;
if(Current_Cell == MAX_POSITIONS)
return (Current_Cell = 0), SpawnPlayerInMinigun(playerid);
if(!SetPlayerFacingAngle(playerid, Minigunspawns[Current_Cell][3])) return false;
SetPlayerPos(playerid, Minigunspawns[Current_Cell][0], Minigunspawns[Current_Cell][1], Minigunspawns[Current_Cell][2]);
Current_Cell++;
return true;
}
Its not random (the one before wasnt too :S) Its like that
Example:
Player1 = Pos1
Player2 = Pos2
...
Player12 = Pos12
Player13 = Pos1
And Pos1 is always the position after the last taken
Re: Random Spawns, Need help please. -
Outbreak - 20.02.2009
This has wrecked my head in trying to figure out how to make it so they dont spawn in the same place and so its kinda random...
Finally its working perfect
Awesome work. Thanks