Ox_inventory
ESX
ox_inventory/modules/bridge/esx/server.lua
---@diagnostic disable-next-line: duplicate-set-field
function server.hasLicense(inv, name)
return exports.bcs_licensemanager:HasLicense(inv.id, name)
end
---@diagnostic disable-next-line: duplicate-set-field
function server.buyLicense(inv, license)
if server.hasLicense(inv, license.name) then
return false, 'already_have'
elseif Inventory.GetItem(inv, 'money', false, true) < license.price then
return false, 'can_not_afford'
end
Inventory.RemoveItem(inv, 'money', license.price)
TriggerClientEvent('LicenseManager:addLicense', inv.id, license.name)
return true, 'have_purchased'
end
Comment this part out
ox_inventory/modules/bridge/esx/server.lua
-- MySQL.ready(function()
-- MySQL.insert('INSERT IGNORE INTO `licenses` (`type`, `label`) VALUES (?, ?)', { 'weapon', 'Weapon License'})
-- end)
QB
ox_inventory/modules/bridge/qb/server.lua
---@diagnostic disable-next-line: duplicate-set-field
function server.hasLicense(inv, license)
local player = server.GetPlayerFromId(inv.id)
return player and exports.bcs_licensemanager:HasLicense(player.PlayerData.source, license)
end
---@diagnostic disable-next-line: duplicate-set-field
function server.buyLicense(inv, license)
local player = server.GetPlayerFromId(inv.id)
if not player then return end
if player.PlayerData.metadata.licences[license.name] then
return false, 'already_have'
elseif Inventory.GetItem(inv, 'money', false, true) < license.price then
return false, 'can_not_afford'
end
Inventory.RemoveItem(inv, 'money', license.price)
TriggerClientEvent('LicenseManager:addLicense', inv.id, license.name)
player.PlayerData.metadata.licences[license.name] = true
player.Functions.SetMetaData('licences', player.PlayerData.metadata.licences)
return true, 'have_purchased'
end
Items
These are the default for the items and example on how to add more licenses as item for ox. Put these in data/items.lua
Licenses
['weapon'] = {
label = 'Firearm License',
description = 'Kartu Ijin Senjata',
weight = 50,
stack = false,
close = true,
consume = 0,
client = {
export = 'bcs_licensemanager.showCard',
}
},
['driver_car'] = {
label = 'SIM A',
description = 'Kartu Ijin Mengemudi',
weight = 50,
stack = false,
close = true,
consume = 0,
client = {
export = 'bcs_licensemanager.showCard',
}
},
['driver_truck'] = {
label = 'SIM B',
weight = 50,
stack = false,
close = true,
description = 'Kartu Ijin Mengemudi',
consume = 0,
client = {
export = 'bcs_licensemanager.showCard',
}
},
['driver_bike'] = {
label = 'SIM C',
weight = 50,
stack = false,
close = true,
description = 'Kartu Ijin Mengemudi',
consume = 0,
client = {
export = 'bcs_licensemanager.showCard',
}
},
['identification'] = {
label = 'Identification',
weight = 50,
stack = false,
close = true,
description = 'Kartu Ijin Mengemudi',
consume = 0,
client = {
export = 'bcs_licensemanager.showCard',
}
},
Badges
['lspd_badge'] = {
label = 'LSPD Badge',
weight=50,
stack = false,
close = true,
consume = 0,
client = {
export = 'bcs_licensemanager.showBadge'
}
}