tag mismatch problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: tag mismatch problem (
/showthread.php?tid=248891)
tag mismatch problem -
Pooh7 - 16.04.2011
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? :/
Re: tag mismatch problem -
Calgon - 16.04.2011
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;
}
Re: tag mismatch problem -
Pooh7 - 16.04.2011
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?
Re: tag mismatch problem -
Calgon - 16.04.2011
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.