Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: core exports #23

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# qb-adminmenu
# qbx_adminmenu
2 changes: 1 addition & 1 deletion client/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, 'qb_adminmenu_main_menu')
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_admin_menu'] = selected
MenuIndexes.qb_adminmenu_admin_menu = selected
end,
options = {
{label = Lang:t('admin_options.label1'), description = Lang:t('admin_options.desc1'), icon = 'fab fa-fly', close = false},
Expand Down
10 changes: 5 additions & 5 deletions client/dev.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ local ShowCoords = false
local VehicleDev = false
local VehicleTypes = {'Compacts', 'Sedans', 'SUVs', 'Coupes', 'Muscle', 'Sports Classics', 'Sports', 'Super', 'Motorcycles', 'Off-road', 'Industrial', 'Utility', 'Vans', 'Cycles', 'Boats', 'Helicopters', 'Planes', 'Service', 'Emergency', 'Military', 'Commercial', 'Trains', 'Open Wheel'}
local Options = {
function() CopyToClipboard('coords2') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes['qb_adminmenu_dev_menu']) end,
function() CopyToClipboard('coords3') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes['qb_adminmenu_dev_menu']) end,
function() CopyToClipboard('coords4') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes['qb_adminmenu_dev_menu']) end,
function() CopyToClipboard('heading') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes['qb_adminmenu_dev_menu']) end,
function() CopyToClipboard('coords2') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes.qb_adminmenu_dev_menu) end,
function() CopyToClipboard('coords3') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes.qb_adminmenu_dev_menu) end,
function() CopyToClipboard('coords4') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes.qb_adminmenu_dev_menu) end,
function() CopyToClipboard('heading') lib.showMenu('qb_adminmenu_dev_menu', MenuIndexes.qb_adminmenu_dev_menu) end,
function()
ShowCoords = not ShowCoords
while ShowCoords do
Expand Down Expand Up @@ -42,7 +42,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, 'qb_adminmenu_main_menu')
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_dev_menu'] = selected
MenuIndexes.qb_adminmenu_dev_menu = selected
end,
options = {
{label = Lang:t('dev_options.label1'), description = Lang:t('dev_options.desc1'), icon = 'fas fa-compass'},
Expand Down
4 changes: 2 additions & 2 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ lib.registerMenu({
CloseMenu(true)
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_main_menu'] = selected
MenuIndexes.qb_adminmenu_main_menu = selected
end,
options = {
{label = Lang:t('main_options.label1'), description = Lang:t('main_options.desc1'), icon = 'fas fa-hammer', args = {'qb_adminmenu_admin_menu'}},
Expand Down Expand Up @@ -52,7 +52,7 @@ function CloseMenu(isFullMenuClose, keyPressed, previousMenu)
end

RegisterNetEvent('qb-admin:client:openmenu', function()
lib.showMenu('qb_adminmenu_main_menu', MenuIndexes['qb_adminmenu_main_menu'])
lib.showMenu('qb_adminmenu_main_menu', MenuIndexes.qb_adminmenu_main_menu)
end)

RegisterNetEvent('qb-admin:client:setmodel', function(skin)
Expand Down
52 changes: 26 additions & 26 deletions client/player.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
local selectedPlayer
local playerOptions = {
function()
lib.showMenu('qb_adminmenu_player_general_menu', MenuIndexes['qb_adminmenu_player_general_menu'])
lib.showMenu('qb_adminmenu_player_general_menu', MenuIndexes.qb_adminmenu_player_general_menu)
end,
function()
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes['qb_adminmenu_player_administration_menu'])
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes.qb_adminmenu_player_administration_menu)
end,
function()
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes['qb_adminmenu_player_extra_menu'])
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes.qb_adminmenu_player_extra_menu)
end,
function()
local Input = lib.inputDialog('Name Change', {'Firstname', 'Lastname'})
Expand Down Expand Up @@ -131,7 +131,7 @@ local playerOptions = {
function GeneratePlayersMenu()
local players = lib.callback.await('qb-admin:server:getplayers', false)
if not players then
lib.showMenu('qb_adminmenu_main_menu', MenuIndexes['qb_adminmenu_main_menu'])
lib.showMenu('qb_adminmenu_main_menu', MenuIndexes.qb_adminmenu_main_menu)
return
end
local optionsList = {}
Expand All @@ -146,13 +146,13 @@ function GeneratePlayersMenu()
CloseMenu(false, keyPressed, 'qb_adminmenu_main_menu')
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_players_menu'] = selected
MenuIndexes.qb_adminmenu_players_menu = selected
end,
options = optionsList
}, function(_, _, args)
local player = lib.callback.await('qb-admin:server:getplayer', false, args[1].id)
if not player then
lib.showMenu('qb_adminmenu_main_menu', MenuIndexes['qb_adminmenu_main_menu'])
lib.showMenu('qb_adminmenu_main_menu', MenuIndexes.qb_adminmenu_main_menu)
return
end
lib.registerMenu({
Expand Down Expand Up @@ -192,7 +192,7 @@ function GeneratePlayersMenu()
selectedPlayer = player
lib.showMenu(('qb_adminmenu_player_menu_%s'):format(args[1].id), MenuIndexes[('qb_adminmenu_player_menu_%s'):format(args[1].id)])
end)
lib.showMenu('qb_adminmenu_players_menu', MenuIndexes['qb_adminmenu_players_menu'])
lib.showMenu('qb_adminmenu_players_menu', MenuIndexes.qb_adminmenu_players_menu)
end

lib.registerMenu({
Expand All @@ -203,7 +203,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, ('qb_adminmenu_player_menu_%s'):format(selectedPlayer?.id))
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_player_general_menu'] = selected
MenuIndexes.qb_adminmenu_player_general_menu = selected
end,
options = {
{label = Lang:t('player_options.general.labelkill'), description = Lang:t('player_options.general.desckill'), icon = 'fas fa-skull', close = false},
Expand Down Expand Up @@ -235,7 +235,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, ('qb_adminmenu_player_menu_%s'):format(selectedPlayer?.id))
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_player_administration_menu'] = selected
MenuIndexes.qb_adminmenu_player_administration_menu = selected
end,
options = {
{label = Lang:t('player_options.administration.labelkick'), description = Lang:t('player_options.administration.desckick'), icon = 'fas fa-plane-departure'},
Expand All @@ -246,22 +246,22 @@ lib.registerMenu({
}, function(selected, scrollIndex, args)
if selected == 1 then
local Input = lib.inputDialog(selectedPlayer.name, {Lang:t('player_options.administration.inputkick')})
if not Input then lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes['qb_adminmenu_player_administration_menu']) return end if not Input[1] then return end
if not Input then lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes.qb_adminmenu_player_administration_menu) return end if not Input[1] then return end
TriggerServerEvent('qb-admin:server:playeradministration', selected, selectedPlayer, Input[1])
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes['qb_adminmenu_player_administration_menu'])
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes.qb_adminmenu_player_administration_menu)
elseif selected == 2 then
local Input = lib.inputDialog(selectedPlayer.name, {
{ type = 'input', label = Lang:t('player_options.administration.inputkick'), placeholder = 'VDM'},
{ type = 'number', label = Lang:t('player_options.administration.input1ban')},
{ type = 'number', label = Lang:t('player_options.administration.input2ban')},
{ type = 'number', label = Lang:t('player_options.administration.input3ban')}
})
if not Input then lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes['qb_adminmenu_player_general_menu']) return end if not Input[1] or not Input[2] and not Input[3] and not Input[4] then return end
if not Input then lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes.qb_adminmenu_player_general_menu) return end if not Input[1] or not Input[2] and not Input[3] and not Input[4] then return end
TriggerServerEvent('qb-admin:server:playeradministration', selected, selectedPlayer, Input)
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes['qb_adminmenu_player_administration_menu'])
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes.qb_adminmenu_player_administration_menu)
else
TriggerServerEvent('qb-admin:server:playeradministration', selected, selectedPlayer, args[scrollIndex])
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes['qb_adminmenu_player_administration_menu'])
lib.showMenu('qb_adminmenu_player_administration_menu', MenuIndexes.qb_adminmenu_player_administration_menu)
end
end)

