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

Just remove the else...

If he has no cars, it's still going to say it however many times you have your loop loop. If you want it to say "this 'ain't' your car", you can add a counter.
pawn Code:
CMD:park(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't in any vehicle.");
    new vehicleid = GetPlayerVehicleID(playerid), count=0;
    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.");
            count++;
            break;
        }
    }
    if(!count) SendClientMessage(playerid, COLOR_RED, "This isn't your car.");
    return 1;
}
That would detect if the car is the players. It checks if the count var = 0 (since it's only 1 if it's the players car) and sends an error message if it is (or whatever)
Reply


Messages In This Thread
i cant get this loop functioning as i want... - by Apenmeeuw - 22.03.2013, 21:18
Re: i cant get this loop functioning as i want... - by Vince - 22.03.2013, 21:25
Re: i cant get this loop functioning as i want... - by Apenmeeuw - 22.03.2013, 22:20
Re: i cant get this loop functioning as i want... - by [ABK]Antonio - 22.03.2013, 22:24
Re: i cant get this loop functioning as i want... - by Apenmeeuw - 22.03.2013, 22:27
Re: i cant get this loop functioning as i want... - by [ABK]Antonio - 22.03.2013, 22:34
Re: i cant get this loop functioning as i want... - by Apenmeeuw - 23.03.2013, 07:45

Forum Jump:


Users browsing this thread: 2 Guest(s)