Random Spawn for a certain class/team
#1

Hello I have two teams one is TEAM_BAYSIDE and the other is TEAM_JIZZY

So far I have got the random spawn locations for TEAM_BAYSIDE which is this.
pawn Код:
new randomSpawns[5][4] = {
    {-2263.2166,2299.9717,4.8202},
    {-2257.9160,2319.3682,4.8125},
    {-2232.6721,2330.4746,7.5469},
    {-2226.5315,2310.1479,5.0991},
    {-2261.6448,2274.3052,4.9844},
};
How do I make it so those above will only let TEAM_BAYSIDE spawn there?

or if not, how do I make it so a certain class spawns in one of the 5 random spawns?
Thanks.
Reply
#2

pawn Код:
public OnPlayerSpawn(playerid) // When the player spawns
{
    if(gTeam[playerid] == TEAM_BAYSIDE) // Replace gTeam with the variable that holds the player's team.
    {
        new x = random(sizeof randomSpawns); // Create a variable with a random number.
        SetPlayerPos(playerid, randomSpawns[x][0], randomSpawns[x][1], randomSpawns[x][2]); // Set the player's position to the co-ords corresponding with the random number.
    }
    else
    {
        // TEAM_JIZZY code here.
    }
    return 1;
}
Commented but untested. I'm sure you can solve basic compile errors.

EDIT: Your array is too large, you only need 3 cells for spawn co-ords. x, y and z.
Reply
#3

Quote:
Originally Posted by Ensconce
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid) // When the player spawns
{
    if(gTeam[playerid] == TEAM_BAYSIDE) // Replace gTeam with the variable that holds the player's team.
    {
        new x = random(sizeof randomSpawns); // Create a variable with a random number.
        SetPlayerPos(playerid, randomSpawns[x][0], randomSpawns[x][1], randomSpawns[x][2]); // Set the player's position to the co-ords corresponding with the random number.
    }
    else
    {
        // TEAM_JIZZY code here.
    }
    return 1;
}
Commented but untested. I'm sure you can solve basic compile errors.

EDIT: Your array is too large, you only need 3 cells for spawn co-ords. x, y and z.
He used 4 because the fourth is his facing angle, even though he doesn't have one in the float.

You can also make it like this with out else:

pawn Код:
public OnPlayerSpawn(playerid) // When the player spawns
{
    if(gTeam[playerid] == TEAM_BAYSIDE) // Replace gTeam with the variable that holds the player's team.
    {
        new x = random(sizeof randomSpawns); // Create a variable with a random number.
        SetPlayerPos(playerid, randomSpawns[x][0], randomSpawns[x][1], randomSpawns[x][2]); // Set the player's position to the co-ords corresponding with the random number.
    }

    if(gTeam[playerid] == TEAM_JIZZY) // Replace gTeam with the variable that holds the player's team.
    {
        // 2nd floats/random spawn coordinates for jizzy's
    }
    return 1;
}
Try this code if you want only bayside's team to spawn there:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] !== TEAM_BAYSIDE)
    {
        return SendClientMessage(playerid,COLOR_RED,"You Are Not On Team Bayside. You Cannot Use This Skin.");
    }
    else
    {
        return 1;
    }
}
! = Short form for NOT TEAM_BAYSIDE

This is untested and I'm not sure if it works.

If it doesn't let me know here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)