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

tweak: adjust to new core changes #22

Merged
merged 1 commit into from
Sep 26, 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
1 change: 0 additions & 1 deletion client/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
QBCore = exports['qbx-core']:GetCoreObject()
MenuIndexes = {}

lib.registerMenu({
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)

QBCore.Functions.Notify(Lang:t("success.coords_copied"), "success")
QBX.Functions.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)

QBCore.Functions.Notify(Lang:t("success.coords_copied"), "success")
QBX.Functions.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)

QBCore.Functions.Notify(Lang:t("success.coords_copied"), "success")
QBX.Functions.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))

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

Expand Down
8 changes: 4 additions & 4 deletions client/vehicle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function GenerateVehiclesSpawnMenu()
local indexedCategories = {}
local categories = {}
local vehs = {}
for _, v in pairs(QBCore.Shared.Vehicles) do
for _, v in pairs(QBX.Shared.Vehicles) do
categories[v.category] = true
end

Expand Down Expand Up @@ -49,7 +49,7 @@ function GenerateVehiclesSpawnMenu()
veh = NetToVeh(vehNetId)
Wait(100)
until DoesEntityExist(veh)
TriggerEvent('qb-vehiclekeys:client:AddKeys', QBCore.Functions.GetPlate(veh))
TriggerEvent('qb-vehiclekeys:client:AddKeys', QBX.Functions.GetPlate(veh))
SetVehicleNeedsToBeHotwired(veh, false)
SetVehicleHasBeenOwnedByPlayer(veh, true)
SetEntityAsMissionEntity(veh, true, false)
Expand All @@ -64,7 +64,7 @@ function GenerateVehiclesSpawnMenu()
indexedCategories[categories[i]] = 1
end

for k in pairs(QBCore.Shared.Vehicles) do
for k in pairs(QBX.Shared.Vehicles) do
vehs[#vehs + 1] = k
end

Expand All @@ -73,7 +73,7 @@ function GenerateVehiclesSpawnMenu()
end)

for i = 1, #vehs do
local v = QBCore.Shared.Vehicles[vehs[i]]
local v = QBX.Shared.Vehicles[vehs[i]]
vehicles[v.category][vehs[i]] = v
lib.setMenuOptions(('qb_adminmenu_spawn_vehicles_menu_%s'):format(v.category), {label = v.name, args = {v.model}}, indexedCategories[v.category])
indexedCategories[v.category] += 1
Expand Down
7 changes: 4 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ version '1.0.0'
description 'https://github.com/Qbox-project'

shared_scripts {
'@qb-core/shared/locale.lua',
'@qbx_core/shared/locale.lua',
'locales/en.lua',
'locales/*.lua',
'@ox_lib/init.lua',
'config.lua',
'@qbx-core/import.lua'
'@qbx_core/import.lua'
}

modules {
'qbx-core:utils',
'qbx_core:core',
'qbx_core:utils',
}

