tag mismatch problem
#1

pawn Code:
new Float:RentACar[141][8] =
{
    // model, x, y, z, a, color, price
    {412, 2119.83203125, -1784.43359375, 13.31082916, 90.00000000, 119, 100}, //Voodoo
    //rest of code
};

For creating vehicles:
pawn Code:
new RentVozilo[141];

for(new i; i < sizeof(RentVozilo); i++)
    {
        RentVozilo[i] = AddStaticVehicleEx(RentACar[i][0], RentACar[i][1], RentACar[i][2], RentACar[i][3], RentACar[i][4], RentACar[i][5], RentACar[i][5], 200);
    }
I have "tag mismatch" error because x, y, z, a are float, but modelid, color and price are int.
How to fix that errors? :/
Reply
#2

You declared your entire variable as a float, that's why.

You should use an enum, so you can use multiple types of variables.

An example of this would be:
pawn Code:
enum eVehicleData {
    iModel,
    Float: fPosition[3], // X, Y, Z angles
    Float: fSpawnAngle,
    iColor[2], // Cars have 2 colours. We're storing these in an array, like fPosition
    iPrice,
    iSpawnID,
}

new
    aVehicleData[141][eVehicleData]; // 141 is what you set, so I'm going to use this as to how many slots can be declared

stock someVehicleFunction() {
    for(new i = 0; i < 140; i++) { // Same again here with the slots
        // A more efficient way would be creating a variable to store each ID in the enum. I say efficient, it's a bit more convenient
        aVehicleData[i][iSpawnID] = AddStaticVehicleEx(aVehicleData[i][iModel], aVehicleData[i][fPosition][0], aVehicleData[i][fPosition][1], aVehicleData[i][fPosition][2], aVehicleData[i][fSpawnAngle], aVehicleData[i][iColor][0], aVehicleData[i][iColor][1], 200);
    }
   
    return 1;
}
Reply
#3

OK, thank you.

Can you explain me how to add vehicle data like in my example:
pawn Code:
new Float:RentACar[141][8] =
{
    // model, x, y, z, a, color, price
    {412, 2119.83203125, -1784.43359375, 13.31082916, 90.00000000, 119, 100}, //Voodoo
    //rest of code
};

Where to add modelid, positions, etc?
Reply
#4

You'd have to manually set them like so:

pawn Code:
aVehicleData[0][iModel] = 412;
aVehicleData[0][fPosition][0] = 2119.83203125;
aVehicleData[0][fPosition][1] = -1784.43359375;
aVehicleData[0][fPosition][2] = 13.31082916;
aVehicleData[0][fSpawnAngle] = 90.00000000;
aVehicleData[0][iPrice] = 100;
aVehicleData[0][iColor][0] = -1;
aVehicleData[0][iColor][1] = 2;
and change the '[0]' after 'aVehicleData' each time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)