This commit is contained in:
Nordi98 2025-07-09 21:31:55 +02:00
parent 55adb0ec7f
commit 1f0a23516e
46 changed files with 2671 additions and 9 deletions

View file

@ -0,0 +1,68 @@
Core = nil

if Config['Core']:upper() == 'ESX' then
local _esx_ = 'new' -- 'new' / 'old'

if _esx_ then
Core = exports['es_extended']:getSharedObject()
else
while Core == nil do
TriggerEvent('esx:getSharedObject', function(obj) Core = obj end)
Citizen.Wait(0)
end
end

LoadedEvent = 'esx:playerLoaded'
ReviveEvent = 'esx_ambulancejob:revive'
JobUpdateEvent = 'esx:setJob'
TSCB = Core.TriggerServerCallback

function GetPlayerJobDatas()
return Core.GetPlayerData().job
end

function GetPlayersFunction()
return Core.Game.GetPlayers()
end

function GetVehiclePropertiesFunction(vehicle)
return Core.Game.GetVehicleProperties(vehicle)
end

function SetVehiclePropertiesFunction(vehicle, properties)
return Core.Game.SetVehicleProperties(vehicle, properties)
end

function GetClosestVehicleFunction(coords, modelFilter)
return Core.Game.GetClosestVehicle(coords, modelFilter)
end

elseif Config['Core']:upper() == 'QBCORE' then
Core = exports['qb-core']:GetCoreObject()

LoadedEvent = 'QBCore:Client:OnPlayerLoaded'
ReviveEvent = 'hospital:client:Revive'
JobUpdateEvent = 'QBCore:Client:OnJobUpdate'
TSCB = Core.Functions.TriggerCallback

function GetPlayerJobDatas()
return Core.Functions.GetPlayerData().job
end

function GetPlayersFunction()
return Core.Functions.GetPlayers()
end

function GetVehiclePropertiesFunction(vehicle)
return Core.Functions.GetVehicleProperties(vehicle)
end

function SetVehiclePropertiesFunction(vehicle, properties)
return Core.Functions.SetVehicleProperties(vehicle, properties)
end

function GetClosestVehicleFunction(coords, modelFilter)
return Core.Functions.GetClosestVehicle(coords, modelFilter)
end
end

Binary file not shown.

View file

@ -0,0 +1,271 @@
Core = nil

if Config['Core']:upper() == 'ESX' then
local _esx_ = 'new' -- 'new' / 'old'
if _esx_ == 'new' then
Core = exports['es_extended']:getSharedObject()
else
Core = nil
TriggerEvent('esx:getSharedObject', function(obj) Core = obj end)
while Core == nil do
Citizen.Wait(0)
end
end

RESCB = Core.RegisterServerCallback
GETPFI = Core.GetPlayerFromId
RUI = Core.RegisterUsableItem
SetJobEvent = 'esx:setJob'
onPlayerDeath = 'esx:onPlayerDeath'
SQLData = {
player_vehicles = 'owned_vehicles',
}

function GetIdentifier(source)
local xPlayer = GETPFI(source)
while xPlayer == nil do
Citizen.Wait(1000)
xPlayer = GETPFI(source)
end
return xPlayer.identifier
end

function GetPlayerByIdentifier(identifier)
return Core.GetPlayerFromIdentifier(identifier)
end

function GetAccountMoney(source,account)
local xPlayer = GETPFI(source)
if account == 'bank' then
return xPlayer.getAccount(account).money
elseif account == 'money' then
return xPlayer.getMoney()
end
end

function AddMoneyFunction(source, account, amount)
local xPlayer = GETPFI(source)
if account == 'bank' then
xPlayer.addAccountMoney('bank', amount)
elseif account == 'money' then
xPlayer.addMoney(amount)
end
end

function RemoveAccountMoney(source, account, amount)
local xPlayer = GETPFI(source)
if account == 'bank' then
xPlayer.removeAccountMoney('bank', amount)
elseif account == 'money' then
xPlayer.removeMoney(amount)
end
end

function GetItemCount(source, item)
local xPlayer = GETPFI(source)

if _esx_ == 'new' then
return xPlayer.getInventoryItem(item).count
else
if string.sub(item, 0, 6):lower() == 'weapon' then
local loadoutNum, weapon = xPlayer.getWeapon(item:upper())

if weapon then
return true
else
return false
end
else
return xPlayer.getInventoryItem(item).count
end
end
end
function RemoveItem(source, item, amount)
local xPlayer = GETPFI(source)
if _esx_ == 'new' then
xPlayer.removeInventoryItem(item, amount)
else
if string.sub(item, 0, 6):lower() == 'weapon' then
xPlayer.removeWeapon(item)
else
xPlayer.removeInventoryItem(item, amount)
end
end
end

