fix(qb-core): add global CreateUsableItem alias for qs-inventory compatibility
qs-inventory apelează CreateUsableItem ca funcție globală, dar qb-core definea doar QBCore.Functions.CreateUseableItem (cu 'e'). Adăugat alias global + fix 16 stringuri sparte în items.lua care blocau parsarea.
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
Example to use a custom trigger
|
||||
```lua
|
||||
local data = {
|
||||
label = 'License Example', ---@param Label on inventory
|
||||
type = 'Weapon license', ---@param Licence type
|
||||
name = 'id_card', ---@param Item name
|
||||
price = 10, --- @param Price of licencie
|
||||
}
|
||||
TriggerEvent('qs-licenses:client:Target', data)
|
||||
```
|
||||
|
||||
You need go to qs-inventory\config\metadata.js
|
||||
|
||||
Modify id_card
|
||||
```js
|
||||
if (itemData.name == "id_card") {
|
||||
$(".item-info-title").html("<p>" + itemData.info.label + "</p>");
|
||||
$(".item-info-description").html(
|
||||
"</p><p><strong>First Name: </strong><span>" +
|
||||
itemData.info.firstname +
|
||||
"</span></p><p><strong>Last Name: </strong><span>" +
|
||||
itemData.info.lastname +
|
||||
"</span></p><p><strong>Birth Date: </strong><span>" +
|
||||
itemData.info.birthdate +
|
||||
"</span></p><p><strong>Gender: </strong><span>" +
|
||||
gender +
|
||||
"</span></p><p><strong>Type: </strong><span>" +
|
||||
itemData.info.type +
|
||||
"</span></p>"
|
||||
);
|
||||
};
|
||||
```
|
||||
@@ -0,0 +1,119 @@
|
||||
if Config.Framework ~= 'esx' then
|
||||
return
|
||||
end
|
||||
|
||||
--[[ Uncomment if use old version
|
||||
ESX = nil
|
||||
CreateThread(function()
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
]]
|
||||
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(playerData)
|
||||
CreateBlips()
|
||||
end)
|
||||
|
||||
function GetJob()
|
||||
return ESX.GetPlayerData().job.name
|
||||
end
|
||||
|
||||
function SendTextMessage(msg, type)
|
||||
if type == 'inform' then
|
||||
lib.notify({
|
||||
title = 'Inventory',
|
||||
description = msg,
|
||||
type = 'inform'
|
||||
})
|
||||
end
|
||||
if type == 'error' then
|
||||
lib.notify({
|
||||
title = 'Inventory',
|
||||
description = msg,
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
if type == 'success' then
|
||||
lib.notify({
|
||||
title = 'Inventory',
|
||||
description = msg,
|
||||
type = 'success'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
if lib.progressCircle({
|
||||
duration = duration,
|
||||
label = label,
|
||||
position = 'bottom',
|
||||
useWhileDead = useWhileDead,
|
||||
canCancel = canCancel,
|
||||
disable = disableControls,
|
||||
anim = {
|
||||
dict = animation.animDict,
|
||||
clip = animation.anim,
|
||||
flag = animation?.flags
|
||||
},
|
||||
prop = prop
|
||||
}) then
|
||||
onFinish()
|
||||
else
|
||||
onCancel()
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('qs-licenses:ShowId', function(sourceId, character)
|
||||
local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(sourceId)), false)
|
||||
local pos = GetEntityCoords(PlayerPedId(), false)
|
||||
if sourceId == GetPlayerServerId(PlayerId()) then
|
||||
ShowCard()
|
||||
end
|
||||
local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true)
|
||||
if ((dist > 0 and dist < 2.5) or sourceId == GetPlayerServerId(PlayerId())) then
|
||||
TriggerEvent('chat:addMessage', {
|
||||
template = '<div class="chat-message advert"><div class="chat-message-body"><strong style="font-size: 20px">{0}</strong><br>Firstname:</strong> {1} <br><strong>Lastname:</strong> {2} <br><strong>Date of birth:</strong> {3} <br><strong>Gender:</strong> {4}</div></div>',
|
||||
args = { character.type, character.firstname, character.lastname, character.birthdate, character.gender }
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
local texts = {}
|
||||
if GetResourceState('qs-textui') == 'started' then
|
||||
function DrawText3D(x, y, z, text, id, key)
|
||||
local _id = id
|
||||
if not texts[_id] then
|
||||
CreateThread(function()
|
||||
texts[_id] = 5
|
||||
while texts[_id] > 0 do
|
||||
texts[_id] = texts[_id] - 1
|
||||
Wait(0)
|
||||
end
|
||||
texts[_id] = nil
|
||||
exports['qs-textui']:DeleteDrawText3D(id)
|
||||
end)
|
||||
TriggerEvent('textui:DrawText3D', x, y, z, text, id, key)
|
||||
end
|
||||
texts[_id] = 5
|
||||
end
|
||||
else
|
||||
function DrawText3D(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,109 @@
|
||||
if Config.Framework ~= 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function(playerData)
|
||||
CreateBlips()
|
||||
end)
|
||||
|
||||
function GetJob()
|
||||
return QBCore.Functions.GetPlayerData().job.name
|
||||
end
|
||||
|
||||
function SendTextMessage(msg, type)
|
||||
if type == 'inform' then
|
||||
lib.notify({
|
||||
title = 'Inventory',
|
||||
description = msg,
|
||||
type = 'inform'
|
||||
})
|
||||
end
|
||||
if type == 'error' then
|
||||
lib.notify({
|
||||
title = 'Inventory',
|
||||
description = msg,
|
||||
type = 'error'
|
||||
})
|
||||
end
|
||||
if type == 'success' then
|
||||
lib.notify({
|
||||
title = 'Inventory',
|
||||
description = msg,
|
||||
type = 'success'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
function Progressbar(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
if lib.progressCircle({
|
||||
duration = duration,
|
||||
label = label,
|
||||
position = 'bottom',
|
||||
useWhileDead = useWhileDead,
|
||||
canCancel = canCancel,
|
||||
disable = disableControls,
|
||||
anim = {
|
||||
dict = animation.animDict,
|
||||
clip = animation.anim,
|
||||
flag = animation?.flags
|
||||
},
|
||||
prop = prop
|
||||
}) then
|
||||
onFinish()
|
||||
else
|
||||
onCancel()
|
||||
end
|
||||
end
|
||||
|
||||
RegisterNetEvent('qs-licenses:ShowId', function(sourceId, character)
|
||||
local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(sourceId)), false)
|
||||
local pos = GetEntityCoords(PlayerPedId(), false)
|
||||
if sourceId == GetPlayerServerId(PlayerId()) then
|
||||
ShowCard()
|
||||
end
|
||||
local dist = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true)
|
||||
if ((dist > 0 and dist < 2.5) or sourceId == GetPlayerServerId(PlayerId())) then
|
||||
TriggerEvent('chat:addMessage', {
|
||||
template = '<div class="chat-message advert"><div class="chat-message-body"><strong style="font-size: 20px">{0}</strong><br>Firstname:</strong> {1} <br><strong>Lastname:</strong> {2} <br><strong>Date of birth:</strong> {3} <br><strong>Gender:</strong> {4}</div></div>',
|
||||
args = { character.type, character.firstname, character.lastname, character.birthdate, character.gender }
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
local texts = {}
|
||||
if GetResourceState('qs-textui') == 'started' then
|
||||
function DrawText3D(x, y, z, text, id, key)
|
||||
local _id = id
|
||||
if not texts[_id] then
|
||||
CreateThread(function()
|
||||
texts[_id] = 5
|
||||
while texts[_id] > 0 do
|
||||
texts[_id] = texts[_id] - 1
|
||||
Wait(0)
|
||||
end
|
||||
texts[_id] = nil
|
||||
exports['qs-textui']:DeleteDrawText3D(id)
|
||||
end)
|
||||
TriggerEvent('textui:DrawText3D', x, y, z, text, id, key)
|
||||
end
|
||||
texts[_id] = 5
|
||||
end
|
||||
else
|
||||
function DrawText3D(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry('STRING')
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x, y, z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = text:len() / 370
|
||||
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
end
|
||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
fx_version "adamant"
|
||||
|
||||
game "gta5"
|
||||
|
||||
lua54 'yes'
|
||||
|
||||
shared_scripts {
|
||||
'@ox_lib/init.lua',
|
||||
'shared/*.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client/custom/*.lua',
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
'@mysql-async/lib/MySQL.lua',
|
||||
'server/custom/*.lua',
|
||||
'server/main.lua',
|
||||
}
|
||||
|
||||
escrow_ignore {
|
||||
'client/custom/*.lua',
|
||||
'server/custom/*.lua',
|
||||
'shared/*.lua'
|
||||
}
|
||||
dependency '/assetpacks'
|
||||
@@ -0,0 +1,53 @@
|
||||
if Config.Framework ~= "esx" then
|
||||
return
|
||||
end
|
||||
|
||||
local version = GetResourceMetadata('es_extended', 'version', 0)
|
||||
|
||||
if version == '1.1.0' or version == '1.2.0' or version == 'legacy' then
|
||||
ESX = nil
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
else
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
end
|
||||
|
||||
function GetPlayerFromIdFramework(player)
|
||||
return ESX.GetPlayerFromId(player)
|
||||
end
|
||||
|
||||
function GetCharacterData(source)
|
||||
local xPlayer = GetPlayerFromIdFramework(source)
|
||||
local firstName, lastName, sex, dateofbirth
|
||||
if xPlayer.get then
|
||||
firstName = xPlayer.get("firstName")
|
||||
lastName = xPlayer.get("lastName")
|
||||
if xPlayer.get("sex") == 'm' then
|
||||
sex = Lang('LICENSES_MAN_LABEL')
|
||||
elseif xPlayer.get("sex") == 'f' then
|
||||
sex = Lang('LICENSES_WOMEN_LABEL')
|
||||
end
|
||||
dateofbirth = xPlayer.get("dateofbirth") or "01/01/2000"
|
||||
else
|
||||
local name = MySQL.Sync.fetchAll("SELECT `firstname`, `lastname`, `dateofbirth`, `sex` FROM `users` WHERE `identifier`=@identifier", {["@identifier"] = ESX.GetIdentifier(source)})
|
||||
firstName = name[1]?.firstname
|
||||
lastName = name[1]?.lastname
|
||||
if name[1]?.sex == 'm' then
|
||||
sex = Lang('LICENSES_MAN_LABEL')
|
||||
elseif name[1]?.sex == 'f' then
|
||||
sex = Lang('LICENSES_WOMEN_LABEL')
|
||||
end
|
||||
dateofbirth = name[1]?.dateofbirth
|
||||
end
|
||||
|
||||
return firstName, lastName, sex, dateofbirth
|
||||
end
|
||||
|
||||
function GetBankMoney(source)
|
||||
local xPlayer = GetPlayerFromIdFramework(source)
|
||||
return xPlayer.getAccount('bank').money
|
||||
end
|
||||
|
||||
function RemoveBankMoney(source, price)
|
||||
local xPlayer = GetPlayerFromIdFramework(source)
|
||||
xPlayer.removeAccountMoney('bank', price)
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
if Config.Framework ~= 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
function GetPlayerFromIdFramework(player)
|
||||
local Player = QBCore.Functions.GetPlayer(player)
|
||||
if Player then
|
||||
Player.citizenid = Player?.PlayerData?.citizenid
|
||||
Player.identifier = Player?.PlayerData?.citizenid
|
||||
Player.source = Player?.PlayerData?.source
|
||||
end
|
||||
return Player
|
||||
end
|
||||
|
||||
function GetCharacterData(source)
|
||||
local player = GetPlayerFromIdFramework(source)?.PlayerData?.charinfo
|
||||
local sex
|
||||
if player.gender == 0 then
|
||||
sex = Lang('LICENSES_MAN_LABEL')
|
||||
elseif player.gender == 1 then
|
||||
sex = Lang('LICENSES_WOMEN_LABEL')
|
||||
end
|
||||
return player.firstname, player.lastname, sex, player.birthdate
|
||||
end
|
||||
|
||||
function GetBankMoney(source)
|
||||
local xPlayer = GetPlayerFromIdFramework(source)
|
||||
return xPlayer?.PlayerData?.money['bank']
|
||||
end
|
||||
|
||||
function RemoveBankMoney(source, price)
|
||||
local xPlayer = GetPlayerFromIdFramework(source)
|
||||
xPlayer.Functions.RemoveMoney('bank', price)
|
||||
end
|
||||
Binary file not shown.
@@ -0,0 +1,75 @@
|
||||
Config = Config or {}
|
||||
|
||||
local esxHas = GetResourceState('es_extended') == 'started'
|
||||
local qbHas = GetResourceState('qb-core') == 'started'
|
||||
local qbxHas = GetResourceState('qbx_core') == 'started'
|
||||
|
||||
Config.Framework = esxHas and 'esx' or qbHas and 'qb' or qbxHas and 'qb' or 'esx'
|
||||
|
||||
-- Marker configuration for the shop locations
|
||||
Config.Marker = {
|
||||
type = 2, -- Marker type (refer to GTA marker types)
|
||||
scale = {x = 0.2, y = 0.2, z = 0.1}, -- Marker scale
|
||||
colour = {r = 71, g = 181, b = 255, a = 120}, -- Marker color with transparency (RGBA)
|
||||
movement = 1 -- Marker animation (0 = no movement, 1 = with movement)
|
||||
}
|
||||
|
||||
-- Shop configuration
|
||||
Config.Shops = {
|
||||
[1] = {
|
||||
name = 'id_card', -- Unique identifier for the item
|
||||
text = "[E] - Identity License", -- Interaction text
|
||||
label = 'ID', -- Item label
|
||||
type = "Document", -- Item type
|
||||
progbar = "Purchasing license...", -- Progress bar text
|
||||
price = 150, -- Item price
|
||||
isjob = false, -- Required job to access this shop (false = no job required)
|
||||
timer = 2500, -- Interaction duration (milliseconds)
|
||||
location = vec3(-545.08, -204.13, 38.22), -- Shop location (vector3 format)
|
||||
blip = { -- Blip configuration for the map
|
||||
enable = true, -- Enable or disable the blip
|
||||
name = 'Identity License', -- Blip name
|
||||
sprite = 409, -- Blip sprite (icon)
|
||||
color = 0, -- Blip color
|
||||
scale = 0.7 -- Blip size
|
||||
},
|
||||
},
|
||||
|
||||
[2] = {
|
||||
name = 'weaponlicense', -- Unique identifier for the item
|
||||
isjob = false, -- Required job to access this shop (false = no job required)
|
||||
text = "[E] - Weapons License", -- Interaction text
|
||||
label = 'License', -- Item label
|
||||
type = "Weapons License", -- Item type
|
||||
price = 10, -- Item price
|
||||
progbar = "Purchasing license...", -- Progress bar text
|
||||
timer = 2500, -- Interaction duration (milliseconds)
|
||||
location = vec3(14.01, -1106.11, 29.8), -- Shop location (vector3 format)
|
||||
blip = { -- Blip configuration for the map
|
||||
enable = false, -- Enable or disable the blip
|
||||
name = 'Weapons License', -- Blip name
|
||||
sprite = 89, -- Blip sprite (icon)
|
||||
color = 1, -- Blip color
|
||||
scale = 0.5 -- Blip size
|
||||
},
|
||||
},
|
||||
|
||||
[3] = {
|
||||
name = 'driver_license', -- Unique identifier for the item
|
||||
isjob = false, -- Required job to access this shop (false = no job required)
|
||||
text = "[E] - Driving License", -- Interaction text
|
||||
label = 'Driving License', -- Item label
|
||||
type = "License", -- Item type
|
||||
price = 10, -- Item price
|
||||
progbar = "Purchasing license...", -- Progress bar text
|
||||
timer = 2500, -- Interaction duration (milliseconds)
|
||||
location = vec3(239.78, -1380.27, 33.74), -- Shop location (vector3 format)
|
||||
blip = { -- Blip configuration for the map
|
||||
enable = true, -- Enable or disable the blip
|
||||
name = 'Driving License', -- Blip name
|
||||
sprite = 67, -- Blip sprite (icon)
|
||||
color = 3, -- Blip color
|
||||
scale = 0.6 -- Blip size
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
Config = Config or {}
|
||||
|
||||
Config.Language = 'en'
|
||||
|
||||
Config.Languages = {
|
||||
['en'] = {
|
||||
['LICENSES_PROGRESS'] = 'Getting licensed...',
|
||||
['LICENSES_SUCCESS'] = 'Thanks for waiting, here is your new',
|
||||
['LICENSES_NO_MONEY'] = "You don't have enough money",
|
||||
['LICENSES_WOMEN_LABEL'] = 'Female',
|
||||
['LICENSES_MAN_LABEL'] = 'Man',
|
||||
|
||||
['LICENSES_DIALOG_HEADER'] = 'Do you want to buy this license?',
|
||||
['LICENSES_DIALOG_CONTENT'] = 'This license will cost you ${price} and will take {timer} seconds to complete.',
|
||||
},
|
||||
|
||||
['es'] = {
|
||||
['LICENSES_PROGRESS'] = 'Obteniendo licencia...',
|
||||
['LICENSES_SUCCESS'] = 'Gracias por esperar, aquí tienes tu nueva',
|
||||
['LICENSES_NO_MONEY'] = 'No tienes dinero suficiente',
|
||||
['LICENSES_WOMEN_LABEL'] = 'Mujer',
|
||||
['LICENSES_MAN_LABEL'] = 'Hombre',
|
||||
|
||||
['LICENSES_DIALOG_HEADER'] = '¿Quieres comprar esta licencia?',
|
||||
['LICENSES_DIALOG_CONTENT'] = 'Esta licencia costará ${price} y tardará {timer} segundos en completarse.',
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user