remove more unneeded functions

This commit is contained in:
Kakarot
2025-06-01 15:42:49 -05:00
parent 8f883ccd2a
commit 28753848dc
5 changed files with 10 additions and 147 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ local function changeText(text, position)
end
local function keyPressed()
CreateThread(function() -- Not sure if a thread is needed but why not eh?
CreateThread(function()
SendNUIMessage({
action = 'KEY_PRESSED',
})
-53
View File
@@ -26,10 +26,6 @@ function QBCore.Functions.TriggerCallback(name, ...)
end
end
function QBCore.Debug(resource, obj, depth)
TriggerServerEvent('QBCore:DebugSomething', resource, obj, depth)
end
-- Player
function QBCore.Functions.GetPlayerData(cb)
@@ -53,55 +49,6 @@ function QBCore.Functions.GetName()
return charinfo.firstname .. ' ' .. charinfo.lastname
end
---@param entity number - The entity to look at
---@param timeout number - The time in milliseconds before the function times out
---@param speed number - The speed at which the entity should turn
---@return number - The time at which the entity was looked at
function QBCore.Functions.LookAtEntity(entity, timeout, speed)
local involved = GetInvokingResource()
if not DoesEntityExist(entity) then
return involved .. ' :^1 Entity does not exist'
end
if type(entity) ~= 'number' then
return involved .. ' :^1 Entity must be a number'
end
if type(speed) ~= 'number' then
return involved .. ' :^1 Speed must be a number'
end
if speed > 5.0 then speed = 5.0 end
if timeout > 5000 then timeout = 5000 end
local ped = PlayerPedId()
local playerPos = GetEntityCoords(ped)
local targetPos = GetEntityCoords(entity)
local dx = targetPos.x - playerPos.x
local dy = targetPos.y - playerPos.y
local targetHeading = GetHeadingFromVector_2d(dx, dy)
local turnSpeed
local startTimeout = GetGameTimer()
while true do
local currentHeading = GetEntityHeading(ped)
local diff = targetHeading - currentHeading
if math.abs(diff) < 2 then
break
end
if diff < -180 then
diff = diff + 360
elseif diff > 180 then
diff = diff - 360
end
turnSpeed = speed + (2.5 - speed) * (1 - math.abs(diff) / 180)
if diff > 0 then
currentHeading = currentHeading + turnSpeed
else
currentHeading = currentHeading - turnSpeed
end
SetEntityHeading(ped, currentHeading)
Wait(0)
if (startTimeout + timeout) < GetGameTimer() then break end
end
SetEntityHeading(ped, targetHeading)
end
-- Function to run an animation
--- @param animDic string: The name of the animation dictionary
--- @param animName string - The name of the animation within the dictionary
+6 -5
View File
@@ -25,20 +25,21 @@ local function tPrint(tbl, indent)
end
end
RegisterServerEvent('QBCore:DebugSomething', function(tbl, indent, resource)
function QBCore.Debug(tbl, indent)
local resource = GetInvokingResource() or 'qb-core'
print(('\x1b[4m\x1b[36m[ %s : DEBUG]\x1b[0m'):format(resource))
tPrint(tbl, indent)
print('\x1b[4m\x1b[36m[ END DEBUG ]\x1b[0m')
end)
function QBCore.Debug(tbl, indent)
TriggerEvent('QBCore:DebugSomething', tbl, indent, GetInvokingResource() or 'qb-core')
end
function QBCore.ShowError(resource, msg)
print('\x1b[31m[' .. resource .. ':ERROR]\x1b[0m ' .. msg)
end
function QBCore.ShowWarning(resource, msg)
print('\x1b[33m[' .. resource .. ':WARNING]\x1b[0m ' .. msg)
end
function QBCore.ShowSuccess(resource, msg)
print('\x1b[32m[' .. resource .. ':LOG]\x1b[0m ' .. msg)
end
+3 -27
View File
@@ -18,8 +18,8 @@ AddEventHandler('playerDropped', function(reason)
QBCore.Players[src] = nil
end)
AddEventHandler("onResourceStop", function(resName)
for i,v in pairs(QBCore.UsableItems) do
AddEventHandler('onResourceStop', function(resName)
for i, v in pairs(QBCore.UsableItems) do
if v.resource == resName then
QBCore.UsableItems[i] = nil
end
@@ -36,7 +36,7 @@ if readyFunction ~= nil then
local DatabaseInfo = QBCore.Functions.GetDatabaseInfo()
if not DatabaseInfo or not DatabaseInfo.exists then return end
local result = MySQL.query.await('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = "bans";', {DatabaseInfo.database})
local result = MySQL.query.await('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = "bans";', { DatabaseInfo.database })
if result and result[1] then
bansTableExists = true
end
@@ -223,26 +223,6 @@ RegisterServerEvent('baseevents:leftVehicle', function(veh, seat, modelName)
TriggerClientEvent('QBCore:Client:VehicleInfo', src, data)
end)
-- Items
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon.
RegisterNetEvent('QBCore:Server:UseItem', function(item)
print(string.format('%s triggered QBCore:Server:UseItem by ID %s with the following data. This event is deprecated due to exploitation, and will be removed soon. Check qb-inventory for the right use on this event.', GetInvokingResource(), source))
QBCore.Debug(item)
end)
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon. function(itemName, amount, slot)
RegisterNetEvent('QBCore:Server:RemoveItem', function(itemName, amount)
local src = source
print(string.format('%s triggered QBCore:Server:RemoveItem by ID %s for %s %s. This event is deprecated due to exploitation, and will be removed soon. Adjust your events accordingly to do this server side with player functions.', GetInvokingResource(), src, amount, itemName))
end)
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon. function(itemName, amount, slot, info)
RegisterNetEvent('QBCore:Server:AddItem', function(itemName, amount)
local src = source
print(string.format('%s triggered QBCore:Server:AddItem by ID %s for %s %s. This event is deprecated due to exploitation, and will be removed soon. Adjust your events accordingly to do this server side with player functions.', GetInvokingResource(), src, amount, itemName))
end)
-- Non-Chat Command Calling (ex: qb-adminmenu)
RegisterNetEvent('QBCore:CallCommand', function(command, args)
@@ -279,7 +259,3 @@ QBCore.Functions.CreateCallback('QBCore:Server:CreateVehicle', function(source,
local veh = QBCore.Functions.CreateAutomobile(source, model, coords, warp)
cb(NetworkGetNetworkIdFromEntity(veh))
end)
--QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, amount)
-- https://github.com/qbcore-framework/qb-inventory/blob/e4ef156d93dd1727234d388c3f25110c350b3bcf/server/main.lua#L2066
--end)
-61
View File
@@ -493,38 +493,6 @@ function QBCore.Functions.CanUseItem(item)
return QBCore.UsableItems[item]
end
-- Inventory Backwards Compatibility
function QBCore.Functions.UseItem(source, item)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:UseItem(source, item)
end
function QBCore.Functions.SaveInventory(source)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:SaveInventory(source, false)
end
function QBCore.Functions.SaveOfflineInventory(PlayerData)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:SaveInventory(PlayerData, true)
end
function QBCore.Functions.GetTotalWeight(items)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetTotalWeight(items)
end
function QBCore.Functions.GetSlotsByItem(items, itemName)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetSlotsByItem(items, itemName)
end
function QBCore.Functions.GetFirstSlotByItem(items, itemName)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetFirstSlotByItem(items, itemName)
end
---Kick Player
---@param source any
---@param reason string
@@ -710,18 +678,6 @@ function QBCore.Functions.IsLicenseInUse(license)
return false
end
-- Utility functions
---Check if a player has an item [deprecated]
---@param source any
---@param items table|string
---@param amount number
---@return boolean
function QBCore.Functions.HasItem(source, items, amount)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:HasItem(source, items, amount)
end
---Notify
---@param source any
---@param text string
@@ -731,23 +687,6 @@ function QBCore.Functions.Notify(source, text, type, length)
TriggerClientEvent('QBCore:Notify', source, text, type, length)
end
---???? ... ok
---@param source any
---@param data any
---@param pattern any
---@return boolean
function QBCore.Functions.PrepForSQL(source, data, pattern)
data = tostring(data)
local src = source
local player = QBCore.Functions.GetPlayer(src)
local result = string.match(data, pattern)
if not result or string.len(result) ~= string.len(data) then
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'SQL Exploit Attempted', 'red', string.format('%s attempted to exploit SQL!', player.PlayerData.license))
return false
end
return true
end
function QBCore.Functions.CreateCitizenId()
local CitizenId = tostring(QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(5)):upper()
local result = MySQL.prepare.await('SELECT EXISTS(SELECT 1 FROM players WHERE citizenid = ?) AS uniqueCheck', { CitizenId })