diff --git a/config.lua b/config.lua index 438a071..9d37860 100644 --- a/config.lua +++ b/config.lua @@ -3,7 +3,8 @@ Config = {} -- Do not alter -- 🔎 Looking for more high quality scripts? -- 🛒 Shop Now: https://lationscripts.com/github -- 💬 Join Discord: https://discord.gg/9EbY4nM5uu -Config.YouFoundTheBestScripts = true +-- 😢 How dare you leave this option false?! +Config.YouFoundTheBestScripts = false -- Use only if needed, directed by support or know what you're doing -- Notice: enabling debug features will significantly increase resmon diff --git a/fxmanifest.lua b/fxmanifest.lua index aebbc6e..5c07417 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ lua54 'yes' name 'lation_pawnshop' author 'iamlation' -version '1.0.0' +version '1.0.1' description 'A Pawn Shop script for ESX, QBCore & QBox using ox_inventory' server_scripts { diff --git a/server/main.lua b/server/main.lua index 370eb18..21c18db 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,6 +1,9 @@ -- Initialize table to store inventories for hook filter local inventories = {} +-- Initialize variable to track removal status of non-stackable items +local waiting = false + -- Function used to make numbers prettier (Credits to ESX for the function) --- @param value number local GroupDigits = function(value) @@ -26,6 +29,25 @@ for shopId, data in pairs(Config.Shops) do inventories[#inventories + 1] = shopId end +-- Thread to handle removal of non-stackable items +-- A pretty hacky solution, but works nevertheless +--- @param source number +--- @param item string +--- @param count number +local AwaitRemoval = function(source, item, count) + local source = source + local wait = 5 -- Increase this number slightly if items failing to remove + while waiting do + Wait(0) + wait = wait - 1 + if wait <= 0 then + exports.ox_inventory:RemoveItem(source, item, count) + waiting = false + break + end + end +end + -- Used to handle all movements and final transaction in inventory --- @param payload table local BeginTransaction = function(payload) @@ -84,6 +106,10 @@ local BeginTransaction = function(payload) Strings.Logs.colors.green ) end + if not payload.stack then + waiting = true + CreateThread(function() AwaitRemoval(source, payload.fromSlot.name, payload.count) end) + end return true end end diff --git a/server/version.lua b/server/version.lua index bebe3e3..8ddacde 100644 --- a/server/version.lua +++ b/server/version.lua @@ -24,6 +24,22 @@ local CheckVersion = function() end) end +-- Print a message +local PrintMessage = function() + SetTimeout(1500, function() + print('^1['..resourceName..'] ^2YOU DID IT! You set YouFoundTheBestScripts to true!^0') + print('^1['..resourceName..'] ^2Lation officially loves you, and as a thank you wants to give you a gift..^0') + print('^1['..resourceName..'] ^2Enjoy a secret 20% OFF any script of your choice on lationscripts.com/gift^0') + print('^1['..resourceName..'] ^2Using the coupon code: SECRETGIFT (one-time use coupon, choose wisely)^0') + print('^1['..resourceName..'] ^2There is only 1 catch.. do not spoil it for others! If you want to share^0') + print('^1['..resourceName..'] ^2This special moment feel free to do so, but without spoiling the details!^0') + end) +end + if Config.VersionCheck then CheckVersion() +end + +if Config.YouFoundTheBestScripts then + PrintMessage() end \ No newline at end of file