About resource versions
These guides include the original resource names. Use the folder and SQL names supplied with your downloaded version. A renamed AWS package may differ from the original EXIT release.
qb.lua
if Config.Framework ~= "qb" then
return
end
Citizen.CreateThreadNow(function()
if Config.Framework == 'qb' then
QBCore = exports['qb-core']:GetCoreObject()
end
end)
function GetPlayers()
local xPlayers = QBCore.Functions.GetPlayers()
return xPlayers
end
function GetPlayerIdentifier(source)
local Player = QBCore.Functions.GetPlayer(source) or false
if Player then
return Player.PlayerData.citizenid
end
end
function GetPlayerId(source)
local Player = QBCore.Functions.GetPlayer(source)
return Player
end
function GetItemCountFromInventory(source, item)
if GetResourceState('ox_inventory') == 'started' then
return exports.ox_inventory:GetItemCount(source, item) or 0
end
local xPlayer = GetPlayerId(source)
if not xPlayer then return 0 end
local ItemData = xPlayer.Functions.GetItemByName(item)
if ItemData then
return ItemData.amount
end
return 0
end
function AddInventoryItem(src, item, quantity)
local xPlayer = GetPlayerId(src)
if GetResourceState('ox_inventory') == 'started' then
exports.ox_inventory:AddItem(src, item, quantity)
return
end
if xPlayer then
xPlayer.Functions.AddItem(item, quantity)
end
end
function RemoveInventoryItem(item, quantity)
local src = source
if GetResourceState('ox_inventory') == 'started' then
exports.ox_inventory:RemoveItem(src, item, quantity)
return
end
local xPlayer = GetPlayerId(src)
if xPlayer then
xPlayer.Functions.RemoveItem(item, quantity)
end
end
function AddMoney(source, price)
if source then
local xPlayer = GetPlayerId(source) or false
if xPlayer then
xPlayer.Functions.AddMoney('cash', price)
end
end
end
function RemoveMoney(price, src)
if src then
local xPlayer = GetPlayerId(src)
xPlayer.Functions.RemoveMoney('cash', price)
else
local xPlayer = GetPlayerId(source)
xPlayer.Functions.RemoveMoney('cash', price)
end
end
function GetMoney(source)
local xPlayer = GetPlayerId(source)
local money = xPlayer.PlayerData.money["cash"]
return money
end
function RegisterServerCallback(name, cb)
QBCore.Functions.CreateCallback(name, cb)
end
function GetPlayerFromIdentifier(identifier) --MODIFICACION
local xPlayer = QBCore.Functions.GetSource(identifier)
if xPlayer then
return xPlayer
else
return nil
end
end
function GetUserName(source)
local xPlayer = GetPlayerId(source)
if xPlayer then
local firstname = xPlayer.PlayerData.charinfo.firstname
local lastname = xPlayer.PlayerData.charinfo.lastname
return (firstname .. " " .. lastname)
else
return 'Unknown'
end
end