Skip to content

Commit

Permalink
Update v2.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Sep 21, 2024
1 parent eba5d64 commit b0a0b33
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 27 deletions.
3 changes: 3 additions & 0 deletions client/bridge/esx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions client/bridge/qbcore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
16 changes: 9 additions & 7 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion html/css/notify.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions server/bridge/esx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions server/bridge/qbcore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
61 changes: 61 additions & 0 deletions server/inventories/qs-inventory.lua
Original file line number Diff line number Diff line change
@@ -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
16 changes: 11 additions & 5 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions server/versionchecker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions shared/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -107,7 +107,7 @@ MSK.SetTimeout = function(ms, cb)
return
end

cb()
cb(data)
end)

Timeout = requestId
Expand Down

0 comments on commit b0a0b33

Please sign in to comment.