09.05.2014, 18:48
From what I understood that player must be in a vehicle to buy it, then before you RemovePlayerFromVehicle, set a variable and save the vehicleid in it after you remove the player from the vehicle respawn it.
This should work.
pawn Код:
new vehicle_id = GetPlayerVehicleID(playerid);
GivePlayerMoney(playerid, -VehicleValue[id]);
new dealerid = strval(VehicleOwner[id]);
VehicleCreated[freeid] = VEHICLE_PLAYER;
VehicleModel[freeid] = VehicleModel[id];
VehiclePos[freeid] = DealershipPos[dealerid];
VehicleColor[freeid] = VehicleColor[id];
VehicleInterior[freeid] = VehicleInterior[id];
VehicleWorld[freeid] = VehicleWorld[id];
VehicleValue[freeid] = VehicleValue[id];
GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
for(new d=0; d < sizeof(VehicleTrunk[]); d++)
{
VehicleTrunk[freeid][d][0] = 0;
VehicleTrunk[freeid][d][1] = 0;
}
for(new d=0; d < sizeof(VehicleMods[]); d++)
{
VehicleMods[freeid][d] = 0;
}
VehiclePaintjob[freeid] = 255;
VehicleLock[freeid] = 0;
VehicleAlarm[freeid] = 0;
UpdateVehicle(freeid, 0);
SaveVehicle(freeid);
new msg[128];
format(msg, sizeof(msg), "You have bought this vehicle for $%d", VehicleValue[id]);
SendClientMessage(playerid, COLOR_WHITE, msg);
SetVehicleToRespawn(vehicle_id);
RemovePlayerFromVehicle(playerid);