Skip to content

Commit

Permalink
fixed radial menu and garage type check
Browse files Browse the repository at this point in the history
  • Loading branch information
swkeep committed Nov 4, 2022
1 parent a0d0e07 commit 1d579bd
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 125 deletions.
42 changes: 33 additions & 9 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,39 @@ local function InitGarageZone()
currentgarage = k
if CanPlayerUseGarage() then
inGarageStation = true
radialmenu = exports['qb-radialmenu']:AddOption({
id = 'keep_put_back_to_garage',
title = 'Park (Job)',
icon = 'car',
type = 'client',
event = 'keep-sharedgarages:client:keep_put_back_to_garage',
shouldClose = true
})
exports['qb-core']:DrawText('Job Parking')
Wait(50)
local garage = GetCurrentgarageData()
if garage and garage.type == 'job' then
if radialmenu then
exports['qb-radialmenu']:RemoveOption(radialmenu)
radialmenu = nil
Wait(50)
end
radialmenu = exports['qb-radialmenu']:AddOption({
id = 'keep_put_back_to_garage',
title = 'Parking (Job)',
icon = 'car',
type = 'client',
event = 'keep-sharedgarages:client:keep_put_back_to_garage',
shouldClose = true
})
exports['qb-core']:DrawText('Job Parking')
elseif garage and garage.type == 'gang' then
if radialmenu then
exports['qb-radialmenu']:RemoveOption(radialmenu)
radialmenu = nil
Wait(50)
end
radialmenu = exports['qb-radialmenu']:AddOption({
id = 'keep_put_back_to_garage',
title = 'Parking (Gang)',
icon = 'car',
type = 'client',
event = 'keep-sharedgarages:client:keep_put_back_to_garage',
shouldClose = true
})
exports['qb-core']:DrawText('Gang Parking')
end
end
else
currentgarage = ''
Expand Down
202 changes: 92 additions & 110 deletions client/menu/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ local function cidWhiteListed(garage)
if not Config.Garages[garage] then return false end
if not Config.Garages[garage].garage_management then return false end
local citizenid = QBCore.Functions.GetPlayerData().citizenid

if Config.Garages[garage].garage_management[citizenid] then
if Config.Garages[garage].garage_management[citizenid] == true then
return true
Expand Down Expand Up @@ -161,71 +160,66 @@ function keep_menu:categories()
local detail = metadata[Config.Garages[GetCurrentgarage()].type]
local grades = metadata.extra[Config.Garages[GetCurrentgarage()].type]

