Array Problem
#1

I have the following code -

pawn Код:
new PoliceCars[][] =
{
    {598, 613.835, -597.2714, 16.9790, 270.8588, 0, 1, 1},
    {598, 613.8523, -601.5485, 16.9765, 270.8588, 0, 1, 1}
};

stock CreatePoliceVehicles()
{
    for(new i; i < sizeof(PoliceCars); i++)
    {
        CreateVehicle(PoliceCars[i][0], PoliceCars[i][1], PoliceCars[i][2], PoliceCars[i][3], PoliceCars[i][4], PoliceCars[i][5], PoliceCars[i][6], -1, 1);
    }
    return 1;
}
Now obviously this isn't working or I wouldn't be here. Can anyone tell me what I'm doing wrong here?

I'm getting Tag Mismatch errors on the actual value lines.
Reply
#2

You need an Enumerator, like this:

PHP код:
#define P:: e_P_
enum e_Police {
    
P::model,
    
Float:P::x,
    
Float:P::y,
    
Float:P::z,
    
Float:P::a,
    
P::c1,
    
P::c2,
    
P::respawn
};
stock const PoliceCars[][e_Police] =
{
    {
598613.835, -597.271416.9790270.858801, -1},
    {
598613.8523, -601.548516.9765270.858801, -1}
};
stock CreatePoliceVehicles()
{
    for(new 
isizeof(PoliceCars); i++)
    {
        
CreateVehicle(PoliceCars[i][P::model], PoliceCars[i][P::x], PoliceCars[i][P::y], PoliceCars[i][P::z], PoliceCars[i][P::a], PoliceCars[i][P::c1], PoliceCars[i][P::c2], PoliceCars[i][P::respawn], 1);
    }
    return 
1;

Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
You need an Enumerator, like this:

PHP код:
#define P:: e_P_
enum e_Police {
    
P::model,
    
Float:P::x,
    
Float:P::y,
    
Float:P::z,
    
Float:P::a,
    
P::c1,
    
P::c2,
    
P::respawn
};
stock const PoliceCars[][e_Police] =
{
    {
598613.835, -597.271416.9790270.858801, -1},
    {
598613.8523, -601.548516.9765270.858801, -1}
};
stock CreatePoliceVehicles()
{
    for(new 
isizeof(PoliceCars); i++)
    {
        
CreateVehicle(PoliceCars[i][P::model], PoliceCars[i][P::x], PoliceCars[i][P::y], PoliceCars[i][P::z], PoliceCars[i][P::a], PoliceCars[i][P::c1], PoliceCars[i][P::c2], PoliceCars[i][P::respawn], 1);
    }
    return 
1;

Thank you, it's been a while. ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)