server_scripts {
Expand Down
2 changes: 1 addition & 1 deletion server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ lib.addCommand('setmodel', {
}, function(source, args)
local Target = args.id or source

if not QBCore.Functions.GetPlayer(Target) then return end
if not QBX.Functions.GetPlayer(Target) then return end

TriggerClientEvent('qb-admin:client:setmodel', Target, args.model)
end)
Expand Down
59 changes: 29 additions & 30 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
QBCore = exports['qbx-core']:GetCoreObject()
local isFrozen = {}
local sounds = {}

function NoPerms(source)
QBCore.Functions.Notify(source, Lang:t('error.no_perms'), 'error')
QBX.Functions.Notify(source, Lang:t('error.no_perms'), 'error')
end

--- Checks if the source is inside of the target's routingbucket
Expand Down Expand Up @@ -51,29 +50,29 @@ local GeneralOptions = {
end,
}
RegisterNetEvent('qb-admin:server:playeroptionsgeneral', function(Selected, SelectedPlayer, Input)
if not QBCore.Functions.HasPermission(source, Config.Events['playeroptionsgeneral']) then NoPerms(source) return end
if not QBX.Functions.HasPermission(source, Config.Events['playeroptionsgeneral']) then NoPerms(source) return end

---@diagnostic disable-next-line: redundant-parameter
GeneralOptions[Selected](SelectedPlayer, source, Input)
end)

local AdministrationOptions = {
function(Source, SelectedPlayer, Input)
if not QBCore.Functions.HasPermission(Source, Config.Events['kick']) then NoPerms(Source) return end
if not QBX.Functions.HasPermission(Source, Config.Events['kick']) then NoPerms(Source) return end
DropPlayer(SelectedPlayer.id, Input)
end,
function(Source, SelectedPlayer, Input)
if not QBCore.Functions.HasPermission(Source, Config.Events['ban']) then NoPerms(Source) return end
if not QBX.Functions.HasPermission(Source, Config.Events['ban']) then NoPerms(Source) return end
local BanDuration = (Input[2] or 0) * 3600 + (Input[3] or 0) * 86400 + (Input[4] or 0) * 2629743
DropPlayer(SelectedPlayer.id, Lang:t('player_options.administration.banreason', { reason = Input[1], lenght = os.date('%c', os.time() + BanDuration) }))
MySQL.Async.insert('INSERT INTO bans (name, license, discord, ip, reason, expire, bannedby) VALUES (?, ?, ?, ?, ?, ?, ?)', {
GetPlayerName(SelectedPlayer.id), QBCore.Functions.GetIdentifier(SelectedPlayer.id, 'license'), QBCore.Functions.GetIdentifier(SelectedPlayer.id, 'discord'),
QBCore.Functions.GetIdentifier(SelectedPlayer.id, 'ip'), Input[1], os.time() + BanDuration, GetPlayerName(Source)
GetPlayerName(SelectedPlayer.id), QBX.Functions.GetIdentifier(SelectedPlayer.id, 'license'), QBX.Functions.GetIdentifier(SelectedPlayer.id, 'discord'),
QBX.Functions.GetIdentifier(SelectedPlayer.id, 'ip'), Input[1], os.time() + BanDuration, GetPlayerName(Source)
})
end,
function(Source, SelectedPlayer, Input)
if not QBCore.Functions.HasPermission(Source, Config.Events['changeperms']) then NoPerms(Source) return end
if Input == 'remove' then QBCore.Functions.RemovePermission(SelectedPlayer.id) else QBCore.Functions.AddPermission(SelectedPlayer.id, Input) end
if not QBX.Functions.HasPermission(Source, Config.Events['changeperms']) then NoPerms(Source) return end
if Input == 'remove' then QBX.Functions.RemovePermission(SelectedPlayer.id) else QBX.Functions.AddPermission(SelectedPlayer.id, Input) end
end,
}
RegisterNetEvent('qb-admin:server:playeradministration', function(Selected, SelectedPlayer, Input)
Expand Down Expand Up @@ -115,22 +114,22 @@ local PlayerDataOptions = {
end,
}
RegisterNetEvent('qb-admin:server:changeplayerdata', function(Selected, SelectedPlayer, Input)
local Target = QBCore.Functions.GetPlayer(SelectedPlayer.id)
local Target = QBX.Functions.GetPlayer(SelectedPlayer.id)

if not QBCore.Functions.HasPermission(source, Config.Events['changeplayerdata']) then NoPerms(source) return end
if not QBX.Functions.HasPermission(source, Config.Events['changeplayerdata']) then NoPerms(source) return end
if not Target then return end

PlayerDataOptions[Selected](Target, Input)
end)

RegisterNetEvent('qb-admin:server:giveallweapons', function(Weapontype, PlayerID)
local src = PlayerID or source
local Target = QBCore.Functions.GetPlayer(src)
local Target = QBX.Functions.GetPlayer(src)

if not QBCore.Functions.HasPermission(source, Config.Events['giveallweapons']) then NoPerms(source) return end
if not QBX.Functions.HasPermission(source, Config.Events['giveallweapons']) then NoPerms(source) return end

for i = 1, #Config.Weaponlist[Weapontype], 1 do
if not QBCore.Shared.Items[Config.Weaponlist[Weapontype][i]] then return end
if not QBX.Shared.Items[Config.Weaponlist[Weapontype][i]] then return end
Target.Functions.AddItem(Config.Weaponlist[Weapontype][i], 1)
end
end)
Expand All @@ -139,10 +138,10 @@ lib.callback.register('qb-admin:callback:getradiolist', function(source, Frequen
local list = exports['pma-voice']:getPlayersInRadioChannel(tonumber(Frequency))
local Players = {}

if not QBCore.Functions.HasPermission(source, Config.Events['getradiolist']) then NoPerms(source) return end
if not QBX.Functions.HasPermission(source, Config.Events['getradiolist']) then NoPerms(source) return end

for targetSource, _ in pairs(list) do -- cheers Knight who shall not be named
local Player = QBCore.Functions.GetPlayer(targetSource)
local Player = QBX.Functions.GetPlayer(targetSource)
Players[#Players + 1] = {
id = targetSource,
name = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname .. ' | (' .. GetPlayerName(targetSource) .. ')'
Expand All @@ -152,10 +151,10 @@ lib.callback.register('qb-admin:callback:getradiolist', function(source, Frequen
end)

lib.callback.register('qb-admin:server:getplayers', function(source)
if not QBCore.Functions.HasPermission(source, Config.Events['usemenu']) then NoPerms(source) return end
if not QBX.Functions.HasPermission(source, Config.Events['usemenu']) then NoPerms(source) return end

local Players = {}
for k, v in pairs(QBCore.Functions.GetQBPlayers()) do
for k, v in pairs(QBX.Functions.GetQBPlayers()) do
Players[#Players + 1] = {
id = k,
cid = v.PlayerData.citizenid,
Expand All @@ -171,19 +170,19 @@ lib.callback.register('qb-admin:server:getplayers', function(source)
bank = v.PlayerData.money['bank'],
job = v.PlayerData.job.label .. ' | ' .. v.PlayerData.job.grade.level,
gang = v.PlayerData.gang.label,
license = QBCore.Functions.GetIdentifier(k, 'license') or 'Unknown',
discord = QBCore.Functions.GetIdentifier(k, 'discord') or 'Not Linked',
steam = QBCore.Functions.GetIdentifier(k, 'steam') or 'Not Linked',
license = QBX.Functions.GetIdentifier(k, 'license') or 'Unknown',
discord = QBX.Functions.GetIdentifier(k, 'discord') or 'Not Linked',
steam = QBX.Functions.GetIdentifier(k, 'steam') or 'Not Linked',
}
end
table.sort(Players, function(a, b) return a.id < b.id end)
return Players
end)

lib.callback.register('qb-admin:server:getplayer', function(source, playerToGet)
if not QBCore.Functions.HasPermission(source, Config.Events['usemenu']) then NoPerms(source) return end
if not QBX.Functions.HasPermission(source, Config.Events['usemenu']) then NoPerms(source) return end

local playerData = QBCore.Functions.GetPlayer(playerToGet)
local playerData = QBX.Functions.GetPlayer(playerToGet)
local player = {
id = playerToGet,
cid = playerData.PlayerData.citizenid,
Expand All @@ -199,15 +198,15 @@ lib.callback.register('qb-admin:server:getplayer', function(source, playerToGet)
bank = playerData.PlayerData.money['bank'],
job = playerData.PlayerData.job.label .. ' | ' .. playerData.PlayerData.job.grade.level,
gang = playerData.PlayerData.gang.label,
license = QBCore.Functions.GetIdentifier(playerToGet, 'license') or 'Unknown',
discord = QBCore.Functions.GetIdentifier(playerToGet, 'discord') or 'Not Linked',
steam = QBCore.Functions.GetIdentifier(playerToGet, 'steam') or 'Not Linked',
license = QBX.Functions.GetIdentifier(playerToGet, 'license') or 'Unknown',
discord = QBX.Functions.GetIdentifier(playerToGet, 'discord') or 'Not Linked',
steam = QBX.Functions.GetIdentifier(playerToGet, 'steam') or 'Not Linked',
}
return player
end)

lib.callback.register('qb-admin:server:clothingMenu', function(source, target)
if not QBCore.Functions.HasPermission(source, Config.Events['clothing menu']) then
if not QBX.Functions.HasPermission(source, Config.Events['clothing menu']) then
NoPerms(source)
return false
end
Expand All @@ -218,15 +217,15 @@ lib.callback.register('qb-admin:server:clothingMenu', function(source, target)
end)

lib.callback.register('qb-admin:server:getSounds', function(source)
if not QBCore.Functions.HasPermission(source, Config.Events['play sounds']) then
if not QBX.Functions.HasPermission(source, Config.Events['play sounds']) then
NoPerms(source)
return
end
return sounds
end)

lib.callback.register('qb-admin:server:canUseMenu', function(source)
if not QBCore.Functions.HasPermission(source, Config.Events['usemenu']) then
if not QBX.Functions.HasPermission(source, Config.Events['usemenu']) then
NoPerms(source)
return false
end
Expand All @@ -242,7 +241,7 @@ lib.callback.register('qb-admin:server:spawnVehicle', function(source, model)
local ply = GetPlayerPed(source)
local plyCoords = GetEntityCoords(ply)
local src = source
return QBCore.Functions.CreateVehicle(src, hash, vec4(plyCoords.x, plyCoords.y, plyCoords.z, GetEntityHeading(ply)), true)
return QBX.Functions.CreateVehicle(src, hash, vec4(plyCoords.x, plyCoords.y, plyCoords.z, GetEntityHeading(ply)), true)
end)

CreateThread(function()
Expand Down