Different spawns
#1

Well Im willing to script my simple deathmatch gamemode, but the thing is, I wanna make like 4 spawns and everytime a player log in he'll be spawned in different replaces.
EXAMPLE:
Player1: Spawned at Ganton.
Player2: Spawned at El Corona.
Well what function should I use? also yea I've tried random

Код:
public OnGameModeInit()
{
	
	SetGameModeText("SDM v1.0");

		
	new rn = random(2);
	if (rn == 1) // Spawn Ganton
	{
	AddPlayerClass(0,2485.5701,-1766.6910,13.5469,7.6177,0,0,0,0,0,0); // SpawnGanton
	}
	else // SpawnCorona
    
	{
	AddPlayerClass(0,1930.2146,-2070.7791,13.5498,353.2042,0,0,0,0,0,0); // SpawnCorona
	}
    
	
	return 1;


}
Reply
#2

Yes, use the random function and use "if" to set position onplayerspawn accordingly to the returned value from the random function. Use the random inside onplayerspawn too, but before the ifs of cource.
edit: bolt
Reply
#3

Oooh so it's suppose to be under OnPlayerSpawn? Imma try.
Reply
#4

create an array with spawn locations in it. (OnPlayerSpawn)
pawn Код:
new Float:RandSpawn[][4] = {//x, y, z, angle
    {0.0, 0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0, 0.0},
    {0.0, 0.0, 0.0, 0.0}
};
then check for example in what team he is or just do

(you are setting the position from the player random to one of the array)

pawn Код:
new rand = random(sizeof(RandSpawn));
SetPlayerPos(playerid, RandSpawn[rand][0], RandSpawn[rand][1], RandSpawn[rand][2]);
SetPlayerFacingAngle(playerid, RandSpawn[rand][3]);
Reply
#5

Woo thank you jordy.kiesebrink It's working now!
Reply
#6

No problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)