Respawn veh after buying it?
#4

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.

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);
This should work.
Reply


Messages In This Thread
Respawn veh after buying it? - by Pepino960 - 09.05.2014, 17:27
AW: Respawn veh after buying it? - by Pepino960 - 09.05.2014, 17:49
AW: Respawn veh after buying it? - by Pepino960 - 09.05.2014, 18:24
Re: Respawn veh after buying it? - by DaniceMcHarley - 09.05.2014, 18:48
Re: Respawn veh after buying it? - by Pepino960 - 10.05.2014, 09:40
AW: Respawn veh after buying it? - by Pepino960 - 10.05.2014, 12:28

Forum Jump:


Users browsing this thread: 1 Guest(s)