Expand All @@ -273,7 +273,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, ('qb_adminmenu_player_menu_%s'):format(selectedPlayer?.id))
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_player_extra_menu'] = selected
MenuIndexes.qb_adminmenu_player_extra_menu = selected
end,
options = {
{label = 'Open Inventory'},
Expand All @@ -288,29 +288,29 @@ lib.registerMenu({
elseif selected == 2 then
local succeeded = lib.callback.await('qb-admin:server:clothingMenu', false, selectedPlayer.id)
if succeeded then return end
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes['qb_adminmenu_player_extra_menu'])
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes.qb_adminmenu_player_extra_menu)
elseif selected == 3 then
local dialog = lib.inputDialog('Give Item', {
{type = 'input', label = 'Item', placeholder = 'phone'},
{type = 'number', label = 'Amount', default = 1}
})
if not dialog or not dialog[1] or dialog[1] == '' or not dialog[2] or dialog[2] < 1 then
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes['qb_adminmenu_player_extra_menu'])
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes.qb_adminmenu_player_extra_menu)
return
end
ExecuteCommand('giveitem ' .. selectedPlayer.id .. ' ' .. dialog[1] .. ' ' .. dialog[2])
elseif selected == 4 then
local sounds = lib.callback.await('qb-admin:server:getSounds', false)
if not sounds then
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes['qb_adminmenu_player_extra_menu'])
lib.showMenu('qb_adminmenu_player_extra_menu', MenuIndexes.qb_adminmenu_player_extra_menu)
return
end

