From 3e967debe4d21fe95bf994f7227481a1b1282b29 Mon Sep 17 00:00:00 2001 From: Lorraxs Date: Wed, 28 Feb 2024 16:16:08 +0700 Subject: [PATCH] add bridge --- client/bridge.lua | 8 ++++++++ fxmanifest.lua | 2 ++ server/bridge.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 client/bridge.lua create mode 100644 server/bridge.lua diff --git a/client/bridge.lua b/client/bridge.lua new file mode 100644 index 0000000..8bf342d --- /dev/null +++ b/client/bridge.lua @@ -0,0 +1,8 @@ +function GetJob() + if Config.Framework == 'ProjectStarboy' then + return Framework.PlayerData.job + end + if Config.Framework == "esx" then + return Framework.GetPlayerData().job + end +end diff --git a/fxmanifest.lua b/fxmanifest.lua index 2466d78..4e35fad 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -35,11 +35,13 @@ shared_scripts { client_scripts { "client/utils.lua", + "client/bridge.lua", "client/classes/*", "client/impl/*" } server_script { "server/utils.lua", + "server/bridge.lua", '@oxmysql/lib/MySQL.lua', "server/classes/*", "server/impl/*" diff --git a/server/bridge.lua b/server/bridge.lua new file mode 100644 index 0000000..11a8c2d --- /dev/null +++ b/server/bridge.lua @@ -0,0 +1,43 @@ +function HasItem(player, itemName, amount) + if Config.Framework == 'ProjectStarboy' then + return player.hasItem({ + itemName = itemName, + amount = amount + }) + elseif Config.Framework == 'esx' then + local xItem = player.hasItem(itemName) + if not xItem then return false end + return xItem.count >= amount + end +end + +function RemoveItem(player, itemName, amount) + if Config.Framework == 'ProjectStarboy' then + return player.removeInventoryItem({ + itemName = itemName, + amount = amount + }) + elseif Config.Framework == 'esx' then + return player.removeInventoryItem(itemName, amount) + end +end + +function AddMoney(player, amount) + if Config.Framework == 'ProjectStarboy' then + return player.addAccountMoney("money", amount) + elseif Config.Framework == 'esx' then + return player.addMoney(amount) + end +end + +function GetPlayerFromId(playerSrc) + if Config.Framework == 'ProjectStarboy' then + return Framework.GetPlayerFromSource(playerSrc) + elseif Config.Framework == 'esx' then + return Framework.GetPlayerFromId(playerSrc) + end +end + +function ShowNotification(player, msg) + return player.showNotification(msg) +end