es
This commit is contained in:
parent
c6dcdfb78a
commit
638b76bc38
2 changed files with 83 additions and 5 deletions
|
@ -13,6 +13,16 @@ function Notify(source, text, status)
|
|||
print("Config.Notifications is invalid.")
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if TGIANN inventory is available
|
||||
local function isTGIANNAvailable()
|
||||
local available = false
|
||||
pcall(function()
|
||||
available = exports["tgiann-inventory"] ~= nil
|
||||
end)
|
||||
return available
|
||||
end
|
||||
|
||||
RegisterServerEvent('dynyx_gym:BuyGymM', function()
|
||||
local src = source
|
||||
if Config.Inventory == 'qb' then
|
||||
|
@ -35,5 +45,49 @@ RegisterServerEvent('dynyx_gym:BuyGymM', function()
|
|||
else
|
||||
Notify(src, 'Not Enough Money', 'error')
|
||||
end
|
||||
elseif Config.Inventory == 'tgiann' then
|
||||
if isTGIANNAvailable() then
|
||||
local money = exports["tgiann-inventory"]:GetItemByName(src, "money")
|
||||
|
||||
if money and money.amount >= Config.GymPassPrice then
|
||||
local success = exports["tgiann-inventory"]:RemoveItem(src, "money", Config.GymPassPrice)
|
||||
if success then
|
||||
exports["tgiann-inventory"]:AddItem(src, Config.GymPassItem, 1)
|
||||
Notify(src, 'You purchased a gym membership!', 'success')
|
||||
else
|
||||
Notify(src, 'Transaction Failed', 'error')
|
||||
end
|
||||
else
|
||||
Notify(src, 'Not Enough Money', 'error')
|
||||
end
|
||||
else
|
||||
print("TGIANN Inventory not available but configured to be used!")
|
||||
Notify(src, 'System Error', 'error')
|
||||
end
|
||||
else
|
||||
print("Invalid Config.Inventory setting: " .. Config.Inventory)
|
||||
Notify(src, 'System Error', 'error')
|
||||
end
|
||||
end)
|
||||
|
||||
-- Server-side function to check if player has an item
|
||||
RegisterNetEvent('dynyx_gym:server:CheckItem', function(item)
|
||||
local src = source
|
||||
local hasItem = false
|
||||
|
||||
if Config.Inventory == 'qb' then
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
hasItem = Player.Functions.HasItem(item)
|
||||
elseif Config.Inventory == 'ox' then
|
||||
local count = exports.ox_inventory:GetItem(src, item, nil, true)
|
||||
hasItem = count > 0
|
||||
elseif Config.Inventory == 'tgiann' then
|
||||
if isTGIANNAvailable() then
|
||||
hasItem = exports["tgiann-inventory"]:HasItem(src, item, 1)
|
||||
else
|
||||
print("TGIANN Inventory not available but configured to be used!")
|
||||
end
|
||||
end
|
||||
|
||||
TriggerClientEvent('dynyx_gym:client:ItemCheckResult', src, hasItem)
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue