Random spawns?
#1

Hello,i've the coordinates for random spawns for COP and CIV team.

Here is:

pawn Код:
AddPlayerClass(0,-1624.7889,661.7517,-5.2422,15.6977,0,0,0,0,0,0); // spawn cops 1
AddPlayerClass(0,-1598.7067,679.4637,-5.2422,1.2324,0,0,0,0,0,0); // spawn cops 2
AddPlayerClass(0,-1614.2136,732.3307,-5.2422,359.9951,0,0,0,0,0,0); // spawn cops 3
AddPlayerClass(0,-1620.7598,685.4606,7.1901,190.0825,0,0,0,0,0,0); // spawn cops 4
AddPlayerClass(0,-2051.7437,478.5006,35.1723,261.2405,0,0,0,0,0,0); // spawn civilian 1
AddPlayerClass(0,-2036.9413,1194.0226,45.4453,165.4971,0,0,0,0,0,0); // spawn civilian 2
AddPlayerClass(0,-1770.8910,1202.6089,25.1250,192.7926,0,0,0,0,0,0); // spawn civilian 3
AddPlayerClass(0,-1551.7037,1165.8408,7.1875,56.0145,0,0,0,0,0,0); // spawn civilian 4
How to make 2 different random spawns for teams?
Reply
#2

pawn Код:
new Float:RandomCopSpawns[][] =
{
    {-1624.7889,661.7517,-5.2422,15.6977},
    {-1598.7067,679.4637,-5.2422,1.2324},
    {-1614.2136,732.3307,-5.2422,359.9951},
    {-1620.7598,685.4606,7.1901,190.0825},
};

new Float:RandomCivilSpawns[][] =
{
    {-2051.7437,478.5006,35.1723,261.2405},
    {-2036.9413,1194.0226,45.4453,165.4971},
    {-1770.8910,1202.6089,25.1250,192.7926},
    {-1551.7037,1165.8408,7.1875,56.0145},
};

public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_COP)
    {
        /* User RandomCopSpawns here */
    }
    else
    {
        /* Civil HEre */
    }
    return 1;
}
Reply
#3

You can also use AddPlayerClassEx
Reply
#4

Quote:
Originally Posted by Snowman12
Посмотреть сообщение
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_COP)
    {
        /* User RandomCopSpawns here */
    }
    else
    {
        /* Civil HEre */
    }
    return 1;
}
Thanks but,what code i add to random spawn the player OnPlayerSpawn?
Reply
#5

https://sampwiki.blast.hk/wiki/Random
Reply
#6

pawn Код:
new Float:SpawnsCivilian[][5] =
{
    {-2051.7437,478.5006,35.1723,261.2405},
    {-2036.9413,1194.0226,45.4453,165.4971},
    {-1770.8910,1202.6089,25.1250,192.7926},
    {-1551.7037,1165.8408,7.1875,56.0145}
};

new Float:SpawnsCops[][5] =
{
{-1624.7889,661.7517,-5.2422,15.6977},
{-1598.7067,679.4637,-5.2422,1.2324},
{-1614.2136,732.3307,-5.2422,359.9951},
{-1620.7598,685.4606,7.1901,190.0825}
};
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == Cop)
    {
        SetPlayerPos(playerid, SpawnsCops[rand][0], SpawnsCops[rand][1],SpawnsCops[rand][2]);SetPlayerFacingAngle(playerid, SpawnsCops[rand][3]);
   
    }
    else
    {
        SetPlayerPos(playerid, SpawnsCivilian[rand][0], SpawnsCivilian[rand][1],SpawnsCivilian[rand][2]);SetPlayerFacingAngle(playerid, SpawnsCivilian[rand][3]);
    }
    return 1;
}
Untested
Change the gTeam on player spawn to your own
Reply
#7

Thanks,but i got this:

error 017: undefined symbol "rand"

WTF?
Reply
#8

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == Cop)
    {
        new rand = random(sizeof(BattleFieldSpawns));
        SetPlayerPos(playerid, SpawnsCops[rand][0], SpawnsCops[rand][1],SpawnsCops[rand][2]);SetPlayerFacingAngle(playerid, SpawnsCops[rand][3]);
   
    }
    else
    {
new rand = random(sizeof(BattleFieldSpawns));        
SetPlayerPos(playerid, SpawnsCivilian[rand][0], SpawnsCivilian[rand][1],SpawnsCivilian[rand][2]);SetPlayerFacingAngle(playerid, SpawnsCivilian[rand][3]);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)