Open shyricaus opened 5 years ago
i did update your comment you forgot to put one line :)
for who wants to use with esx_vehicleshop
AddEventHandler('esx_vehicleshop:hasEnteredMarker', function (zone)
if zone == 'ShopEntering' then
if Config.EnablePlayerManagement then
if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' then
CurrentAction = 'reseller_menu'
CurrentActionMsg = _U('shop_menu')
CurrentActionData = {}
end
else
CurrentAction = 'shop_menu'
CurrentActionMsg = _U('shop_menu')
CurrentActionData = {}
end
end
if zone == 'GiveBackVehicle' and Config.EnablePlayerManagement then
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
CurrentAction = 'give_back_vehicle'
CurrentActionMsg = _U('vehicle_menu')
CurrentActionData = {
vehicle = vehicle
}
end
end
if zone == 'ResellVehicle' then
local playerPed = PlayerPedId()
if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
local networkid = NetworkGetNetworkIdFromEntity(vehicle)
local vehicleData = nil
for i=1, #Vehicles, 1 do
if GetHashKey(Vehicles[i].model) == GetEntityModel(vehicle) then
vehicleData = Vehicles[i]
break
end
end
local resellPrice = math.floor(vehicleData.price / 100 * Config.ResellPercentage)
CurrentAction = 'resell_vehicle'
TriggerServerEvent('esx_jb_stopvehicledespawn:vehicleenteredingarage', networkid)
CurrentActionMsg = _U('sell_menu', vehicleData.name, resellPrice)
CurrentActionData = {
vehicle = vehicle,
price = resellPrice
}
end
end
if zone == 'BossActions' and Config.EnablePlayerManagement and ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'cardealer' and ESX.PlayerData.job.grade_name == 'boss' then
CurrentAction = 'boss_actions_menu'
CurrentActionMsg = _U('shop_menu')
CurrentActionData = {}
end
end)
for those who want to use with esx-qalle-sellvehicles
function OpenSellMenu(veh, price, buyVehicle, owner)
local elements = {}
local networkid = NetworkGetNetworkIdFromEntity(veh)
if not buyVehicle then
if price ~= nil then
table.insert(elements, { ["label"] = "Alterar preço - " .. price .. " :-", ["value"] = "price" })
table.insert(elements, { ["label"] = "Colocar à venda", ["value"] = "sell" })
else
table.insert(elements, { ["label"] = "Preço definido - :-", ["value"] = "price" })
end
else
table.insert(elements, { ["label"] = "Comprar " .. price .. " - :-", ["value"] = "buy" })
if owner then
table.insert(elements, { ["label"] = "Remover Veículo", ["value"] = "remove" })
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'sell_veh',
{
title = "Menu Veículo",
align = 'top-right',
elements = elements
},
function(data, menu)
local action = data.current.value
if action == "price" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'sell_veh_price',
{
title = "Preço do Veículo"
},
function(data2, menu2)
local vehPrice = tonumber(data2.value)
menu2.close()
menu.close()
OpenSellMenu(veh, vehPrice)
end, function(data2, menu2)
menu2.close()
end)
elseif action == "sell" then
local vehProps = ESX.Game.GetVehicleProperties(veh)
ESX.TriggerServerCallback("esx-qalle-sellvehicles:isVehicleValid", function(valid)
if valid then
DeleteVehicle(veh)
TriggerServerEvent('esx_jb_stopvehicledespawn:vehicleenteredingarage', networkid)
ESX.ShowNotification("Você colocou o ~g~veículo~s~ à venda por - " .. price .. " :-")
menu.close()
else
ESX.ShowNotification("O seu ~g~veículo!~s~ já está a ~r~venda~s~ " .. #Config.VehiclePositions .. " veículos à venda!")
end
end, vehProps, price)
elseif action == "buy" then
ESX.TriggerServerCallback("esx-qalle-sellvehicles:buyVehicle", function(isPurchasable, totalMoney)
if isPurchasable then
DeleteVehicle(veh)
ESX.ShowNotification("Você ~g~comprou~s~ um veículo por " .. price .. " :-")
menu.close()
else
ESX.ShowNotification("Você ~r~não~s~ tem dinheiro suficiente, está faltando " .. price - totalMoney .. " :-")
end
end, ESX.Game.GetVehicleProperties(veh), price)
elseif action == "remove" then
ESX.TriggerServerCallback("esx-qalle-sellvehicles:buyVehicle", function(isPurchasable, totalMoney)
if isPurchasable then
DeleteVehicle(veh)
ESX.ShowNotification("Você ~g~removeu~s~ seu veículo")
menu.close()
end
end, ESX.Game.GetVehicleProperties(veh), 0)
end
end, function(data, menu)
menu.close()
end)
end
for anyone who wants to use with esx_ownedcarthief
function SellStolenCar()
local playerPed = PlayerPedId()
local veh = GetVehiclePedIsIn(playerPed, false)
local vehicleData = ESX.Game.GetVehicleProperties(veh)
local networkid = NetworkGetNetworkIdFromEntity(veh)
if GetPedInVehicleSeat(veh, -1) == playerPed and not SellWait then
SellWait = true
ESX.TriggerServerCallback('esx_ownedcarthief:GetVehPrice', function (ownedcar, vehicles)
ESX.ShowNotification(_U('checkvehicle'))
Citizen.CreateThread(function()
if ownedcar then
for i=1, #vehicles, 1 do
Citizen.Wait(1)
local vehicle = vehicles[i]
if vehicleData.model == GetHashKey(vehicle.model) then
price = math.floor(vehicle.price / 100 * Config.ResellPercentage)
ESX.Game.DeleteVehicle(veh)
TriggerServerEvent('esx_ownedcarthief:VehSold', true, price, vehicleData.plate)
TriggerServerEvent('esx_jb_stopvehicledespawn:vehicleenteredingarage', networkid)
SellWait = false
break
end
end
elseif not Config.OnlyPlayerCar and not ownedcar then
price = Config.NpcCarPrice
ESX.Game.DeleteVehicle(veh)
TriggerServerEvent('esx_ownedcarthief:VehSold', false, price, vehicleData.plate)
SellWait = false
elseif Config.OnlyPlayerCar and not ownedcar then
ESX.ShowNotification(_U('not_work_with_npc'))
SellWait = false
end
end)
end, vehicleData.plate)
end
end
networkid = NetworkGetNetworkIdFromEntity(vehicle) TriggerServerEvent('vehicleenteredingarage', networkid)
Idk where to put this in correctly, I am using esx_jb_eden_garage2, do i put it in the client lua or server lua? Also where would I place it? I tried using the ones above as reference but don't see where you triggerserverevent
I dont know, either.
i am using esx_garage