Skip to content

Commit

Permalink
Inventory Update
Browse files Browse the repository at this point in the history
  • Loading branch information
GhzGarage committed May 20, 2024
1 parent d2b8e37 commit 8770076
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
30 changes: 15 additions & 15 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
-- Variables
local QBCore = exports['qb-core']:GetCoreObject()
local requiredItemsShowed = false
local requiredItems = {[1] = {name = QBCore.Shared.Items["cryptostick"]["name"], image = QBCore.Shared.Items["cryptostick"]["image"]}}
local requiredItems = { [1] = { name = QBCore.Shared.Items['cryptostick']['name'], image = QBCore.Shared.Items['cryptostick']['image'] } }

-- Functions

local function DrawText3Ds(coords, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
BeginTextCommandDisplayText("STRING")
SetTextCentre(true)
AddTextComponentSubstringPlayerName(text)
SetDrawOrigin(coords.x, coords.y, coords.z, 0)
EndTextCommandDisplayText(0.0, 0.0)
local factor = (string.len(text)) / 370
DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
BeginTextCommandDisplayText('STRING')
SetTextCentre(true)
AddTextComponentSubstringPlayerName(text)
SetDrawOrigin(coords.x, coords.y, coords.z, 0)
EndTextCommandDisplayText(0.0, 0.0)
local factor = (string.len(text)) / 370
DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
end

local function ExchangeSuccess()
Expand Down Expand Up @@ -64,7 +64,7 @@ CreateThread(function()
DrawText3Ds(Crypto.Exchange.coords, Lang:t('text.enter_usb'))
if not requiredItemsShowed then
requiredItemsShowed = true
TriggerEvent('inventory:client:requiredItems', requiredItems, true)
TriggerEvent('qb-inventory:client:requiredItems', requiredItems, true)
end

if IsControlJustPressed(0, 38) then
Expand All @@ -82,12 +82,12 @@ CreateThread(function()
end)
end
else
DrawText3Ds(Crypto.Exchange.coords, Lang:t('text.system_is_rebooting', {rebootInfoPercentage = Crypto.Exchange.RebootInfo.percentage}) )
DrawText3Ds(Crypto.Exchange.coords, Lang:t('text.system_is_rebooting', { rebootInfoPercentage = Crypto.Exchange.RebootInfo.percentage }))
end
else
if requiredItemsShowed then
requiredItemsShowed = false
TriggerEvent('inventory:client:requiredItems', requiredItems, false)
TriggerEvent('qb-inventory:client:requiredItems', requiredItems, false)
end
end
end
Expand Down
13 changes: 5 additions & 8 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ RegisterServerEvent('qb-crypto:server:ExchangeFail', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local ItemData = Player.Functions.GetItemByName('cryptostick')

if ItemData ~= nil then
Player.Functions.RemoveItem('cryptostick', 1)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['cryptostick'], 'remove')
exports['qb-inventory']:RemoveItem(src, 'cryptostick', 1, false, 'qb-crypto:server:ExchangeFail')
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items['cryptostick'], 'remove')
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.cryptostick_malfunctioned'), 'error')
end
end)
Expand All @@ -217,19 +216,17 @@ RegisterServerEvent('qb-crypto:server:ExchangeSuccess', function(LuckChance)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
local ItemData = Player.Functions.GetItemByName('cryptostick')

if ItemData ~= nil then
local LuckyNumber = math.random(1, 10)
local DeelNumber = 1000000
local Amount = (math.random(611111, 1599999) / DeelNumber)
if LuckChance == LuckyNumber then
Amount = (math.random(1599999, 2599999) / DeelNumber)
end

Player.Functions.RemoveItem('cryptostick', 1)
Player.Functions.AddMoney('crypto', Amount, 'crypto stick exchange')
exports['qb-inventory']:RemoveItem(src, 'cryptostick', 1, false, 'qb-crypto:server:ExchangeSuccess')
Player.Functions.AddMoney('crypto', Amount, 'qb-crypto:server:ExchangeSuccess')
TriggerClientEvent('QBCore:Notify', src, Lang:t('success.you_have_exchanged_your_cryptostick_for', { amount = Amount }), 'success', 3500)
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items['cryptostick'], 'remove')
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items['cryptostick'], 'remove')
TriggerClientEvent('qb-phone:client:AddTransaction', src, Player, {}, Lang:t('credit.there_are_amount_credited', { amount = Amount }), 'Credit')
end
end)
Expand Down

0 comments on commit 8770076

Please sign in to comment.