Error 022: lvalue is not constant
#1

pawn Code:
stock GetClosestCar(playerid, exception = INVALID_VEHICLE_ID) {

    new
        Float: Distance,
        target = -1,
        Float: vPos[3];

    if(!IsPlayerInAnyVehicle(playerid)) GetPlayerPos(playerid, vPos[0], vPos[1], vPos[2]);
    else GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);

    for(new v; v < MAX_VEHICLES; v++) if(GetVehicleModel(v) >= 400) {
        if(v != exception && (target < 0 || Distance > GetDistanceToCar(playerid, v, vPos[0], vPos[1], vPos[2]))) {
            target = v;
            Distance = GetDistanceToCar(playerid, v, vPos[0], vPos[1], vPos[2]); // Before the rewrite, we'd be running GetPlayerPos 2000 times...
        }
    }
    return target;
}
Reply


Messages In This Thread
Error 022: lvalue is not constant - by damian123 - 26.09.2013, 15:44
Re: Error 022: lvalue is not constant - by Blast3r - 26.09.2013, 16:46
Re: Error 022: lvalue is not constant - by Konstantinos - 26.09.2013, 16:52
Re: Error 022: lvalue is not constant - by damian123 - 26.09.2013, 17:04

Forum Jump:


Users browsing this thread: 1 Guest(s)