for i = 1, #sounds do
lib.setMenuOptions('qb_adminmenu_play_sounds_menu', {label = sounds[i], description = 'Press enter to play this sound', args = {sounds[i]}, close = false}, i + 2)
end

lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
elseif selected == 5 then
exports['pma-voice']:toggleMutePlayer(selectedPlayer.id)
end
Expand All @@ -327,7 +327,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, 'qb_adminmenu_player_extra_menu')
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_play_sounds_menu'] = selected
MenuIndexes.qb_adminmenu_play_sounds_menu = selected
end,
onSideScroll = function(_, scrollIndex, args)
if args == 'volume' then
Expand All @@ -351,7 +351,7 @@ lib.registerMenu({
local dialog = lib.inputDialog('Set Volume Manually', {'Volume (0.00 - 1.00'})
if not dialog or not dialog[1] or dialog[1] == '' or not tonumber(dialog[1]) then
Wait(200)
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
return
end

Expand All @@ -360,22 +360,22 @@ lib.registerMenu({
if result < 0 or result > 1 then
lib.notify({ description = 'The number has to be between 0.00 and 1.00', type = 'error' })
Wait(200)
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
return
end

volume[2] = result --[[@as number]]
lib.setMenuOptions('qb_adminmenu_play_sounds_menu', {label = 'Volume', args = {'volume'}, values = {'0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1.0', 'Input'}, defaultIndex = scrollIndex, close = false}, 1)
Wait(200)
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
return
elseif args[1] == 'radius' then
if scrollIndex ~= 11 then return end
lib.hideMenu(false)
local dialog = lib.inputDialog('Set Radius Manually', {'Radius (1 - 100'})
if not dialog or not dialog[1] or dialog[1] == '' or not tonumber(dialog[1]) then
Wait(200)
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
return
end

Expand All @@ -384,14 +384,14 @@ lib.registerMenu({
if result < 1 or result > 100 then
lib.notify({ description = 'The number has to be between 1 and 100', type = 'error' })
Wait(200)
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
return
end

radius[2] = result --[[@as number]]
lib.setMenuOptions('qb_adminmenu_play_sounds_menu', {label = 'Radius', args = {'radius'}, values = {'10', '20', '30', '40', '50', '60', '70', '80', '90', '100', 'Input'}, defaultIndex = scrollIndex, close = false}, 2)
Wait(200)
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes['qb_adminmenu_play_sounds_menu'])
lib.showMenu('qb_adminmenu_play_sounds_menu', MenuIndexes.qb_adminmenu_play_sounds_menu)
return
end

Expand Down
2 changes: 1 addition & 1 deletion client/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lib.registerMenu({
CloseMenu(false, keyPressed, 'qb_adminmenu_main_menu')
end,
onSelected = function(selected)
MenuIndexes['qb_adminmenu_server_menu'] = selected
MenuIndexes.qb_adminmenu_server_menu = selected
end,
options = {
{label = Lang:t('server_options.label1'), description = Lang:t('server_options.desc1'), icon = 'fas fa-cloud', values = {Lang:t('server_options.value1_1'), Lang:t('server_options.value1_2'), Lang:t('server_options.value1_3'), Lang:t('server_options.value1_4'), Lang:t('server_options.value1_5'), Lang:t('server_options.value1_6'),
Expand Down
8 changes: 4 additions & 4 deletions client/vectors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function CopyToClipboard(dataType)
local string = string.format('vec2(%s, %s)', x, y)
lib.setClipboard(string)

QBX.Functions.Notify(Lang:t("success.coords_copied"), "success")
exports.qbx_core:Notify(Lang:t("success.coords_copied"), "success")
elseif dataType == 'coords3' then
local coords = GetEntityCoords(ped)
local x = math.round(coords.x, 2)
Expand All @@ -18,7 +18,7 @@ function CopyToClipboard(dataType)
local string = string.format('vec3(%s, %s, %s)', x, y, z)
lib.setClipboard(string)

QBX.Functions.Notify(Lang:t("success.coords_copied"), "success")
exports.qbx_core:Notify(Lang:t("success.coords_copied"), "success")
elseif dataType == 'coords4' then
local coords = GetEntityCoords(ped)
local x = math.round(coords.x, 2)
Expand All @@ -30,15 +30,15 @@ function CopyToClipboard(dataType)
local string = string.format('vec4(%s, %s, %s, %s)', x, y, z, h)
lib.setClipboard(string)

QBX.Functions.Notify(Lang:t("success.coords_copied"), "success")
exports.qbx_core:Notify(Lang:t("success.coords_copied"), "success")
elseif dataType == 'heading' then
local heading = GetEntityHeading(ped)
local h = math.round(heading, 2)

local string = h
lib.setClipboard(tostring(string))

QBX.Functions.Notify(Lang:t("success.heading_copied"), "success")
exports.qbx_core:Notify(Lang:t("success.heading_copied"), "success")
end
end

Expand Down
Loading