22.03.2013, 22:34
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.
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)
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;
}