Merge pull request #722 from Taavi-AU/main

context menu implementation
This commit is contained in:
Benzo
2022-12-04 04:46:57 +01:00
committed by GitHub
16 changed files with 576 additions and 627 deletions
+70 -72
View File
@@ -11,63 +11,59 @@ end)
function OpenAmbulanceActionsMenu()
local elements = {{label = TranslateCap('cloakroom'), value = 'cloakroom'}}
local elements = {
{unselectable = true, icon = "fas fa-shirt", title = "Ambulance Actions"},
{icon = "fas fa-shirt", title = TranslateCap('cloakroom'), value = 'cloakroom'}
}
if Config.EnablePlayerManagement and ESX.PlayerData.job.grade_name == 'boss' then
table.insert(elements, {label = TranslateCap('boss_actions'), value = 'boss_actions'})
elements[#elements+1] = {
icon = "fas fa-ambulance",
title = TranslateCap('boss_actions'),
value = 'boss_actions'
}
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'ambulance_actions', {
title = TranslateCap('ambulance'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value == 'cloakroom' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == 'cloakroom' then
OpenCloakroomMenu()
elseif data.current.value == 'boss_actions' then
elseif element.value == 'boss_actions' then
TriggerEvent('esx_society:openBossMenu', 'ambulance', function(data, menu)
menu.close()
end, {wash = false})
end
end, function(data, menu)
menu.close()
end)
end
function OpenMobileAmbulanceActionsMenu()
ESX.UI.Menu.CloseAll()
local elements = {
{unselectable = true, icon = "fas fa-ambulance", title = TranslateCap('ambulance')},
{icon = "fas fa-ambulance", title = TranslateCap('ems_menu'), value = "citizen_interaction"}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mobile_ambulance_actions', {
title = TranslateCap('ambulance'),
align = 'top-left',
elements = {
{label = TranslateCap('ems_menu'), value = 'citizen_interaction'}
}}, function(data, menu)
if data.current.value == 'citizen_interaction' then
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'citizen_interaction', {
title = TranslateCap('ems_menu_title'),
align = 'top-left',
elements = {
{label = TranslateCap('ems_menu_revive'), value = 'revive'},
{label = TranslateCap('ems_menu_small'), value = 'small'},
{label = TranslateCap('ems_menu_big'), value = 'big'},
{label = TranslateCap('ems_menu_putincar'), value = 'put_in_vehicle'},
{label = TranslateCap('ems_menu_search'), value = 'search'}
}}, function(data, menu)
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "citizen_interaction" then
local elements2 = {
{unselectable = true, icon = "fas fa-ambulance", title = element.title},
{icon = "fas fa-syringe", title = TranslateCap('ems_menu_revive'), value = "revive"},
{icon = "fas fa-bandage", title = TranslateCap('ems_menu_small'), value = "small"},
{icon = "fas fa-bandage", title = TranslateCap('ems_menu_big'), value = "big"},
{icon = "fas fa-car", title = TranslateCap('ems_menu_putincar'), value = "put_in_vehicle"},
{icon = "fas fa-syringe", title = TranslateCap('ems_menu_search'), value = "search"},
}
ESX.OpenContext("right", elements2, function(menu2,element2)
if isBusy then return end
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if data.current.value == 'search' then
if element2.value == 'search' then
TriggerServerEvent('esx_ambulancejob:svsearch')
elseif closestPlayer == -1 or closestDistance > 1.0 then
ESX.ShowNotification(TranslateCap('no_players'))
else
if data.current.value == 'revive' then
if element2.value == 'revive' then
revivePlayer(closestPlayer)
elseif data.current.value == 'small' then
elseif element2.value == 'small' then
ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
if quantity > 0 then
local closestPlayerPed = GetPlayerPed(closestPlayer)
@@ -94,8 +90,7 @@ function OpenMobileAmbulanceActionsMenu()
end
end, 'bandage')
elseif data.current.value == 'big' then
elseif element2.value == 'big' then
ESX.TriggerServerCallback('esx_ambulancejob:getItemAmount', function(quantity)
if quantity > 0 then
local closestPlayerPed = GetPlayerPed(closestPlayer)
@@ -121,18 +116,12 @@ function OpenMobileAmbulanceActionsMenu()
ESX.ShowNotification(TranslateCap('not_enough_medikit'))
end
end, 'medikit')
elseif data.current.value == 'put_in_vehicle' then
elseif element2.value == 'put_in_vehicle' then
TriggerServerEvent('esx_ambulancejob:putInVehicle', GetPlayerServerId(closestPlayer))
end
end
end, function(data, menu)
menu.close()
end)
end
end, function(data, menu)
menu.close()
end)
end
@@ -328,7 +317,7 @@ end)
AddEventHandler('esx_ambulancejob:hasExitedMarker', function(hospital, part, partNum)
if not isInShopMenu then
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
end
ESX.HideUI()
CurrentAction = nil
@@ -411,14 +400,14 @@ AddEventHandler('esx_ambulancejob:putInVehicle', function()
end)
function OpenCloakroomMenu()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'cloakroom', {
title = TranslateCap('cloakroom'),
align = 'top-left',
elements = {
{label = TranslateCap('ems_clothes_civil'), value = 'citizen_wear'},
{label = TranslateCap('ems_clothes_ems'), value = 'ambulance_wear'},
}}, function(data, menu)
if data.current.value == 'citizen_wear' then
local elements = {
{unselectable = true, icon = "fas fa-shirt", title = TranslateCap('cloakroom')},
{icon = "fas fa-shirt", title = TranslateCap('ems_clothes_civil'), value = "citizen_wear"},
{icon = "fas fa-shirt", title = TranslateCap('ems_clothes_ems'), value = "ambulance_wear"},
}
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "citizen_wear" then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
TriggerEvent('skinchanger:loadSkin', skin)
isOnDuty = false
@@ -432,7 +421,7 @@ function OpenCloakroomMenu()
print("[^2INFO^7] Off Duty")
end
end)
elseif data.current.value == 'ambulance_wear' then
elseif element.value == "ambulance_wear" then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
@@ -450,29 +439,38 @@ function OpenCloakroomMenu()
end
end)
end
menu.close()
end, function(data, menu)
menu.close()
end)
end
function OpenPharmacyMenu()
ESX.UI.Menu.CloseAll()
local elements = {
{unselectable = true, icon = "fas fa-pills", title = TranslateCap('pharmacy_menu_title')}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'pharmacy', {
title = TranslateCap('pharmacy_menu_title'),
align = 'top-left',
elements = {
{label = TranslateCap('pharmacy_take', TranslateCap('medikit')), item = 'medikit', type = 'slider', value = 1, min = 1, max = 100},
{label = TranslateCap('pharmacy_take', TranslateCap('bandage')), item = 'bandage', type = 'slider', value = 1, min = 1, max = 100}
}}, function(data, menu)
if Config.Debug then
print("[^2INFO^7] Attempting to Give Item - ^5" .. tostring(data.current.item) .. "^7")
end
TriggerServerEvent('esx_ambulancejob:giveItem', data.current.item, data.current.value)
end, function(data, menu)
menu.close()
for k,v in pairs(Config.PharmacyItems) do
elements[#elements+1] = {
icon = "fas fa-pills",
title = v.title,
item = v.item
}
end
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-pills", title = element.title},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 100, inputPlaceholder = "Amount to buy.."},
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local amount = menu2.eles[2].inputValue
if Config.Debug then
print("[^2INFO^7] Attempting to Give Item - ^5" .. tostring(element.item) .. "^7")
end
TriggerServerEvent('esx_ambulancejob:giveItem', element.item, amount)
end, function(menu)
OpenPharmacyMenu()
end)
end)
end
@@ -100,7 +100,7 @@ end)
function OnPlayerDeath()
isDead = true
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
ClearTimecycleModifier()
SetTimecycleModifier("REDMIST_blend")
SetTimecycleModifierStrength(0.7)
@@ -115,7 +115,7 @@ end
RegisterNetEvent('esx_ambulancejob:useItem')
AddEventHandler('esx_ambulancejob:useItem', function(itemName)
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
if itemName == 'medikit' then
local lib, anim = 'anim@heists@narcotics@funding@gang_idle', 'gang_chatting_idle01' -- TODO better animations
@@ -2,16 +2,15 @@ local spawnedVehicles = {}
function OpenVehicleSpawnerMenu(type, hospital, part, partNum)
local playerCoords = GetEntityCoords(PlayerPedId())
local elements = {
{unselectable = true, icon = "fas fa-car", title = TranslateCap('garage_title')},
{icon = "fas fa-car", title = TranslateCap('garage_storeditem'), action = 'garage'},
{icon = "fas fa-car", title = TranslateCap('garage_storeitem'), action = 'store_garage'},
{icon = "fas fa-car", title = TranslateCap('garage_buyitem'), action = 'buy_vehicle'}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', {
title = TranslateCap('garage_title'),
align = 'top-left',
elements = {
{label = TranslateCap('garage_storeditem'), action = 'garage'},
{label = TranslateCap('garage_storeitem'), action = 'store_garage'},
{label = TranslateCap('garage_buyitem'), action = 'buy_vehicle'}
}}, function(data, menu)
if data.current.action == 'buy_vehicle' then
ESX.OpenContext("right", elements, function(menu,element)
if element.action == "buy_vehicle" then
local shopElements = {}
local authorizedVehicles = Config.AuthorizedVehicles[type][ESX.PlayerData.job.grade_name]
local shopCoords = Config.Hospitals[hospital][part][partNum].InsideShop
@@ -21,23 +20,30 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum)
if IsModelInCdimage(vehicle.model) then
local vehicleLabel = GetLabelText(GetDisplayNameFromVehicleModel(vehicle.model))
table.insert(shopElements, {
label = ('%s - <span style="color:green;">%s</span>'):format(vehicleLabel, TranslateCap('shop_item', ESX.Math.GroupDigits(vehicle.price))),
shopElements[#shopElements+1] = {
icon = 'fas fa-car',
title = ('%s - <span style="color:green;">%s</span>'):format(vehicleLabel, TranslateCap('shop_item', ESX.Math.GroupDigits(vehicle.price))),
name = vehicleLabel,
model = vehicle.model,
price = vehicle.price,
props = vehicle.props,
type = type
})
}
end
end
if #shopElements > 0 then
OpenShopMenu(shopElements, playerCoords, shopCoords)
else
ESX.ShowNotification(TranslateCap('garage_notauthorized'))
end
else
ESX.ShowNotification(TranslateCap('garage_notauthorized'))
end
elseif data.current.action == 'garage' then
local garage = {}
elseif element.action == "garage" then
local garage = {
{unselectable = true, icon = "fas fa-car", title = "Garage"}
}
ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles)
if #jobVehicles > 0 then
@@ -56,42 +62,37 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum)
label = label .. ('<span style="color:darkred;">%s</span>'):format(TranslateCap('garage_notstored'))
end
table.insert(garage, {
label = label,
garage[#garage+1] = {
icon = 'fas fa-car',
title = label,
stored = v.stored,
model = props.model,
plate = props.plate
})
}
allVehicleProps[props.plate] = props
end
end
if #garage > 0 then
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', {
title = TranslateCap('garage_title'),
align = 'top-left',
elements = garage
}, function(data2, menu2)
if data2.current.stored == 1 then
ESX.OpenContext("right", garage, function(menuG,elementG)
if elementG.stored == 1 then
local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(hospital, part, partNum)
if foundSpawn then
menu2.close()
ESX.CloseContext()
ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
local vehicleProps = allVehicleProps[data2.current.plate]
ESX.Game.SpawnVehicle(elementG.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
local vehicleProps = allVehicleProps[elementG.plate]
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
TriggerServerEvent('esx_vehicleshop:setJobVehicleState', data2.current.plate, false)
TriggerServerEvent('esx_vehicleshop:setJobVehicleState', elementG.plate, false)
ESX.ShowNotification(TranslateCap('garage_released'))
end)
end
else
ESX.ShowNotification(TranslateCap('garage_notavailable'))
end
end, function(data2, menu2)
menu2.close()
end)
else
ESX.ShowNotification(TranslateCap('garage_empty'))
@@ -100,11 +101,9 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum)
ESX.ShowNotification(TranslateCap('garage_empty'))
end
end, type)
elseif data.current.action == 'store_garage' then
elseif element.action == "store_garage" then
StoreNearbyVehicle(playerCoords)
end
end, function(data, menu)
menu.close()
end)
end
@@ -198,84 +197,71 @@ end
function OpenShopMenu(elements, restoreCoords, shopCoords)
local playerPed = PlayerPedId()
isInShopMenu = true
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-car", title = element.title},
{icon = "fas fa-eye", title = "View", value = "view"}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', {
title = TranslateCap('vehicleshop_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop_confirm', {
title = TranslateCap('vehicleshop_confirm', data.current.name, data.current.price),
align = 'top-left',
elements = {
{label = TranslateCap('confirm_no'), value = 'no'},
{label = TranslateCap('confirm_yes'), value = 'yes'}
}}, function(data2, menu2)
if data2.current.value == 'yes' then
local newPlate = exports['esx_vehicleshop']:GeneratePlate()
local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = newPlate
ESX.OpenContext("right", elements2, function(menu2,element2)
if element2.value == "view" then
DeleteSpawnedVehicles()
WaitForVehicleToLoad(element.model)
ESX.TriggerServerCallback('esx_ambulancejob:buyJobVehicle', function(bought)
if bought then
ESX.ShowNotification(TranslateCap('vehicleshop_bought', data.current.name, ESX.Math.GroupDigits(data.current.price)))
ESX.Game.SpawnLocalVehicle(element.model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(element.model)
if element.props then
ESX.Game.SetVehicleProperties(vehicle, element.props)
end
end)
local elements3 = {
{unselectable = true, icon = "fas fa-car", title = element.title},
{icon = "fas fa-check-double", title = "Buy", value = "buy"},
{icon = "fas fa-eye", title = "Stop Viewing", value = "stop"}
}
ESX.OpenContext("right", elements3, function(menu3,element3)
if element3.value == 'stop' then
isInShopMenu = false
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
else
ESX.ShowNotification(TranslateCap('vehicleshop_money'))
menu2.close()
elseif element3.value == "buy" then
local newPlate = exports['esx_vehicleshop']:GeneratePlate()
local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = newPlate
ESX.TriggerServerCallback('esx_ambulancejob:buyJobVehicle', function (bought)
if bought then
ESX.ShowNotification(TranslateCap('vehicleshop_bought', element.name, ESX.Math.GroupDigits(element.price)))
isInShopMenu = false
ESX.CloseContext()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
else
ESX.ShowNotification(TranslateCap('vehicleshop_money'))
ESX.CloseContext()
end
end, props, element.type)
end
end, props, data.current.type)
else
menu2.close()
end
end, function(data2, menu2)
menu2.close()
end)
end, function(data, menu)
isInShopMenu = false
ESX.UI.Menu.CloseAll()
DeleteSpawnedVehicles()
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
ESX.Game.Teleport(playerPed, restoreCoords)
end, function(data, menu)
DeleteSpawnedVehicles()
WaitForVehicleToLoad(data.current.model)
ESX.Game.SpawnLocalVehicle(data.current.model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(data.current.model)
if data.current.props then
ESX.Game.SetVehicleProperties(vehicle, data.current.props)
end)
end
end)
end)
WaitForVehicleToLoad(elements[1].model)
ESX.Game.SpawnLocalVehicle(elements[1].model, shopCoords, 0.0, function(vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
SetModelAsNoLongerNeeded(elements[1].model)
if elements[1].props then
ESX.Game.SetVehicleProperties(vehicle, elements[1].props)
end
end)
end
CreateThread(function()
+11
View File
@@ -35,6 +35,17 @@ Config.RespawnPoints = {
{coords = vector3(1836.03, 3670.99, 34.28), heading = 296.06} -- Sandy Shores
}
Config.PharmacyItems = {
{
title = "Medikit",
item = "medikit"
},
{
title = "Bandage",
item = "bandage"
},
}
Config.Hospitals = {
CentralLosSantos = {
+65 -43
View File
@@ -72,40 +72,54 @@ function OpenCustomersMenu()
ESX.OpenContext("right", elements2, function(menu2,element2)
local customer = element.data
if element2.value == "deposit" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'customer_deposit_amount', {
title = TranslateCap('amount')
}, function(data2, menu2)
local amount = tonumber(data2.value)
local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('amount')},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 250000, inputPlaceholder = "Amount to bill.."},
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
}
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu2.close()
TriggerServerEvent('esx_bankerjob:customerDeposit', customer.source, amount)
ESX.ShowNotification("You have deposited $"..amount.." into "..element.title.."s account.")
OpenCustomersMenu()
ESX.OpenContext("right", elements, function(menu,element)
if element.val == "confirm" then
local amount = tonumber(menu.eles[2].inputValue)
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
ESX.CloseContext()
TriggerServerEvent('esx_bankerjob:customerDeposit', customer.source, amount)
ESX.ShowNotification("You have deposited $"..amount.." into "..element.title.."s account.")
OpenCustomersMenu()
end
end
end, function(data2, menu2)
menu2.close()
OpenCustomersMenu()
end, function(menu)
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
end)
elseif element2.value == "withdraw" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'customer_withdraw_amount', {
title = TranslateCap('amount')
}, function(data2, menu2)
local amount = tonumber(data2.value)
local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('amount')},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 250000, inputPlaceholder = "Amount to bill.."},
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
}
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu2.close()
TriggerServerEvent('esx_bankerjob:customerWithdraw', customer.source, amount)
ESX.ShowNotification("You have withdrawn $"..amount.." from "..element.title.."s account.")
OpenCustomersMenu()
ESX.OpenContext("right", elements, function(menu,element)
if element.val == "confirm" then
local amount = tonumber(menu.eles[2].inputValue)
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
ESX.CloseContext()
TriggerServerEvent('esx_bankerjob:customerWithdraw', customer.source, amount)
ESX.ShowNotification("You have withdrawn $"..amount.." from "..element.title.."s account.")
OpenCustomersMenu()
end
end
end, function(data2, menu2)
menu2.close()
OpenCustomersMenu()
end, function(menu)
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
end)
end
end, function(menu)
@@ -122,26 +136,34 @@ function OpenCustomersMenu()
end
function CreateBillingDialog()
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'billing', {
title = TranslateCap('bill_amount')
}, function(data, menu)
local amount = tonumber(data.value)
local elements = {
{unselectable = true, icon = "fas fa-scroll", title = TranslateCap('bill_amount')},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 250000, inputPlaceholder = "Amount to bill.."},
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
}
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu.close()
ESX.OpenContext("right", elements, function(menu,element)
if element.val == "confirm" then
local amount = tonumber(menu.eles[2].inputValue)
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer == -1 or closestDistance > 5.0 then
ESX.ShowNotification(TranslateCap('no_player_nearby'))
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_banker', 'Bank', amount)
ESX.CloseContext()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer == -1 or closestDistance > 5.0 then
ESX.ShowNotification(TranslateCap('no_player_nearby'))
else
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_banker', 'Bank', amount)
end
end
end
end, function(data, menu)
menu.close()
end, function(menu)
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
end)
end
+1 -1
View File
@@ -27,7 +27,7 @@ function ShowBillsMenu()
end
RegisterCommand('showbills', function()
if not isDead and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'billing') then
if not isDead then
ShowBillsMenu()
end
end, false)
+105 -107
View File
@@ -5,97 +5,96 @@ function OpenBoatShop(shop)
isInShopMenu = true
local playerPed = PlayerPedId()
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-ship", title = TranslateCap('boat_shop')}
}
for k,v in ipairs(Config.Vehicles) do
table.insert(elements, {
label = ('%s - <span style="color:green;">$%s</span>'):format(v.label, ESX.Math.GroupDigits(v.price)),
elements[#elements+1] = {
icon = "fas fa-ship",
title = ('%s - <span style="color:green;">$%s</span>'):format(v.label, ESX.Math.GroupDigits(v.price)),
name = v.label,
model = v.model,
price = v.price,
props = v.props or nil
})
}
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boat_shop', {
title = TranslateCap('boat_shop'),
align = 'top-left',
elements = elements
}, function (data, menu)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boat_shop_confirm', {
title = TranslateCap('boat_shop_confirm', data.current.name, ESX.Math.GroupDigits(data.current.price)),
align = 'top-left',
elements = {
{label = TranslateCap('confirm_no'), value = 'no'},
{label = TranslateCap('confirm_yes'), value = 'yes'}
}}, function (data2, menu2)
if data2.current.value == 'yes' then
local plate = exports['esx_vehicleshop']:GeneratePlate()
local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = plate
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-ship", title = element.title},
{icon = "fas fa-eye", title = "View", val = "view"}
}
ESX.TriggerServerCallback('esx_boat:buyBoat', function(bought)
if bought then
ESX.ShowNotification(TranslateCap('boat_shop_bought', data.current.name, ESX.Math.GroupDigits(data.current.price)))
ESX.OpenContext("right", elements2, function(menu2,element2)
if element2.val == "view" then
DeleteSpawnedVehicles()
DeleteSpawnedVehicles()
isInShopMenu = false
ESX.UI.Menu.CloseAll()
ESX.Game.SpawnLocalVehicle(element.model, shop.Inside, shop.Inside.w, function (vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
SetEntityCoords(playerPed, shop.Outside.x, shop.Outside.y, shop.Outside.z)
else
ESX.ShowNotification(TranslateCap('boat_shop_nomoney'))
menu2.close()
if element.props then
ESX.Game.SetVehicleProperties(vehicle, element.props)
end
end, props)
else
menu2.close()
end
end, function (data2, menu2)
menu2.close()
end)
end, function (data, menu)
menu.close()
isInShopMenu = false
DeleteSpawnedVehicles()
local elements3 = {
{unselectable = true, icon = "fas fa-ship", title = element.title},
{icon = "fas fa-check-double", title = "Buy", value = "buy"},
{icon = "fas fa-eye", title = "Stop Viewing", value = "stop"}
}
ESX.OpenContext("right", elements3, function(menu3,element3)
if element3.value == "buy" then
local plate = exports['esx_vehicleshop']:GeneratePlate()
local vehicle = GetVehiclePedIsIn(playerPed, false)
local props = ESX.Game.GetVehicleProperties(vehicle)
props.plate = plate
ESX.TriggerServerCallback('esx_boat:buyBoat', function(bought)
if bought then
ESX.ShowNotification(TranslateCap('boat_shop_bought', element.name, ESX.Math.GroupDigits(element.price)))
DeleteSpawnedVehicles()
isInShopMenu = false
ESX.CloseContext()
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
SetEntityCoords(playerPed, shop.Outside.x, shop.Outside.y, shop.Outside.z)
else
ESX.ShowNotification(TranslateCap('boat_shop_nomoney'))
ESX.CloseContext()
end
end, props)
elseif element3.value == "stop" then
isInShopMenu = false
DeleteSpawnedVehicles()
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
SetEntityCoords(playerPed, shop.Outside.x, shop.Outside.y, shop.Outside.z)
ESX.CloseContext()
end
end)
end)
end
end, function(menu)
isInShopMenu = false
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
end)
end, function(menu)
isInShopMenu = false
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
FreezeEntityPosition(playerPed, false)
SetEntityVisible(playerPed, true)
SetEntityCoords(playerPed, shop.Outside.x, shop.Outside.y, shop.Outside.z)
end, function (data, menu)
DeleteSpawnedVehicles()
ESX.Game.SpawnLocalVehicle(data.current.model, shop.Inside, shop.Inside.w, function (vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
if data.current.props then
ESX.Game.SetVehicleProperties(vehicle, data.current.props)
end
end)
end)
-- spawn first vehicle
DeleteSpawnedVehicles()
ESX.Game.SpawnLocalVehicle(Config.Vehicles[1].model, shop.Inside, shop.Inside.w, function (vehicle)
table.insert(spawnedVehicles, vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
FreezeEntityPosition(vehicle, true)
if Config.Vehicles[1].props then
ESX.Game.SetVehicleProperties(vehicle, Config.Vehicles[1].props)
end
end)
end
@@ -105,24 +104,22 @@ function OpenBoatGarage(garage)
ESX.ShowNotification(TranslateCap('garage_noboats'))
else
-- get all available boats
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-ship", title = TranslateCap('garage')}
}
for i=1, #ownedBoats, 1 do
ownedBoats[i] = json.decode(ownedBoats[i])
table.insert(elements, {
label = getVehicleLabelFromHash(ownedBoats[i].model),
elements[#elements+1] = {
icon = "fas fa-ship",
title = getVehicleLabelFromHash(ownedBoats[i].model),
vehicleProps = ownedBoats[i]
})
}
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boat_garage', {
title = TranslateCap('garage'),
align = 'top-left',
elements = elements
}, function (data, menu)
-- make sure the spawn point isn't blocked
ESX.OpenContext("right", elements, function(menu,element)
local playerPed = PlayerPedId()
local vehicleProps = data.current.vehicleProps
local vehicleProps = element.vehicleProps
if ESX.Game.IsSpawnPointClear(garage.SpawnPoint, 4.0) then
TriggerServerEvent('esx_boat:takeOutVehicle', vehicleProps.plate)
@@ -133,13 +130,11 @@ function OpenBoatGarage(garage)
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
end)
menu.close()
ESX.CloseContext()
else
ESX.ShowNotification(TranslateCap('garage_blocked'))
end
end, function (data, menu)
menu.close()
end, function(menu)
CurrentAction = 'garage_out'
CurrentActionMsg = TranslateCap('garage_open')
end)
@@ -148,33 +143,36 @@ function OpenBoatGarage(garage)
end
function OpenLicenceMenu(shop)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'boat_license', {
title = TranslateCap('license_menu'),
align = 'top-left',
elements = {
{label = TranslateCap('license_buy_no'), value = 'no'},
{label = TranslateCap('license_buy_yes', ESX.Math.GroupDigits(Config.LicensePrice)), value = 'yes'}
}}, function (data, menu)
if data.current.value == 'yes' then
local elements = {
{unselectable = true, icon = "fas fa-ship", title = TranslateCap('license_menu')},
{icon = "fas fa-ship", title = "Purchase Boat License"}
}
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-ship", title = element.title},
{icon = "fas fa-check-double", title = TranslateCap('license_buy_yes'), val = "yes"},
{icon = "fas fa-window-close", title = TranslateCap('license_buy_no'), val = "no"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
ESX.TriggerServerCallback('esx_boat:buyBoatLicense', function (boughtLicense)
if boughtLicense then
ESX.ShowNotification(TranslateCap('license_bought', ESX.Math.GroupDigits(Config.LicensePrice)))
menu.close()
ESX.CloseContext()
OpenBoatShop(shop) -- parse current shop
else
ESX.ShowNotification(TranslateCap('license_nomoney'))
end
end)
else
CurrentAction = 'boat_shop'
end, function(menu)
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
menu.close()
end
end, function (data, menu)
CurrentAction = 'boat_shop'
end)
end, function(menu)
CurrentAction = 'boat_shop'
CurrentActionMsg = TranslateCap('boat_shop_open')
menu.close()
end)
end
+1 -1
View File
@@ -68,7 +68,7 @@ end)
AddEventHandler('esx_boat:hasExitedMarker', function()
if not isInShopMenu then
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
end
CurrentAction = nil
+7 -7
View File
@@ -33,18 +33,18 @@ function OpenShopMenu()
ESX.OpenContext("right", elements2, function(menu2,element2)
if element2.value == "yes" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'outfit_name', {
title = TranslateCap('name_outfit')
}, function(data3, menu3)
menu3.close()
local elements3 = {
{unselectable = true, icon = "fas fa-shirt", title = TranslateCap('name_outfit')},
{title = "Outfit Name", input = true, inputType = "text", inputPlaceholder = "Outfit name in wardrobe.."},
{icon = "fas fa-check-circle", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements3, function(menu3,element3)
TriggerEvent('skinchanger:getSkin', function(skin)
ESX.CloseContext()
TriggerServerEvent('esx_clotheshop:saveOutfit', data3.value, skin)
TriggerServerEvent('esx_clotheshop:saveOutfit', menu3.eles[2].inputValue, skin)
ESX.ShowNotification(TranslateCap('saved_outfit'))
end)
end, function(data3, menu3)
menu3.close()
end)
elseif element2.value == "no" then
ESX.CloseContext()
+35 -52
View File
@@ -21,7 +21,6 @@ CreateThread(function()
inZoneDrugShop = false
if menuOpen then
menuOpen=false
ESX.UI.Menu.CloseAll()
end
end
@@ -62,36 +61,39 @@ CreateThread(function ()
end)
function OpenDrugShop()
ESX.UI.Menu.CloseAll()
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-cannabis", title = TranslateCap('dealer_title')}
}
menuOpen = true
for k, v in pairs(ESX.GetPlayerData().inventory) do
local price = Config.DrugDealerItems[v.name]
if price and v.count > 0 then
table.insert(elements, {
label = ('%s - <span style="color:green;">%s</span>'):format(v.label, TranslateCap('dealer_item', ESX.Math.GroupDigits(price))),
elements[#elements+1] = {
icon = "fas fa-shopping-basket",
title = ('%s - <span style="color:green;">%s</span>'):format(v.label, TranslateCap('dealer_item', ESX.Math.GroupDigits(price))),
name = v.name,
price = price,
-- menu properties
type = 'slider',
value = 1,
min = 1,
max = v.count
})
}
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'drug_shop', {
title = TranslateCap('dealer_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
TriggerServerEvent('esx_drugs:sellDrug', data.current.name, data.current.value)
end, function(data, menu)
menu.close()
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-shopping-basket", title = element.title},
{icon = "fas fa-shopping-basket", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount you want to sell", inputMin = Config.SellMenu.Min, inputMax = Config.SellMenu.Max},
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local amount = menu2.eles[2].inputValue
ESX.CloseContext()
TriggerServerEvent('esx_drugs:sellDrug', element.name, amount)
end, function(menu)
menuOpen = false
end)
end, function(menu)
menuOpen = false
end)
end
@@ -99,7 +101,7 @@ end
AddEventHandler('onResourceStop', function(resource)
if resource == GetCurrentResourceName() then
if menuOpen then
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
end
end
end)
@@ -109,39 +111,20 @@ function OpenBuyLicenseMenu(licenseName)
local license = Config.LicensePrices[licenseName]
local elements = {
{
label = TranslateCap('license_no'),
value = 'no'
},
{
label = ('%s - <span style="color:green;">%s</span>'):format(license.label, TranslateCap('dealer_item', ESX.Math.GroupDigits(license.price))),
value = licenseName,
price = license.price,
licenseName = license.label
}
{unselectable = true, title = TranslateCap('purchase_license')},
{title = ('%s - <span style="color:green;">%s</span>'):format(license.label, TranslateCap('dealer_item', ESX.Math.GroupDigits(license.price))), value = licenseName, price = license.price, licenseName = license.label}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'license_shop', {
title = TranslateCap('license_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value ~= 'no' then
ESX.TriggerServerCallback('esx_drugs:buyLicense', function(boughtLicense)
if boughtLicense then
ESX.ShowNotification(TranslateCap('license_bought', data.current.licenseName, ESX.Math.GroupDigits(data.current.price)))
else
ESX.ShowNotification(TranslateCap('license_bought_fail', data.current.licenseName))
end
end, data.current.value)
else
menu.close()
end
end, function(data, menu)
menu.close()
ESX.OpenContext("right", elements, function(menu,element)
ESX.TriggerServerCallback('esx_drugs:buyLicense', function(boughtLicense)
if boughtLicense then
ESX.CloseContext()
ESX.ShowNotification(TranslateCap('license_bought', element.licenseName, ESX.Math.GroupDigits(element.price)))
else
ESX.ShowNotification(TranslateCap('license_bought_fail', element.licenseName))
end
end, element.value)
end, function(menu)
menuOpen = false
end)
end
+7
View File
@@ -31,3 +31,10 @@ Config.Marker = {
Size = vector3(1.5,1.5,1.0),
Type = 1,
}
-- min amount of Config.DrugDealerItems to sell
-- max amount of Config.DrugDealerItems to sell
Config.SellMenu = {
Min = 1,
Max = 50
}
+8 -15
View File
@@ -27,17 +27,14 @@ RegisterNetEvent('esx:setJob',function(job)
end)
function OpenMenu()
ESX.UI.Menu.CloseAll()
local elements = {
{unselectable = true, icon = "fas fa-shirt", title = TranslateCap('cloakroom')},
{icon = "fas fa-shirt", title = TranslateCap('job_wear'), value = "job_wear"},
{icon = "fas fa-shirt", title = TranslateCap('citizen_wear'), value = "citizen_wear"},
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'cloakroom',
{
title = TranslateCap('cloakroom'),
elements = {
{label = TranslateCap('job_wear'), value = 'job_wear'},
{label = TranslateCap('citizen_wear'), value = 'citizen_wear'}
}
}, function(data, menu)
if data.current.value == 'citizen_wear' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "citizen_wear" then
onDuty = false
ESX.ShowNotification(TranslateCap('offduty'),"success")
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
@@ -49,7 +46,7 @@ function OpenMenu()
end)
end)
end)
elseif data.current.value == 'job_wear' then
elseif element.value == "job_wear" then
onDuty = true
ESX.ShowNotification(TranslateCap('onduty'), "success")
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
@@ -68,10 +65,6 @@ function OpenMenu()
end
end)
end
menu.close()
end, function(data, menu)
menu.close()
end)
end
+136 -176
View File
@@ -54,44 +54,41 @@ end
function OpenMechanicActionsMenu()
local elements = {
{label = TranslateCap('vehicle_list'), value = 'vehicle_list'},
{label = TranslateCap('work_wear'), value = 'cloakroom'},
{label = TranslateCap('civ_wear'), value = 'cloakroom2'},
{label = TranslateCap('deposit_stock'), value = 'put_stock'},
{label = TranslateCap('withdraw_stock'), value = 'get_stock'}
{unselectable = true, icon = "fas fa-gear", title = TranslateCap('mechanic')},
{icon = "fas fa-car", title = TranslateCap('vehicle_list'), value = 'vehicle_list'},
{icon = "fas fa-shirt", title = TranslateCap('work_wear'), value = 'cloakroom'},
{icon = "fas fa-shirt", title = TranslateCap('civ_wear'), value = 'cloakroom2'},
{icon = "fas fa-box", title = TranslateCap('deposit_stock'), value = 'put_stock'},
{icon = "fas fa-box", title = TranslateCap('withdraw_stock'), value = 'get_stock'}
}
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade_name == 'boss' then
table.insert(elements, {label = TranslateCap('boss_actions'), value = 'boss_actions'})
elements[#elements+1] = {
icon = 'fas fa-boss',
title = TranslateCap('boss_actions'),
value = 'boss_actions'
}
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mechanic_actions', {
title = TranslateCap('mechanic'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value == 'vehicle_list' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == 'vehicle_list' then
if Config.EnableSocietyOwnedVehicles then
local elements = {}
local elements2 = {
{unselectable = true, icon = "fas fa-car", title = TranslateCap('service_vehicle')}
}
ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(vehicles)
for i=1, #vehicles, 1 do
table.insert(elements, {
label = GetDisplayNameFromVehicleModel(vehicles[i].model) .. ' [' .. vehicles[i].plate .. ']',
elements2[#elements2+1] = {
icon = 'fas fa-car',
title = GetDisplayNameFromVehicleModel(vehicles[i].model) .. ' [' .. vehicles[i].plate .. ']',
value = vehicles[i]
})
}
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner', {
title = TranslateCap('service_vehicle'),
align = 'top-left',
elements = elements
}, function(data, menu)
menu.close()
local vehicleProps = data.current.value
ESX.OpenContext("right", elements2, function(menu2,element2)
ESX.CloseContext()
local vehicleProps = element.value
ESX.Game.SpawnVehicle(vehicleProps.model, Config.Zones.VehicleSpawnPoint.Pos, 270.0, function(vehicle)
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
@@ -100,38 +97,35 @@ function OpenMechanicActionsMenu()
end)
TriggerServerEvent('esx_society:removeVehicleFromGarage', 'mechanic', vehicleProps)
end, function(data, menu)
menu.close()
end)
end, 'mechanic')
else
local elements = {
{label = TranslateCap('flat_bed'), value = 'flatbed'},
{label = TranslateCap('tow_truck'), value = 'towtruck2'}
local elements2 = {
{unselectable = true, icon = "fas fa-car", title = TranslateCap('service_vehicle')},
{icon = "fas fa-truck", title = TranslateCap('flat_bed'), value = 'flatbed'},
{icon = "fas fa-truck", title = TranslateCap('tow_truck'), value = 'towtruck2'}
}
if Config.EnablePlayerManagement and ESX.PlayerData.job and (ESX.PlayerData.job.grade_name == 'boss' or ESX.PlayerData.job.grade_name == 'chief' or ESX.PlayerData.job.grade_name == 'experimente') then
table.insert(elements, {label = 'SlamVan', value = 'slamvan3'})
elements2[#elements2+1] = {
icon = 'fas fa-truck',
title = 'Slamvan',
value = 'slamvan3'
}
end
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'spawn_vehicle', {
title = TranslateCap('service_vehicle'),
align = 'top-left',
elements = elements
}, function(data, menu)
ESX.OpenContext("right", elements2, function(menu2,element2)
if Config.MaxInService == -1 then
ESX.Game.SpawnVehicle(data.current.value, Config.Zones.VehicleSpawnPoint.Pos, 90.0, function(vehicle)
ESX.CloseContext()
ESX.Game.SpawnVehicle(element2.value, Config.Zones.VehicleSpawnPoint.Pos, 90.0, function(vehicle)
local playerPed = PlayerPedId()
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
end)
else
ESX.TriggerServerCallback('esx_service:enableService', function(canTakeService, maxInService, inServiceCount)
if canTakeService then
ESX.Game.SpawnVehicle(data.current.value, Config.Zones.VehicleSpawnPoint.Pos, 90.0, function(vehicle)
ESX.CloseContext()
ESX.Game.SpawnVehicle(element2.value, Config.Zones.VehicleSpawnPoint.Pos, 90.0, function(vehicle)
local playerPed = PlayerPedId()
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
end)
@@ -140,16 +134,10 @@ function OpenMechanicActionsMenu()
end
end, 'mechanic')
end
menu.close()
end, function(data, menu)
menu.close()
OpenMechanicActionsMenu()
end)
end
elseif data.current.value == 'cloakroom' then
menu.close()
elseif element.value == 'cloakroom' then
ESX.CloseContext()
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
if skin.sex == 0 then
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_male)
@@ -157,27 +145,24 @@ function OpenMechanicActionsMenu()
TriggerEvent('skinchanger:loadClothes', skin, jobSkin.skin_female)
end
end)
elseif data.current.value == 'cloakroom2' then
menu.close()
elseif element.value == 'cloakroom2' then
ESX.CloseContext()
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
elseif Config.OxInventory and (data.current.value == 'put_stock' or data.current.value == 'get_stock') then
elseif Config.OxInventory and (element.value == 'put_stock' or element.value == 'get_stock') then
exports.ox_inventory:openInventory('stash', 'society_mechanic')
return ESX.UI.Menu.CloseAll()
elseif data.current.value == 'put_stock' then
return ESX.CloseContext()
elseif element.value == 'put_stock' then
OpenPutStocksMenu()
elseif data.current.value == 'get_stock' then
elseif element.value == 'get_stock' then
OpenGetStocksMenu()
elseif data.current.value == 'boss_actions' then
elseif element.value == 'boss_actions' then
TriggerEvent('esx_society:openBossMenu', 'mechanic', function(data, menu)
menu.close()
end)
end
end, function(data, menu)
menu.close()
end, function(menu)
CurrentAction = 'mechanic_actions_menu'
CurrentActionMsg = TranslateCap('open_actions')
CurrentActionData = {}
@@ -187,29 +172,21 @@ end
function OpenMechanicHarvestMenu()
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade_name ~= 'recrue' then
local elements = {
{label = TranslateCap('gas_can'), value = 'gaz_bottle'},
{label = TranslateCap('repair_tools'), value = 'fix_tool'},
{label = TranslateCap('body_work_tools'), value = 'caro_tool'}
{unselectable = true, icon = "fas fa-gear", title = "Mechanic Harvest Menu"},
{icon = "fas fa-gear", title = TranslateCap('gas_can'), value = 'gaz_bottle'},
{icon = "fas fa-gear", title = TranslateCap('repair_tools'), value = 'fix_tool'},
{icon = "fas fa-gear", title = TranslateCap('body_work_tools'), value = 'caro_tool'}
}
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mechanic_harvest', {
title = TranslateCap('harvest'),
align = 'top-left',
elements = elements
}, function(data, menu)
menu.close()
if data.current.value == 'gaz_bottle' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == 'gaz_bottle' then
TriggerServerEvent('esx_mechanicjob:startHarvest')
elseif data.current.value == 'fix_tool' then
elseif element.value == 'fix_tool' then
TriggerServerEvent('esx_mechanicjob:startHarvest2')
elseif data.current.value == 'caro_tool' then
elseif element.value == 'caro_tool' then
TriggerServerEvent('esx_mechanicjob:startHarvest3')
end
end, function(data, menu)
menu.close()
end, function(menu)
CurrentAction = 'mechanic_harvest_menu'
CurrentActionMsg = TranslateCap('harvest_menu')
CurrentActionData = {}
@@ -222,30 +199,21 @@ end
function OpenMechanicCraftMenu()
if Config.EnablePlayerManagement and ESX.PlayerData.job and ESX.PlayerData.job.grade_name ~= 'recrue' then
local elements = {
{label = TranslateCap('blowtorch'), value = 'blow_pipe'},
{label = TranslateCap('repair_kit'), value = 'fix_kit'},
{label = TranslateCap('body_kit'), value = 'caro_kit'}
{unselectable = true, icon = "fas fa-gear", title = "Mechanic Craft Menu"},
{icon = "fas fa-gear", title = TranslateCap('blowtorch'), value = 'blow_pipe'},
{icon = "fas fa-gear", title = TranslateCap('repair_kit'), value = 'fix_kit'},
{icon = "fas fa-gear", title = TranslateCap('body_kit'), value = 'caro_kit'}
}
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mechanic_craft', {
title = TranslateCap('craft'),
align = 'top-left',
elements = elements
}, function(data, menu)
menu.close()
if data.current.value == 'blow_pipe' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == 'blow_pipe' then
TriggerServerEvent('esx_mechanicjob:startCraft')
elseif data.current.value == 'fix_kit' then
elseif element.value == 'fix_kit' then
TriggerServerEvent('esx_mechanicjob:startCraft2')
elseif data.current.value == 'caro_kit' then
elseif element.value == 'caro_kit' then
TriggerServerEvent('esx_mechanicjob:startCraft3')
end
end, function(data, menu)
menu.close()
end, function(menu)
CurrentAction = 'mechanic_craft_menu'
CurrentActionMsg = TranslateCap('craft_menu')
CurrentActionData = {}
@@ -256,27 +224,29 @@ function OpenMechanicCraftMenu()
end
function OpenMobileMechanicActionsMenu()
ESX.UI.Menu.CloseAll()
local elements = {
{unselectable = true, icon = "fas fa-gear", title = TranslateCap('mechanic')},
{icon = "fas fa-gear", title = TranslateCap('billing'), value = 'billing'},
{icon = "fas fa-gear", title = TranslateCap('hijack'), value = 'hijack_vehicle'},
{icon = "fas fa-gear", title = TranslateCap('repair'), value = 'fix_vehicle'},
{icon = "fas fa-gear", title = TranslateCap('clean'), value = 'clean_vehicle'},
{icon = "fas fa-gear", title = TranslateCap('imp_veh'), value = 'del_vehicle'},
{icon = "fas fa-gear", title = TranslateCap('flat_bed'), value = 'dep_vehicle'},
{icon = "fas fa-gear", title = TranslateCap('place_objects'), value = 'object_spawner'}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mobile_mechanic_actions', {
title = TranslateCap('mechanic'),
align = 'top-left',
elements = {
{label = TranslateCap('billing'), value = 'billing'},
{label = TranslateCap('hijack'), value = 'hijack_vehicle'},
{label = TranslateCap('repair'), value = 'fix_vehicle'},
{label = TranslateCap('clean'), value = 'clean_vehicle'},
{label = TranslateCap('imp_veh'), value = 'del_vehicle'},
{label = TranslateCap('flat_bed'), value = 'dep_vehicle'},
{label = TranslateCap('place_objects'), value = 'object_spawner'}
}}, function(data, menu)
ESX.OpenContext("right", elements, function(menu,element)
if isBusy then return end
if data.current.value == 'billing' then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'billing', {
title = TranslateCap('invoice_amount')
}, function(data, menu)
local amount = tonumber(data.value)
if element.value == "billing" then
local elements2 = {
{unselectable = true, icon = "fas fa-scroll", title = element.title},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 250000, inputPlaceholder = "Amount to bill.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local amount = tonumber(menu2.eles[2].inputValue)
if amount == nil or amount < 0 then
ESX.ShowNotification(TranslateCap('amount_invalid'), "error")
@@ -289,10 +259,8 @@ function OpenMobileMechanicActionsMenu()
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_mechanic', TranslateCap('mechanic'), amount)
end
end
end, function(data, menu)
menu.close()
end)
elseif data.current.value == 'hijack_vehicle' then
elseif element.value == "hijack_vehicle" then
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
local coords = GetEntityCoords(playerPed)
@@ -318,7 +286,7 @@ function OpenMobileMechanicActionsMenu()
else
ESX.ShowNotification(TranslateCap('no_vehicle_nearby'))
end
elseif data.current.value == 'fix_vehicle' then
elseif element.value == "fix_vehicle" then
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
local coords = GetEntityCoords(playerPed)
@@ -346,7 +314,7 @@ function OpenMobileMechanicActionsMenu()
else
ESX.ShowNotification(TranslateCap('no_vehicle_nearby'))
end
elseif data.current.value == 'clean_vehicle' then
elseif element.value == "clean_vehicle" then
local playerPed = PlayerPedId()
local vehicle = ESX.Game.GetVehicleInDirection()
local coords = GetEntityCoords(playerPed)
@@ -371,7 +339,7 @@ function OpenMobileMechanicActionsMenu()
else
ESX.ShowNotification(TranslateCap('no_vehicle_nearby'))
end
elseif data.current.value == 'del_vehicle' then
elseif element.value == "del_vehicle" then
local playerPed = PlayerPedId()
if IsPedSittingInAnyVehicle(playerPed) then
@@ -393,7 +361,7 @@ function OpenMobileMechanicActionsMenu()
ESX.ShowNotification(TranslateCap('must_near'))
end
end
elseif data.current.value == 'dep_vehicle' then
elseif element.value == "dep_vehicle" then
local playerPed = PlayerPedId()
local vehicle = GetVehiclePedIsIn(playerPed, true)
@@ -459,7 +427,7 @@ function OpenMobileMechanicActionsMenu()
else
ESX.ShowNotification(TranslateCap('imp_flatbed'))
end
elseif data.current.value == 'object_spawner' then
elseif element.value == "object_spawner" then
local playerPed = PlayerPedId()
if IsPedSittingInAnyVehicle(playerPed) then
@@ -467,14 +435,14 @@ function OpenMobileMechanicActionsMenu()
return
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'mobile_mechanic_actions_spawn', {
title = TranslateCap('objects'),
align = 'top-left',
elements = {
{label = TranslateCap('roadcone'), value = 'prop_roadcone02a'},
{label = TranslateCap('toolbox'), value = 'prop_toolchest_01'}
}}, function(data2, menu2)
local model = data2.current.value
local elements2 = {
{unselectable= true, icon = "fas fa-object", title = TranslateCap('objects')},
{icon = "fas fa-object", title = TranslateCap('roadcone'), value = 'prop_roadcone02a'},
{icon = "fas fa-object", title = TranslateCap('toolbox'), value = 'prop_toolchest_01'}
}
ESX.OpenContext("right", elements2, function(menuObj,elementObj)
local model = elementObj.value
local coords = GetEntityCoords(playerPed)
local forward = GetEntityForwardVector(playerPed)
local x, y, z = table.unpack(coords + forward * 1.0)
@@ -489,100 +457,92 @@ function OpenMobileMechanicActionsMenu()
SetEntityHeading(obj, GetEntityHeading(playerPed))
PlaceObjectOnGroundProperly(obj)
end)
end, function(data2, menu2)
menu2.close()
end)
end
end, function(data, menu)
menu.close()
end)
end
function OpenGetStocksMenu()
ESX.TriggerServerCallback('esx_mechanicjob:getStockItems', function(items)
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-box", title = TranslateCap('mechanic_stock')}
}
for i=1, #items, 1 do
table.insert(elements, {
label = 'x' .. items[i].count .. ' ' .. items[i].label,
elements[#elements+1] = {
icon = 'fas fa-box',
title = 'x' .. items[i].count .. ' ' .. items[i].label,
value = items[i].name
})
}
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', {
title = TranslateCap('mechanic_stock'),
align = 'top-left',
elements = elements
}, function(data, menu)
local itemName = data.current.value
ESX.OpenContext("right", elements, function(menu,element)
local itemName = element.value
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = TranslateCap('quantity')
}, function(data2, menu2)
local count = tonumber(data2.value)
local elements2 = {
{unselectable = true, icon = "fas fa-box", title = element.title},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 100, inputPlaceholder = "Amount to withdraw.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local count = tonumber(menu2.eles[2].inputValue)
if count == nil then
ESX.ShowNotification(TranslateCap('invalid_quantity'))
else
menu2.close()
menu.close()
ESX.CloseContext()
TriggerServerEvent('esx_mechanicjob:getStockItem', itemName, count)
Wait(1000)
OpenGetStocksMenu()
end
end, function(data2, menu2)
menu2.close()
end)
end, function(data, menu)
menu.close()
end)
end)
end
function OpenPutStocksMenu()
ESX.TriggerServerCallback('esx_mechanicjob:getPlayerInventory', function(inventory)
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-box", title = TranslateCap('inventory')}
}
for i=1, #inventory.items, 1 do
local item = inventory.items[i]
if item.count > 0 then
table.insert(elements, {
label = item.label .. ' x' .. item.count,
elements[#elements+1] = {
icon = 'fas fa-box',
title = item.label .. ' x' .. item.count,
type = 'item_standard',
value = item.name
})
}
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', {
title = TranslateCap('inventory'),
align = 'top-left',
elements = elements
}, function(data, menu)
local itemName = data.current.value
ESX.OpenContext("right", elements, function(menu,element)
local itemName = element.value
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count', {
title = TranslateCap('quantity')
}, function(data2, menu2)
local count = tonumber(data2.value)
local elements2 = {
{unselectable = true, icon = "fas fa-box", title = element.title},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 100, inputPlaceholder = "Amount to deposit.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local count = tonumber(menu2.eles[2].inputValue)
if count == nil then
ESX.ShowNotification(TranslateCap('invalid_quantity'))
else
menu2.close()
menu.close()
ESX.CloseContext()
TriggerServerEvent('esx_mechanicjob:putStockItems', itemName, count)
Wait(1000)
OpenPutStocksMenu()
end
end, function(data2, menu2)
menu2.close()
end)
end, function(data, menu)
menu.close()
end)
end)
end
@@ -738,7 +698,7 @@ AddEventHandler('esx_mechanicjob:hasExitedMarker', function(zone)
end
CurrentAction = nil
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
end)
AddEventHandler('esx_mechanicjob:hasEnteredEntityZone', function(entity)
+25 -35
View File
@@ -2,49 +2,39 @@ local hasAlreadyEnteredMarker, lastZone
local currentAction, currentActionMsg, currentActionData = nil, nil, {}
function OpenShopMenu(zone)
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-shopping-basket", title = TranslateCap('shop') }
}
for i=1, #Config.Zones[zone].Items, 1 do
local item = Config.Zones[zone].Items[i]
table.insert(elements, {
label = ('%s - <span style="color:green;">%s</span>'):format(item.label, TranslateCap('shop_item', ESX.Math.GroupDigits(item.price))),
elements[#elements+1] = {
icon = "fas fa-shopping-basket",
title = ('%s - <span style="color:green;">%s</span>'):format(item.label, TranslateCap('shop_item', ESX.Math.GroupDigits(item.price))),
itemLabel = item.label,
item = item.name,
price = item.price,
-- menu properties
value = 1,
type = 'slider',
min = 1,
max = 100
})
item = item.name,
price = item.price
}
end
ESX.UI.Menu.CloseAll()
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-shopping-basket", title = element.title},
{icon = "fas fa-shopping-basket", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount you want to buy", inputMin = 1, inputMax = 25},
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', {
title = TranslateCap('shop'),
align = 'bottom-left',
elements = elements
}, function(data, menu)
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
title = TranslateCap('shop_confirm', data.current.value, data.current.itemLabel, ESX.Math.GroupDigits(data.current.price * data.current.value)),
align = 'bottom-left',
elements = {
{label = TranslateCap('no'), value = 'no'},
{label = TranslateCap('yes'), value = 'yes'}
}}, function(data2, menu2)
if data2.current.value == 'yes' then
TriggerServerEvent('esx_shops:buyItem', data.current.item, data.current.value, zone)
end
menu2.close()
end, function(data2, menu2)
menu2.close()
ESX.OpenContext("right", elements2, function(menu2,element2)
local amount = menu2.eles[2].inputValue
ESX.CloseContext()
TriggerServerEvent('esx_shops:buyItem', element.item, amount, zone)
end, function(menu)
currentAction = 'shop_menu'
currentActionMsg = TranslateCap('press_menu')
currentActionData = {zone = zone}
end)
end, function(data, menu)
menu.close()
end, function(menu)
currentAction = 'shop_menu'
currentActionMsg = TranslateCap('press_menu')
currentActionData = {zone = zone}
+18 -18
View File
@@ -322,24 +322,24 @@ function OpenGetStocksMenu()
ESX.OpenContext("right", elements, function(menu,element)
local itemName = element.value
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', {
title = TranslateCap('quantity')
}, function(data2, menu2)
local count = tonumber(data2.value)
local elements2 = {
{unselectable = true, icon = "fas fa-box", title = element.title},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 100, inputPlaceholder = "Amount to withdraw.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local count = tonumber(menu2.eles[2].inputValue)
if count == nil then
ESX.ShowNotification(TranslateCap('quantity_invalid'))
else
menu2.close()
ESX.CloseContext()
-- todo: refresh on callback
TriggerServerEvent('esx_taxijob:getStockItem', itemName, count)
Wait(1000)
OpenGetStocksMenu()
end
end, function(data2, menu2)
menu2.close()
end)
end)
end, function(menu)
@@ -370,24 +370,24 @@ function OpenPutStocksMenu()
ESX.OpenContext("right", elements, function(menu,element)
local itemName = element.value
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count', {
title = TranslateCap('quantity')
}, function(data2, menu2)
local count = tonumber(data2.value)
local elements2 = {
{unselectable = true, icon = "fas fa-box", title = element.title},
{title = "Amount", input = true, inputType = "number", inputMin = 1, inputMax = 100, inputPlaceholder = "Amount to deposit.."},
{icon = "fas fa-check-double", title = "Confirm", value = "confirm"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local count = tonumber(menu2.eles[2].inputValue)
if count == nil then
ESX.ShowNotification(TranslateCap('quantity_invalid'))
else
menu2.close()
else
ESX.CloseContext()
-- todo: refresh on callback
TriggerServerEvent('esx_taxijob:putStockItems', itemName, count)
Wait(1000)
OpenPutStocksMenu()
end
end, function(data2, menu2)
menu2.close()
end)
end)
end, function(menu)
+3 -2
View File
@@ -99,12 +99,13 @@ end)
RegisterNetEvent('esx_taxijob:putStockItems')
AddEventHandler('esx_taxijob:putStockItems', function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)
local sourceItem = xPlayer.getInventoryItem(itemName)
if xPlayer.job.name == 'taxi' then
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_taxi', function(inventory)
local item = inventory.getItem(itemName)
if item.count > 0 then
if sourceItem.count >= count and count > 0 then
xPlayer.removeInventoryItem(itemName, count)
inventory.addItem(itemName, count)
xPlayer.showNotification(TranslateCap('have_deposited', count, item.label))