SA-MP Forums Archive
A tag mismatch warning that I don't understand... - 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)
+--- Thread: A tag mismatch warning that I don't understand... (/showthread.php?tid=456865)



[SOLVED] A tag mismatch warning that I don't understand... - Scenario - 07.08.2013

Okay, this makes absolutely no sense to me. I keep getting a tag mismatch on this line:

pawn Код:
if(vStats[vehicleID][vType] == VEHICLE_TYPE_FACTION)
"VEHICLE_TYPE_FACTION" is defined in an enum and " vType" is in a different enum but it doesn't have a specific tag or anything.

pawn Код:
enum eVehicleType
{
    VEHICLE_TYPE_ZERO_FILL, // bug prevention
    VEHICLE_TYPE_PERSONAL,
    VEHICLE_TYPE_FACTION,
    VEHICLE_TYPE_PUBLIC,
    VEHICLE_TYPE_BUSINESS,
};
However, if I use a switch, the warning goes away:

pawn Код:
switch(vStats[vehicleID][vType])
    {
        case VEHICLE_TYPE_FACTION:
        {
            //
        }
    }
It has nothing to do with the code above, because this has happened to me before with a different enum. I don't understand why it's doing this though. Isn't "VEHICLE_TYPE_FACTION" just being replaced with a number corresponding to the location in the enum?

Why would the switch work, but not the if statement?


Re: A tag mismatch warning that I don't understand... - Misiur - 07.08.2013

Your vType is probably inside enum declaring strong tag (starting with big letter). Like:

pawn Код:
enum VehicleInfo {
    vType
    //(...)
}
So, do one of the following:
pawn Код:
if(eVehicleType:vStats[vehicleID][vType] == VEHICLE_TYPE_FACTION)
//or
if(vStats[vehicleID][vType] == VehicleInfo:VEHICLE_TYPE_FACTION)
//or
if(_:vStats[vehicleID][vType] == _:VEHICLE_TYPE_FACTION)
#e: and the reason why switch isn't causing tag mismatches, is because everything in there is reduced to numeric constants (_ tag), while if checks everything


Re: A tag mismatch warning that I don't understand... - Bakr - 07.08.2013

Come on RealCop, this is described on the Wiki


Re: A tag mismatch warning that I don't understand... - Scenario - 07.08.2013

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Your vType is probably inside enum declaring strong tag (starting with big letter). Like:

pawn Код:
enum VehicleInfo {
    vType
    //(...)
}
So, do one of the following:
pawn Код:
if(eVehicleType:vStats[vehicleID][vType] == VEHICLE_TYPE_FACTION)
//or
if(vStats[vehicleID][vType] == VehicleInfo:VEHICLE_TYPE_FACTION)
//or
if(_:vStats[vehicleID][vType] == _:VEHICLE_TYPE_FACTION)
#e: and the reason why switch isn't causing tag mismatches, is because everything in there is reduced to numeric constants (_ tag), while if checks everything
Nope, it starts with a lowercase e.

pawn Код:
enum enumVehicleData
{
    vID,
    vType,
    vOwnerID,
    vModel,
    vSecurityLevel,
    vMod0,
    vMod1,
    vMod2,
    vMod3,
    vMod4,
    vMod5,
    vMod6,
    vMod7,
    vMod8,
    vMod9,
    vMod10,
    vMod11,
    vMod12,
    Float:vPosX,
    Float:vPosY,
    Float:vPosZ,
    Float:vAngle,
    vKeys,
    vFuel,
    vPaintjob,
    vMileage,
   
    vScriptID,
    bool:vLights,
    bool:vEngine,
    bool:vAlarm,
    bool:vLock,
    bool:vBonnet,
    bool:vBoot,
    Float:vSpeedM,
    Float:vSpeedTh,
    Float:vMaxSpeedTh,
    bool:vBroken
};
@Bakr: Is it really?

#e: Is it bad if I don't name my enums? Because, removing the "name" or the "tag" of the enum seems to remove the tag mismatch warning...


Re: A tag mismatch warning that I don't understand... - Vince - 07.08.2013

Do you actually use eVehicleType as an initializer somewhere? If not, you can just remove it. Otherwise, you should prefix vType with the eVehicleType tag.
pawn Код:
enum enumVehicleData {
    eVehicleType:vType
}



Re: A tag mismatch warning that I don't understand... - Scenario - 07.08.2013

I don't. I went ahead and removed it along with some of my other enum tags. I expected the compiler to tell me I couldn't do that but everything compiled fine and the enum numbers are still the same. I have no idea why we started tagging enums anyways.

Thanks guys- problem solved!

Note to self: I should read the Wiki better.