I think you should set value to variable ID before this:
pawn Код:
format(String, sizeof(String), "SELECT * FROM `ownedcars` WHERE `ID` = %i", ID);
Also, when player enters vehicle, you are checking the vehicledata at vehicleid index which is incorrect because when you load vehicle, the ID is different than vehicleid.