if detail.isboss then
local Input = {
inputs = {
{
type = 'text',
isRequired = true,
name = 'category',
text = "name of new category",
icon = 'fa-solid fa-money-bill-trend-up',
title = 'Category Name',
},
{
type = 'text',
name = 'icon',
icon = 'fa-solid fa-money-bill-trend-up',
title = 'font icon',
text = 'fa-solid fa-car-side',
force_value = 'fa-solid fa-car-side'
},
{
type = 'text',
name = 'citizenids',
icon = 'fa-solid fa-money-bill-trend-up',
title = 'CitizenID Whitelist',
text = 'PZT37891,PZT37891,....'
},
}
local Input = {
inputs = {
{
type = 'text',
isRequired = true,
name = 'category',
text = "name of new category",
icon = 'fa-solid fa-money-bill-trend-up',
title = 'Category Name',
},
{
type = 'text',
name = 'icon',
icon = 'fa-solid fa-money-bill-trend-up',
title = 'font icon',
text = 'fa-solid fa-car-side',
force_value = 'fa-solid fa-car-side'
},
{
type = 'text',
name = 'citizenids',
icon = 'fa-solid fa-money-bill-trend-up',
title = 'CitizenID Whitelist',
text = 'PZT37891,PZT37891,....'
},
}
}

local index = #Input.inputs + 1
Input.inputs[index] = {
isRequired = true,
title = 'Allowed Grades',
name = "grades", -- name of the input should be unique
type = "checkbox",
options = {},
}

-- sort grades
local temp_grages = {}
for key, value in pairs(grades) do
temp_grages[tonumber(key + 1)] = value
end

local index = #Input.inputs + 1
Input.inputs[index] = {
isRequired = true,
title = 'Allowed Grades',
name = "grades", -- name of the input should be unique
type = "checkbox",
options = {},
for key, value in pairs(temp_grages) do
Input.inputs[index].options[#Input.inputs[index].options + 1] = {
value = key - 1,
text = value.name .. ' (' .. key .. ')'
}
end

-- sort grades
local temp_grages = {}
for key, value in pairs(grades) do
temp_grages[tonumber(key + 1)] = value
local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
if inputData.citizenids then
inputData.citizenids = split(inputData.citizenids, ",")
end

for key, value in pairs(temp_grages) do
Input.inputs[index].options[#Input.inputs[index].options + 1] = {
value = key - 1,
text = value.name .. ' (' .. key .. ')'
}
end

local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
if inputData.citizenids then
inputData.citizenids = split(inputData.citizenids, ",")
end
inputData.type_name = Config.Garages[GetCurrentgarage()].type
TriggerCallback('keep-sharedgarages:server:POST:create_category', function(result)
Wait(50)
keep_menu:categories()
end, inputData, GetCurrentgarage())
end
else
TriggerServerEvent('keep-sharedgarages:server:Notification', 'You are not boss!', 'error')
return
inputData.type_name = Config.Garages[GetCurrentgarage()].type
TriggerCallback('keep-sharedgarages:server:POST:create_category', function(result)
Wait(50)
keep_menu:categories()
end, inputData, GetCurrentgarage())
end
end)
end
Expand Down Expand Up @@ -299,30 +293,25 @@ function keep_menu:vehicles_inside_category(category)
action = function()
TriggerCallback('keep-sharedgarages:server:GET:player_job_gang', function(metadata)
local detail = metadata[Config.Garages[GetCurrentgarage()].type]
if detail.isboss then
local Input = {
inputs = {
{
type = 'text',
isRequired = true,
name = 'name',
text = "Type new name here",
icon = 'fa-solid fa-money-bill-trend-up',
title = 'Name',
},
}
local Input = {
inputs = {
{
type = 'text',
isRequired = true,
name = 'name',
text = "Type new name here",
icon = 'fa-solid fa-money-bill-trend-up',
title = 'Name',
},
}
}

local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
TriggerCallback('keep-sharedgarages:server:POST:edit_category', function(result)
Wait(50)
keep_menu:categories()
end, 'name', inputData.name, category.name, GetCurrentgarage())
end
else
TriggerServerEvent('keep-sharedgarages:server:Notification', 'You are not boss!', 'error')
return
local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
TriggerCallback('keep-sharedgarages:server:POST:edit_category', function(result)
Wait(50)
keep_menu:categories()
end, 'name', inputData.name, category.name, GetCurrentgarage())
end
end)
end
Expand All @@ -334,36 +323,29 @@ function keep_menu:vehicles_inside_category(category)
action = function()
TriggerCallback('keep-sharedgarages:server:GET:player_job_gang', function(metadata)
local detail = metadata[Config.Garages[GetCurrentgarage()].type]
if detail.isboss then
local Input = {
inputs = {
{
type = 'text',
isRequired = true,
name = 'conf',
text = "Type Confirm (^.^)",
icon = 'fa-solid fa-money-bill-trend-up',
title = 'Confirm',
},
}
local Input = {
inputs = {
{
type = 'text',
isRequired = true,
name = 'conf',
text = "Type Confirm (^.^)",
icon = 'fa-solid fa-money-bill-trend-up',
title = 'Confirm',
},
}
}

local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
if inputData.conf == 'Confirm' then
TriggerCallback('keep-sharedgarages:server:DELETE:category', function(result)
Wait(50)
keep_menu:categories()
end, category.name, GetCurrentgarage())
else
TriggerServerEvent('keep-sharedgarages:server:Notification',
"Ok, i won't delete it!",
'error')
end
local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
if inputData.conf == 'Confirm' then
TriggerCallback('keep-sharedgarages:server:DELETE:category', function(result)
Wait(50)
keep_menu:categories()
end, category.name, GetCurrentgarage())
else
TriggerServerEvent('keep-sharedgarages:server:Notification', "Ok, i won't delete it!", 'error')
end
else
TriggerServerEvent('keep-sharedgarages:server:Notification', 'You are not boss!', 'error')
return
end
end)
end
Expand Down
22 changes: 17 additions & 5 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Config.Garages = {
WhiteList = Config.VehicleWhiteList['defaultPolice'],
garage_management = {
-- access to garage management
['IFD87837'] = true
['GBC74362'] = true
}
},
['mrpd_out'] = {
Expand All @@ -98,7 +98,7 @@ Config.Garages = {
WhiteList = Config.VehicleWhiteList['defaultPolice'],
garage_management = {
-- access to garage management
['GBC74362'] = true
['GBC74362'] = false
}
},
['mrpd_back'] = {
Expand All @@ -118,7 +118,11 @@ Config.Garages = {
},
minz = 27,
maxz = 30.95,
WhiteList = Config.VehicleWhiteList['defaultPolice']
WhiteList = Config.VehicleWhiteList['defaultPolice'],
garage_management = {
-- access to garage management
['GBC74362'] = false
}
},
['mrpd_heli_pad'] = {
label = 'Police Heli Pad (mrpd)',
Expand All @@ -135,7 +139,11 @@ Config.Garages = {
},
minz = 42.5,
maxz = 50.95,
WhiteList = Config.VehicleWhiteList['heliPolice']
WhiteList = Config.VehicleWhiteList['heliPolice'],
garage_management = {
-- access to garage management
['GBC74362'] = true
}
},
['gas_station'] = {
label = 'Gas Station',
Expand All @@ -158,7 +166,11 @@ Config.Garages = {
},
minz = 28.0,
maxz = 30.0,
WhiteList = Config.VehicleWhiteList['gas_station']
WhiteList = Config.VehicleWhiteList['gas_station'],
garage_management = {
-- access to garage management
['GBC74362'] = true
}
},
['vagos_yard'] = {
label = 'Vagos',
Expand Down
Loading

0 comments on commit 1d579bd

Please sign in to comment.