Help with this
#1

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}
};
--

OnPlayerSpawn:

pawn Код:
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[rand][0], SpawnsCivilian[rand][1],SpawnsCivilian[rand][2]);SetPlayerFacingAngle(playerid, SpawnsCivilian[rand][3]);

    }
---

error 017: undefined symbol "rand"

What's wrong?
Reply
#2

http://forum.sa-mp.com/showpost.php?...60&postcount=8

Reply
#3

That is crashing my pawno compiler,lol.
Reply
#4

EDIT: It's 4 not 5

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;
}
Reply
#5

Same.
Reply
#6

BUMP
Reply
#7

Add this:

pawn Код:
new rand = random( /* howmutch spawn locations do you have in the variables */ );
And you will be fine.

'Unidentified' means it isnt defined in the script. Like when youre doing
pawn Код:
if( a == b )
It should say undefined symbol a & b, since we didnt make those variables
Reply
#8

pawn Код:
public OnPlayerSpawn(playerid)
{
    new rand = random(4);
    if(gTeam[playerid] == COP) { SetPlayerPos(playerid,SpawnCops[rand][0],SpawnCops[rand][1],SpawnCops[rand][2]); SetPlayerFacingAngle(playerid,SpawnCops[rand][3]);}
    else
    {
        rand = random(4);
        SetPlayerPos(playerid,SpawnCivillian[rand][0],SpawnCivillian[rand][1],SpawnCivillian[rand][2]);
        SetPlayerFacingAngle(playerid,SpawnCivillian[rand][3]);
    }
    return 1;
}
Don't tell me it returns Undentified symbol...
Reply
#9

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;
}
Reply
#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


Forum Jump:


Users browsing this thread: 5 Guest(s)