PHP Code:
//Spawn Function/Redie Function
decl Float:fOrigin[3];
new iRandom = GetRandomInt(1, MaxClients);
for(new i = 1; i <= MaxClients; i++)
{
if(i == iRandom)
{
GetClientAbsOrigin(i, fOrigin);
if(IsClientInGame(Client) && IsPlayerAlive(Client) && IsClientInGame(i))
{
TeleportEntity(Client, fOrigin, NULL_VECTOR, NULL_VECTOR);
break;
}
}
else break;
}
What does this do?
fOrigin: The buffer (variable which we store data in) for the client's angles that we're going to be spawning on.
iRandom: We're doing this to get Player 1 to Player X (Not all games/servers have same amount of max players)
for(new i = 1; i <= MaxClients: We're looping through every player and getting a random player to spawn on
if(i == iRandom): Teleport the Player to the randomly selected client
break;: Stop the loop immediatly (no inf. looping)