[HOW TO]Spawn All?
#1

Hi,
How to spawn all player with a timer?

Thanks
Reply
#2

Use SetTimer/SetTimerEx with loop over SpawnPlayer function.
Reply
#3

Thx. But i want all player re spawn
Reply
#4

Код:
forward RespawnAll();
public RespawnAll()
  {
  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    SpawnPlayer(i);
    }
  }
Place anywhere in your script but NOT in a callback.
Then use it just as a normalfunction.
Reply
#5

If you have a 50-slot server then using Ronyx's code would be a little pointless, unless you have undefined MAX_PLAYERS and redefined to 50!
Reply
#6

Quote:
Originally Posted by Ronyx69
Код:
forward RespawnAll();
public RespawnAll()
  {
  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    SpawnPlayer(i);
    }
  }
Place anywhere in your script but NOT in a callback.
Then use it just as a normalfunction.
Thanks. It works perfectly
Reply
#7

In my opinion, you should check if the player, which you will be spawning, is online, like this:

pawn Код:
forward SpawnAll();
public SpawnAll()
{
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
     if(IsPlayerConnected(i))
     {
        SpawnPlayer(i);
     }
   }
}
Reply
#8

Quote:
Originally Posted by SpiderPork
In my opinion, you should check if the player, which you will be spawning, is online, like this:

pawn Код:
forward SpawnAll();
public SpawnAll()
{
   for(new i = 0; i < MAX_PLAYERS; i++)
   {
     if(IsPlayerConnected(i))
     {
        SpawnPlayer(i);
     }
   }
}
Doesn't have to be, using if(IsPlayerConnected(i)) would take longer to do the loop, and since you cannot spawn a not-connected playerid you don't have to worry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)