Warning about speedo
#1

(7350) : warning 219: local variable "VehicleStatus" shadows a variable at a preceding level
pawn Код:
public SpeedoMeterUp()
{
    new Float:PosX;
    new Float:PosY;
    new Float:PosZ;
    new Float:PlayerSpeedDistance;
    new value;
    new Float:VehHealth;
    new VehicleStatus[15];  //---< WARNING

    for(new i=0; i< MAX_PLAYERS; i++)
    {
        if(VehicleStatus[GetPlayerVehicleID(i)] == 1)
        {
            VehicleStatus = "~r~Locked";
        }
        else
        {
            VehicleStatus = "~g~Unlocked";
        }
    if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
    {
        GetPlayerPos(i, PosX, PosY, PosZ);
        GetPlayerVehicleID(i);
        GetVehicleHealth(GetPlayerVehicleID(i), VehHealth);
        PlayerSpeedDistance = floatsqroot(floatpower(floatabs(floatsub(PosX,ReadPlayerPosition[i][ReadX])),2)+floatpower(floatabs(floatsub(PosY,ReadPlayerPosition[i][ReadY])),2)+floatpower(floatabs(floatsub(PosZ,ReadPlayerPosition[i][ReadZ])),2));
        value = floatround(PlayerSpeedDistance * 5000);
        new Zone[MAX_ZONE_NAME];
        GetPlayer2DZone(i, Zone, MAX_ZONE_NAME);
        if(SpeedoMeter[i] == 0)
        {
            TextDrawShowForPlayer(i, Box[i]);
            TextDrawShowForPlayer(i, Line1[i]);
            TextDrawShowForPlayer(i, Line2[i]);
            TextDrawShowForPlayer(i, Line3[i]);
            TextDrawShowForPlayer(i, Line4[i]);
            TextDrawShowForPlayer(i, Credits[i]);
            TextDrawShowForPlayer(i, mph[i]);
            TextDrawShowForPlayer(i, Func[i]);
            SpeedoMeter[i] = 1;
        }
            new MPH = floatround(value/1600);
            new KPH = floatround(value/1000);

            format(lstring,sizeof(lstring),"~b~Vehicle: ~w~%s~n~~b~Health: ~w~%.2f~n~~b~Altitude: ~w~%.1f~n~~b~Gps: ~w~%s~n~~b~Status: %s",VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400],VehHealth,PosZ,Zone,VehicleStatus);
            TextDrawSetString(Func[i], lstring);

            format(lstr,sizeof(lstr),"%sMPH: ~w~%d  %sKM/H: ~w~%d",MPH_KPH_Color,MPH,MPH_KPH_Color,KPH);
            TextDrawSetString(mph[i], lstr);

        if(VehHealth <= 500)
        {
            format(lstring,sizeof(lstring),"%sVehicle: ~w~%s~n~%sHealth: ~w~~r~%.2f~n~%sAltitude: ~w~%.1f~n~%sGps: ~w~%s",CategoriesColor,VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400],CategoriesColor,VehHealth,CategoriesColor,PosZ,CategoriesColor,Zone);
            TextDrawSetString(Func[i], lstring);
        }
        if(KPH >= VehicleMaxSpeed)
        {
            TogglePlayerControllable(i,0);
            UnFreeze = SetTimer("UnFreezeCar", 250, 1);
            format(lstr,sizeof(lstr),"~g~MPH: ~w~%d  ~g~KM/H: ~r~%d",MPH,KPH);
            TextDrawSetString(mph[i], lstr);
        }
    }

        ReadPlayerPosition[i][ReadX] = PosX, ReadPlayerPosition[i][ReadY] = PosY, ReadPlayerPosition[i][ReadZ] = PosZ;
    }
    for(new i=0; i< MAX_PLAYERS; i++)
    {
        if(!IsPlayerInAnyVehicle(i))
        {
            TextDrawHideForPlayer(i, Box[i]);
            TextDrawHideForPlayer(i, Line1[i]);
            TextDrawHideForPlayer(i, Line2[i]);
            TextDrawHideForPlayer(i, Line3[i]);
            TextDrawHideForPlayer(i, Line4[i]);
            TextDrawHideForPlayer(i, Credits[i]);
            TextDrawHideForPlayer(i, mph[i]);
            TextDrawHideForPlayer(i, Func[i]);
            SpeedoMeter[i] = 0;
        }
    }
    return 1;
}
Reply
#2

Quote:
Originally Posted by vassilis
Посмотреть сообщение
(7350) : warning 219: local variable "VehicleStatus" shadows a variable at a preceding level
As you can see It's a warning, So It doesn't matter XD but let me try to solve it for you.
Reply
#3

VehicleStatus is declared as global variable so change the name of that string and where it's used in SpeedoMeterUp.
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
VehicleStatus is declared as global variable so change the name of that string and where it's used in SpeedoMeterUp.
He's right!, Try it
Reply
#5

Ok thanks.
Reply
#6

Quote:
Originally Posted by Teemo
Посмотреть сообщение
As you can see It's a warning, So It doesn't matter XD
Yes, it does matter. Warnings indicate that something is syntactically correct, but quite possibly logically wrong. There are only a handful warnings that can be safely ignored. This isn't one of them.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)