i cant get this loop functioning as i want...
#1

hey all,

i can't get this loop as i want it, i want it to loop through the "OtherCars[MAX_PLAYERS][4]", but instead it only checks OtherCars[playerid][0], and 1, 2, 3 is just gone, he doesnt checks them at all..., i already tried break; and continue;, both didnt work..

pawn Code:
CMD:park(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't in any vehicle.");
    new vehicleid = GetPlayerVehicleID(playerid);
    for(new i; i < sizeof(OtherCars[]); i++)
    {
        if(vehicleid == OtherCars[playerid][i])
        {
            new Float:x, Float:y, Float:z, Float:angle;
            GetVehiclePos(OtherCars[playerid][i], x, y, z);
            GetVehicleZAngle(OtherCars[playerid][i], angle);
            SaveFloatToCarSlot(playerid, i, "XSpawn", x );
            SaveFloatToCarSlot(playerid, i, "YSpawn", y );
            SaveFloatToCarSlot(playerid, i, "ZSpawn", z );
            SaveFloatToCarSlot(playerid, i, "ASpawn", angle );
            SaveVehComponents(playerid, OtherCars[playerid][i], i);
            foreach(Player, p)
            {
                if(IsPlayerInVehicle(playerid, vehicleid))
                {
                    if(p != playerid && GetPlayerState(p) == PLAYER_STATE_DRIVER)
                    {
                        RemovePlayerFromVehicle(p);
                    }
                }
            }
            SetVehiclePosZAngle( OtherCars[playerid][i], x, y, z, angle );
            PutPlayerInVehicle(playerid, OtherCars[playerid][i], 0);
            SendClientMessage(playerid, COLOR_WHITE, "Car Succesfully Parked.");
            continue;
        }
        else return SendClientMessage(playerid, COLOR_RED, "This ain't your car.");
    }
    return 1;
}
whats wrong with this code that it only checks the first one of the othercars?
it keeps saying: this aint your car... except for the car that is at slot 0(OtherCars[playerid][0])

greets
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)