New Random Spawn
#1

Hi, I've got a random spawn in my script which's moving down. If one of the spawn points has Z<0, it'll get inactive. If all of these spawn points had Z<0, a new random spawn should get enabled. But it doesn't work. Instead of this I spawn at a harbor.
Is it up to the code or's something different the reason? Thanks for help.
Here's the code:
pawn Код:
public OnPlayerSpawn(playerid)
{
    new iRandom;
    if(SpawnsAreDead==0)
    {
      new i;
        do
        {
          iRandom=random(sizeof(RandomSpawn));
        i++;
        if(i>=124)
        {
          SpawnsAreDead=1;
                break;
            }
        }
        while(RandomSpawn[iRandom][2]-gZ<0);
        if(SpawnsAreDead==0)
        {
            SetPlayerPos(playerid,RandomSpawn[iRandom][0],RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]-gZ);
            SetPlayerFacingAngle(playerid,RandomSpawn[iRandom][3]);
        }
    }
    if(SpawnsAreDead==1)
    {
        iRandom=random(sizeof(RS2));
        SetPlayerPos(playerid,RS2[iRandom][0],RS2[iRandom][1],RS2[iRandom][2]-gZ);
        SetPlayerFacingAngle(playerid,RS2[iRandom][3]);
    }
    return 1;
}
Reply
#2

here is a muuucchhh easier way.


Код:
	new rand;
	rand = random( number of teleports );
	rand++; //changes the 9 to 10, elimanting the number 0
	switch(rand)
	{
		case 1: SetPlayerPos(playerid, x,y,z);

	}
Reply
#3

Quote:
Originally Posted by anonymoushacker
here is a muuucchhh easier way.


Код:
	new rand;
	rand = random( number of teleports );
	rand++; //changes the 9 to 10, elimanting the number 0
	switch(rand)
	{
		case 1: SetPlayerPos(playerid, x,y,z);

	}
I think you didn't understand what the code's doing.

There's the normal spawn, RandomSpawn. The spawn point move down (Z-gZ[their Z-position less the value gZ each second]). So once, its Z-coordinate is under 0. And these point shouldn't be used for the players to spawn. So that they've to spawn over 0. Till than it works. BUT once all spawn points are under 0, and then there's no other place left to spawn. So there gets another random spawn enabled, RS2(RandomSpawn2). This doesn't work. I spawn in the water and then on the Grove Street.
If somebody's abцeto help me, please tell if the problem is the code or if it's somewhere else.
Thanks for help.
Reply
#4

marc, thats what i am doing, but i need to figure out howto set the interior when they teleport.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)