Help with this
#10

Quote:
Originally Posted by Dwane
Посмотреть сообщение
This works. I tested it on localhost. However, your compiler crashed because you used random from the Spawns that they were 5 and you used 4.
Also, random 4 in what?
pawn Код:
new rand = random(4);
That isn't correct. We want random Spawns from the Global variables.
pawn Код:
// At The Top
new Float:SpawnsCivilian[ ][ 4 ] =
{
    {-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[ ][ 4 ] =
{
{-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}
};

public OnPlayerSpawn( playerid )
{
    new
        rand = random( sizeof( SpawnsCivilian) ),
        rand2 = random( sizeof( SpawnsCops) );
       
    if( gTeam[ playerid ] == COP )
    {
        SetPlayerPos( playerid, SpawnsCops[ rand ][ 0 ], SpawnsCops[ rand ][ 1 ],SpawnsCops[ rand ][ 2 ] );
        SetPlayerFacingAngle( playerid, SpawnsCops[ rand ][ 3 ] );
    }
    if( gTeam[ playerid ] == CIV )
    {
        SetPlayerPos( playerid, SpawnsCivilian[ rand2 ][ 0 ], SpawnsCivilian[ rand2 ][ 1 ], SpawnsCivilian[ rand2 ][ 2 ] );
        SetPlayerFacingAngle( playerid, SpawnsCivilian[ rand ][ 3 ] );
    }
    return 1;
}
sizeof(SpawnCevilians) will return 4.
What do you mean by
Quote:

Also, random 4 in what?

?
Eventually what you're doing is defining a random number between zero and four and then using it as an array position.
My code was fine.
And you don't need 2 variables as you can just reuse the first 'rand' by redefining it.
Reply


Messages In This Thread
Help with this - by Face9000 - 24.01.2012, 15:10
Re: Help with this - by Vince - 24.01.2012, 15:11
Re: Help with this - by Face9000 - 24.01.2012, 15:12
Re: Help with this - by Konstantinos - 24.01.2012, 15:14
Re: Help with this - by Face9000 - 24.01.2012, 15:15
Re: Help with this - by Face9000 - 24.01.2012, 18:09
Re: Help with this - by Wesley221 - 24.01.2012, 18:17
Re: Help with this - by [XST]O_x - 24.01.2012, 18:23
Re: Help with this - by Konstantinos - 24.01.2012, 18:38
Re: Help with this - by [XST]O_x - 24.01.2012, 18:56

Forum Jump:


Users browsing this thread: 2 Guest(s)