function AddItem(source, item, count, info)
local xPlayer = GETPFI(source)
if _esx_ == 'new' then
xPlayer.addInventoryItem(item, count, info)
else
if string.sub(item, 0, 6):lower() == 'weapon' then
xPlayer.addWeapon(item, 90)
else
xPlayer.addInventoryItem(item, count)
end
end
end

function GetPlayerNameFunction(source)
local name
if Config.SteamName then
name = GetPlayerName(source) or 'No Data'
else
local xPlayer = GETPFI(source)
name = xPlayer.getName() or 'No Data'
end
return name
end

function GetPlayerJob(source)
local xPlayer = GETPFI(source)
return xPlayer.job.name
end

function CreateCoreJob(name, label, grades)
Core.CreateJob(name, label, grades)
end

function SetCoreJob(source, job, grade)
local xPlayer = GETPFI(source)
xPlayer.setJob(job, grade)
end

function SetCoreJobOffline(identifier, job, grade)
MySQL.update('UPDATE users SET job = ?, job_grade = ? WHERE identifier = ?', {job, grade, identifier})
end

function GetPlayersFunction()
return Core.GetPlayers()
end

elseif Config['Core']:upper() == 'QBCORE' then

Core = exports['qb-core']:GetCoreObject()
RESCB = Core.Functions.CreateCallback
GETPFI = Core.Functions.GetPlayer
RUI = Core.Functions.CreateUseableItem
SetJobEvent = 'QBCore:Server:SetGang'
onPlayerDeath = GetResourceState("brutal_ambulancejob") == "started" and 'onPlayerDeath' or 'hospital:server:SetDeathStatus'
SQLData = {
player_vehicles = 'player_vehicles',
}

function GetIdentifier(source)
local xPlayer = GETPFI(source)
while xPlayer == nil do
Citizen.Wait(1000)
xPlayer = GETPFI(source)
end
return xPlayer.PlayerData.citizenid
end

function GetPlayerByIdentifier(identifier)
return Core.Functions.GetPlayerByCitizenId(identifier)
end

function GetAccountMoney(source, account)
local xPlayer = GETPFI(source)
if account == 'bank' then
return xPlayer.PlayerData.money.bank
elseif account == 'money' then
return xPlayer.PlayerData.money.cash
end
end

function AddMoneyFunction(source, account, amount)
local xPlayer = GETPFI(source)
if account == 'bank' then
xPlayer.Functions.AddMoney('bank', amount)
elseif account == 'money' then
xPlayer.Functions.AddMoney('cash', amount)
end
end

function RemoveAccountMoney(source, account, amount)
local xPlayer = GETPFI(source)
if account == 'bank' then
xPlayer.Functions.RemoveMoney('bank', amount)
elseif account == 'money' then
xPlayer.Functions.RemoveMoney('cash', amount)
end
end

function GetItemCount(source, item)
local xPlayer = GETPFI(source)
local items = xPlayer.Functions.GetItemByName(item)
local item_count = 0
if items ~= nil then
item_count = items.amount
else
item_count = 0
end
return item_count
end

function RemoveItem(source, item, amount)
local xPlayer = GETPFI(source)
xPlayer.Functions.RemoveItem(item, amount)
end

function AddItem(source, item, count, info)
local xPlayer = GETPFI(source)
xPlayer.Functions.AddItem(item, count, nil, info)
end

function GetPlayerNameFunction(source)
local name
if Config.SteamName then
name = GetPlayerName(source)
else
local xPlayer = GETPFI(source)
name = xPlayer.PlayerData.charinfo.firstname..' '..xPlayer.PlayerData.charinfo.lastname
end
return name
end

function GetPlayerJob(source)
local xPlayer = GETPFI(source)
return xPlayer.PlayerData.gang.name
end

function CreateCoreJob(name, label, grades)
Core.Functions.AddGang(name,
{
label = label,
grades = grades,
})
end

function UpdateCoreJob(name, label, grades)
Core.Functions.UpdateGang(name, {
label = label,
grades = grades,
})
end

function RemoveCoreJob(name)
Core.Functions.RemoveGang(name)
end

function SetCoreJob(source, job, grade)
local xPlayer = GETPFI(source)
xPlayer.Functions.SetGang(job, grade)
end

function SetCoreJobOffline(identifier, job)
local joblabel = "None"
if Gangs[job] ~= nil and Gangs[job].label ~= nil then
joblabel = Gangs[job].label
end

MySQL.update('UPDATE players SET gang = ? WHERE citizenid = ?', {json.encode({grade = {level = 0, name = "Member"}, name = job, isboss = false, label = joblabel}), identifier})
end

function GetPlayersFunction()
return Core.Functions.GetPlayers()
end
end