30.08.2016, 16:56
How do i make 3 randoms spawns when playerspawn ?
new Float:Spawns [][4] = { {x, y, z, angle}, //Spawn 1 {x, y, z, angle}, //Spawn 2 {x, y, z, angle} //Spawn 3 }; public OnPlayerSpawn(playerid) { new spawn = random(sizeof(Spawns)); SetPlayerPos(playerid, Spawns[spawn][0], Spawns[spawn][1], Spawns[spawn][2]); SetPlayerFacingAngle(playerid, Spawns[spawn][3]); return 1; }
public OnPlayerSpawn(playerid) { new spawn = random(3); switch(random) { case 0: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 1 case 1: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 2 case 2: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 3 } return 1; }
EDIT:
Another easy way of making random spawns: Код:
public OnPlayerSpawn(playerid) { new spawn = random(3); switch(random) { case 0: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 1 case 1: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 2 case 2: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 3 } return 1; } |
public OnPlayerSpawn(playerid)
{
new spawn = random(3);
switch(spawn)
{
case 0: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 1
case 1: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 2
case 2: { SetPlayerPos(playerid, x, y, z); SetPlayerFacingAngle(playerid, angle); } // Spawn 3
}
return 1;
}
switch(random(3))
{
...
}