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