diff --git a/client/bridge/esx.lua b/client/bridge/esx.lua index e0d5dec..a768942 100644 --- a/client/bridge/esx.lua +++ b/client/bridge/esx.lua @@ -30,6 +30,9 @@ GetPlayerData = function() if MSK.Bridge.Inventory == 'ox_inventory' then self.inventory = exports.ox_inventory:GetPlayerItems() self.loadout = self.inventory + elseif MSK.Bridge.Inventory == 'qs-inventory' then + self.inventory = exports['qs-inventory']:getUserInventory() + self.loadout = self.inventory end self.Notification = function(title, message, typ, duration) diff --git a/client/bridge/qbcore.lua b/client/bridge/qbcore.lua index cd209bd..c0f8990 100644 --- a/client/bridge/qbcore.lua +++ b/client/bridge/qbcore.lua @@ -28,6 +28,9 @@ GetPlayerData = function() if MSK.Bridge.Inventory == 'ox_inventory' then self.inventory = exports.ox_inventory:GetPlayerItems() self.loadout = self.inventory + elseif MSK.Bridge.Inventory == 'qs-inventory' then + self.inventory = exports['qs-inventory']:getUserInventory() + self.loadout = self.inventory end self.accounts = { diff --git a/client/main.lua b/client/main.lua index bb8286f..fd250d5 100644 --- a/client/main.lua +++ b/client/main.lua @@ -9,13 +9,6 @@ MSK.Bridge.Framework.Events = { onPlayerDeath = 'msk_core:onPlayerDeath', } -MSK.Bridge.Inventory = Config.Inventory -if GetResourceState('ox_inventory') ~= 'missing' then - MSK.Bridge.Inventory = 'ox_inventory' -end - -MSK.Bridge.isPlayerLoaded = false - if Config.Framework == 'AUTO' then if GetResourceState('es_extended') ~= 'missing' then ESX = exports["es_extended"]:getSharedObject() @@ -36,6 +29,15 @@ elseif Config.Framework == 'QBCore' then MSK.Bridge.Framework.Core = QBCore end +MSK.Bridge.Inventory = Config.Inventory +if GetResourceState('ox_inventory') ~= 'missing' then + MSK.Bridge.Inventory = 'ox_inventory' +elseif GetResourceState('qs-inventory') ~= 'missing' then + MSK.Bridge.Inventory = 'qs-inventory' +end + +MSK.Bridge.isPlayerLoaded = false + if MSK.Bridge.Framework.Type == 'ESX' then RegisterNetEvent('esx:setPlayerData', function(key, val) TriggerEvent(MSK.Bridge.Framework.Events.setPlayerData, MSK.Bridge.Player) diff --git a/config.lua b/config.lua index f8d2601..f0134c6 100644 --- a/config.lua +++ b/config.lua @@ -7,7 +7,7 @@ Config.VersionChecker = true -- AUTO will search for your framework Config.Framework = 'AUTO' --- Supported Inventories: default, custom, ox_inventory +-- Supported Inventories: default, custom, ox_inventory, qs-inventory -- Set to 'custom' if you use another inventory -- You can add your own inventory in: server/inventories/custom.lua Config.Inventory = 'default' diff --git a/fxmanifest.lua b/fxmanifest.lua index a68423e..546b9f9 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ games { 'gta5' } author 'Musiker15 - MSK Scripts' name 'msk_core' description 'Functions for MSK Scripts' -version '2.4.5' +version '2.4.6' lua54 'yes' diff --git a/html/css/notify.css b/html/css/notify.css index 0140520..967c9c0 100644 --- a/html/css/notify.css +++ b/html/css/notify.css @@ -20,7 +20,7 @@ rgba(56, 56, 56, 0.4), 1.0vh, rgba(56, 56, 56, 0.4) 2.0vh ); - background-color:rgb(0, 0, 0); + background-color:rgba(0, 0, 0, 0); border-radius:0.6vh; box-shadow:0vh 0vh 2vh 0vh rgba(0, 0, 0, 0.8) inset; } diff --git a/server/bridge/esx.lua b/server/bridge/esx.lua index 98b7e54..502bb0a 100644 --- a/server/bridge/esx.lua +++ b/server/bridge/esx.lua @@ -44,9 +44,7 @@ local GetPlayerData = function(Player) return nil end - if MSK.Bridge.Inventory == 'ox_inventory' then - Player = FunctionOverride(Player) - elseif MSK.Bridge.Inventory == 'custom' then + if MSK.Bridge.Inventory ~= 'default' then Player = FunctionOverride(Player) end diff --git a/server/bridge/qbcore.lua b/server/bridge/qbcore.lua index 4ce1fd4..4faec38 100644 --- a/server/bridge/qbcore.lua +++ b/server/bridge/qbcore.lua @@ -53,9 +53,7 @@ GetPlayerData = function(Player) return Player.accounts[account:lower()] end - if MSK.Bridge.Inventory == 'ox_inventory' then - Player = FunctionOverride(Player) - elseif MSK.Bridge.Inventory == 'custom' then + if MSK.Bridge.Inventory ~= 'default' then Player = FunctionOverride(Player) end diff --git a/server/inventories/qs-inventory.lua b/server/inventories/qs-inventory.lua new file mode 100644 index 0000000..8ace84d --- /dev/null +++ b/server/inventories/qs-inventory.lua @@ -0,0 +1,61 @@ +if MSK.Bridge.Inventory ~= 'qs-inventory' then return end + +FunctionOverride = function(Player) + if GetResourceState('qs-inventory') ~= 'started' then return Player end + local playerId = MSK.GetServerId(Player) + Player.inventory = exports['qs-inventory']:GetInventory(playerId) + Player.loadout = Player.inventory + + Player.GetInventory = function() + return Player.inventory + end + + Player.AddItem = function(item, count, metadata, slot) + exports['qs-inventory']:AddItem(playerId, item, count or 1, slot, metadata) + end + + Player.RemoveItem = function(item, count, metadata, slot) + exports['qs-inventory']:RemoveItem(playerId, item, count or 1, slot, metadata) + end + + Player.HasItem = function(itemName, metadata) + local item = exports['qs-inventory']:GetItemByName(playerId, itemName) + if not item then item = {amount = 0} end + item.count = item.amount + return item + end + + Player.AddMoney = function(accountName, money) + exports['qs-inventory']:AddItem(playerId, accountName, money) + end + + Player.RemoveMoney = function(accountName, money) + exports['qs-inventory']:RemoveItem(playerId, accountName, money) + end + + Player.AddWeapon = function(weapon, count, metadata, slot) + exports['qs-inventory']:GiveWeaponToPlayer(playerId, weapon, count) + end + + Player.RemoveWeapon = function(weapon, count, metadata, slot) + exports['qs-inventory']:RemoveItem(playerId, weapon, count or 1, slot, metadata) + end + + Player.HasWeapon = function(weapon, metadata) + return exports.ox_inventory:GetItem(playerId, weapon, metadata) + end + + Player.CanSwapItem = function(firstItem, firstItemCount, secondItem, secondItemCount) + return true + end + + Player.CanCarryItem = function(name, count, metadata) + return exports['qs-inventory']:CanCarryItem(playerId, name, count) + end + + Player.SetMaxWeight = function(maxWeight) + -- No export found for that + end + + return Player +end \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index fdbe0c9..8a42d55 100644 --- a/server/main.lua +++ b/server/main.lua @@ -8,20 +8,17 @@ MSK.Bridge.Framework.Events = { setJob = 'msk_core:setJob', } -MSK.Bridge.Inventory = Config.Inventory -if GetResourceState('ox_inventory') ~= 'missing' then - MSK.Bridge.Inventory = 'ox_inventory' -end - if Config.Framework == 'AUTO' then if GetResourceState('es_extended') ~= 'missing' then ESX = exports["es_extended"]:getSharedObject() MSK.Bridge.Framework.Type = 'ESX' MSK.Bridge.Framework.Core = ESX + print(('[^2%s^0] [^4Info^0] Framework ^3ESX^0 found'):format(GetCurrentResourceName())) elseif GetResourceState('qb-core') ~= 'missing' then QBCore = exports['qb-core']:GetCoreObject() MSK.Bridge.Framework.Type = 'QBCore' MSK.Bridge.Framework.Core = QBCore + print(('[^2%s^0] [^4Info^0] Framework ^3QBCore^0 found'):format(GetCurrentResourceName())) end elseif Config.Framework == 'ESX' then ESX = exports["es_extended"]:getSharedObject() @@ -33,6 +30,15 @@ elseif Config.Framework == 'QBCore' then MSK.Bridge.Framework.Core = QBCore end +MSK.Bridge.Inventory = Config.Inventory +if GetResourceState('ox_inventory') ~= 'missing' then + MSK.Bridge.Inventory = 'ox_inventory' + print(('[^2%s^0] [^4Info^0] Inventory ^3ox_inventory^0 found'):format(GetCurrentResourceName())) +elseif GetResourceState('qs-inventory') ~= 'missing' then + MSK.Bridge.Inventory = 'qs-inventory' + print(('[^2%s^0] [^4Info^0] Inventory ^3qs-inventory^0 found'):format(GetCurrentResourceName())) +end + if MSK.Bridge.Framework.Type == 'ESX' then RegisterNetEvent('esx:playerLoaded', function(playerId, xPlayer, isNew) TriggerEvent(MSK.Bridge.Framework.Events.playerLoaded, playerId) diff --git a/server/versionchecker.lua b/server/versionchecker.lua index 9b74fb2..0dcc934 100644 --- a/server/versionchecker.lua +++ b/server/versionchecker.lua @@ -5,13 +5,13 @@ local FILE = "Lib.json" local RESOURCE_NAME = "msk_core" local NAME_COLORED = "[^2"..GetCurrentResourceName().."^0]" local GITHUB_URL = "https://raw.githubusercontent.com/%s/%s/main/%s" -local DOWNLOAD_URL = "https://github.com/MSK-Scripts/msk_core/releases/tag/v%s" +local DOWNLOAD_URL = "https://github.com/MSK-Scripts/%s/releases/tag/v%s" local RENAME_WARNING = NAME_COLORED .. "^3 [WARNING] This resource should not be renamed! This can lead to errors. Please rename it to^0 %s" -local CHECK_FAILED = NAME_COLORED .. "^1 [ERROR] Version Check failed! Http Error: %s^0\n^3Please update to the latest version.^0" +local CHECK_FAILED = NAME_COLORED .. "^1 [ERROR] Version Check failed! Http Error: %s^0 - ^3Please update to the latest version.^0" local BETA_VERSION = NAME_COLORED .. "^3 [WARNING] Beta version detected^0 - ^5Current Version:^0 %s - ^5Latest Version:^0 %s" local UP_TO_DATE = NAME_COLORED .. "^2 ✓ Resource is Up to Date^0 - ^5Current Version:^2 %s ^0" -local NEW_VERSION = NAME_COLORED .. "^3 [Update Available] ^5Current Version:^0 %s - ^5Latest Version:^0 %s\n^5Download:^4 %s ^0" +local NEW_VERSION = NAME_COLORED .. "^3 [Update Available] ^5Current Version:^0 %s - ^5Latest Version:^0 %s\n" .. NAME_COLORED .. "^5 Download:^4 %s ^0" local CheckResourceName = function() if GetCurrentResourceName() ~= RESOURCE_NAME then @@ -49,7 +49,7 @@ local CheckVersionCallback = function(status, response, header) end if current[i] < latest[i] then - print(NEW_VERSION:format(currentVersion, latestVersion, DOWNLOAD_URL:format(latestVersion))) + print(NEW_VERSION:format(currentVersion, latestVersion, DOWNLOAD_URL:format(RESOURCE_NAME, latestVersion))) for i = 1, #response do if response[i].version == currentVersion then break end diff --git a/shared/shared.lua b/shared/shared.lua index 36b248f..00e19de 100644 --- a/shared/shared.lua +++ b/shared/shared.lua @@ -97,7 +97,7 @@ end exports('Comma', MSK.Comma) local Timeout = 0 -MSK.SetTimeout = function(ms, cb) +MSK.SetTimeout = function(ms, cb, data) assert(ms and tonumber(ms), 'Parameter "ms" has to be a number on function MSK.SetTimeout') local requestId = Timeout + 1 @@ -107,7 +107,7 @@ MSK.SetTimeout = function(ms, cb) return end - cb() + cb(data) end) Timeout = requestId