[NEW RELEASE] [ESX] KUANA_GARAGE 2.0! (need esx_vehicleshop)

Hi, so im 17 old (a kid who do scripts like that).
I made this plugin for a wile and this is the last release i made.
If this get a good feedback, maybe i will do more scripts.

Video: https://youtu.be/sv0Bt76SmVU - Sorry for my bad english, im portuguese.

Download: https://github.com/Kuanaxd/KUANA_GARAGE

Vehicle Shop/
Server:

  RegisterServerEvent('esx_vehicleshop:setVehicleOwned')
  AddEventHandler('esx_vehicleshop:setVehicleOwned', function (vehicleProps)
    local _source = source
    local xPlayer = ESX.GetPlayerFromId(_source)

    MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, x, y, z, h, health) VALUES (@owner, @plate, @vehicle, @xx, @yy, @zz, @hh, @vida)',
    {
      ['@owner']   = xPlayer.identifier,
      ['@plate']   = vehicleProps.plate,
      ['@vehicle'] = json.encode(vehicleProps),
      ["@xx"] = -245.86,
      ["@yy"] = 6257.2,
      ["@zz"] = 31.09,
      ["@hh"] = 223.97,
      ["@vida"] = 1000
    }, function (rowsChanged)
      TriggerClientEvent('esx:showNotification', _source, _U('vehicle_belongs', vehicleProps.plate))
    end)
  end)

  RegisterServerEvent('esx_vehicleshop:setVehicleOwnedPlayerId')
  AddEventHandler('esx_vehicleshop:setVehicleOwnedPlayerId', function (playerId, vehicleProps)
    local xPlayer = ESX.GetPlayerFromId(playerId)

    MySQL.Async.execute('INSERT INTO owned_vehicles (owner, plate, vehicle, x, y, z, h, health) VALUES (@owner, @plate, @vehicle, @xx, @yy, @zz, @hh, @vida)',
    {
      ['@owner']   = xPlayer.identifier,
      ['@plate']   = vehicleProps.plate,
      ['@vehicle'] = json.encode(vehicleProps),
      ["@xx"] = -245.86,
      ["@yy"] = 6257.2,
      ["@zz"] = 31.09,
      ["@hh"] = 223.97,
      ["@vida"] = 1000
    }, function (rowsChanged)
      TriggerClientEvent('esx:showNotification', playerId, _U('vehicle_belongs', vehicleProps.plate))
    end) 
  end)

Mechanic/
Client:

{label = "Nitro Canister - 20000$",      value = 'giveboost'},


if data.current.value == 'giveboost' then
      local playerPed = PlayerPedId()
      local vehicle   = ESX.Game.GetVehicleInDirection()
      local coords    = GetEntityCoords(playerPed)
      local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)

      if IsPedSittingInAnyVehicle(playerPed) then
        ESX.ShowNotification(_U('inside_vehicle'))
        return
      end

      if DoesEntityExist(vehicle) then
        isBusy = true
        TaskStartScenarioInPlace(playerPed, 'PROP_HUMAN_BUM_BIN', 0, true)
        Citizen.CreateThread(function()
          Citizen.Wait(20000)

          ESX.TriggerServerCallback('esx_mechanicjob:checkdbnitro', function(check)
            if check == true then
              ESX.ShowNotification("Nitro Canister ~g~placed~w~")
            elseif check == false then
              ESX.ShowNotification("Nitro Canister was ~y~already~w~ placed or you ~r~dont~w~ have enough money.")
            end
          end, vehicleProps.plate)
          SetVehicleEngineOn(vehicle, true, true)
          ClearPedTasksImmediately(playerPed)
          isBusy = false
        end)
      else
        ESX.ShowNotification(_U('no_vehicle_nearby'))
      end

else

Server:

ESX.RegisterServerCallback('esx_mechanicjob:checkdbnitro', function(source, cb, plate)
    local xPlayer = ESX.GetPlayerFromId(source)
    local result = MySQL.Sync.fetchAll("SELECT nitro FROM owned_vehicles WHERE plate = @plate", {
      ['@plate'] = plate
      })
      local check          = result[1]
      local resultado	   = check['nitro']
      if xPlayer.getMoney() >= 20000 then
      if resultado == "sim" then
        cb(false)
      elseif resultado == "nao" then
        MySQL.Sync.execute("UPDATE owned_vehicles SET nitro =@comprado WHERE plate=@plate",{['@comprado'] = "sim" , ['@plate'] = plate})
        xPlayer.removeMoney(20000)
        cb(true)
      end
      else
      cb(false)
      end
  end)


  ESX.RegisterServerCallback('esx_mechanicjob:usedbnitro', function(source, cb, plate)
    local xPlayer = ESX.GetPlayerFromId(source)
    local result = MySQL.Sync.fetchAll("SELECT nitro FROM owned_vehicles WHERE plate = @plate", {
      ['@plate'] = plate
      })
      local check          = result[1]
      local resultado	   = check['nitro']

      if resultado == "sim" then
      cb(true)
      MySQL.Sync.execute("UPDATE owned_vehicles SET nitro =@comprado WHERE plate=@plate",{['@comprado'] = "nao" , ['@plate'] = plate})
      elseif resultado == "nao" then
      cb(false)
      end
end)
19 Likes

Nice i don’t know shit how to read the stuff in the script so hope someone can translate it to english also can you add some images / video?

ya sure, my internet is so bad so wait like 1h :sob:

here is the first, i need to do the second… wait. https://youtu.be/yGOTxbZR4TM

use https://translate.google.com like everyone who doesnt know english does.

1 Like

google translate is not the best and im not going to use my time to translate it to english

Em vez de teres de ir buscar o carro a garagem, era melhor se o carro n desse despawn

(tens de falar em ingles) Thats true you can change that if you want but if you do that every time you do /garagem you can spawn a car and get infinite cars.

But if the car doesnt despawn its not necessary the /garagem
Like in SAMP RP

Nice ! Could you upload to github so we can fork this ?

Amazing!

How can you activate that they take money from you when ur car is broken? or just cant /park until repair the vehicle?

1 Like

you can take that code from esx_eden_garage.

Add me at discord: James Black#2027

(Sou pt)

@KUANA tira-me só uma dúvida, eu faço /garagem, aquilo abre o menu e eu clico em lista de veículos e depois desaparece o menu, ou sejas, não apareçe os veículos para spawnar, é possível ajudares?

o veiculo faz spawn nas coordadas da base de dados.

@KUANA a mim tambem me acontece eu comprei um carro e fiz /estacionar e o carro desapareceu(foi pa garagem). Ate aqui tudo bem, mas depois faço /garagem e vou a tirar o carro clico no carro que quero mas ele nao aparece. Se poderes ajudar, agradecia imenso.

Did you put the sql file in you database? Do you have the last version of vehicle shop? If yes download again my plugin i upload again with this fix i think

i cant get the solution that people cant abuse to park and unpark the car for fix it, instead have to use mecano job
possible solutions;
when people use /park > they have to pay likle 200$ everytime or
if car is damaged, then u cant park it.

there are is possible solutions, i tried to implement it, but not work for me

Just code, when vehicle is (0-1000) health, i recommend to 935, you cant do the command,

i have tried, not work :confused:

    local damage  = GetVehicleEngineHealth(current)
    if IsPedInAnyVehicle(ped) and damage >= 950 then