Skip to content

Commit

Permalink
feat: initial support for ox_core (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 26, 2024
1 parent ca9d1ac commit b04f812
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ Discord: https://discord.illenium.dev

- qb-core
- ESX
- ox_core

## Dependencies

- [qb-core](https://github.com/qbcore-framework/qb-core) (Latest) (Only for qb-core based servers)
- [es_extended](https://github.com/esx-framework/esx-legacy) (Latest) (Only for ESX based servers)
- [ox_core](https://github.com/overextended/ox_core) (experimental) (Only for ox_core based servers)
- [ox_lib](https://github.com/overextended/ox_lib)
- [qb-target](https://github.com/BerkieBb/qb-target) (Optional) (Only for qb-core based servers)

Expand Down
42 changes: 42 additions & 0 deletions client/framework/ox/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
if not Framework.Ox() then return end

local Ox = require '@ox_core.lib.init'
local player = Ox.GetPlayer()

RegisterNetEvent("ox:setActiveCharacter", function(character)
if character.isNew then
return InitializeCharacter(Framework.GetGender(true))
end

InitAppearance()
end)

---@todo groups
-- RegisterNetEvent("ox:setGroup", function(group, grade)
-- end)

function Framework.GetPlayerGender()
return player.get('gender') == 'female' and 'Female' or 'Male'
end

function Framework.UpdatePlayerData() end

function Framework.HasTracker() return false end

function Framework.CheckPlayerMeta()
return LocalPlayer.state.isDead or IsPedCuffed(cache.ped)
end

function Framework.IsPlayerAllowed(charId)
return charId == player.charId
end

function Framework.GetRankInputValues() end

function Framework.GetJobGrade() end

function Framework.GetGangGrade() end

function Framework.CachePed() end

function Framework.RestorePlayerArmour() end
2 changes: 2 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ client_scripts {
"client/framework/qb/migrate.lua",
"client/framework/esx/compatibility.lua",
"client/framework/esx/main.lua",
"client/framework/ox/main.lua",
"client/target/target.lua",
"client/target/qb.lua",
"client/target/ox.lua",
Expand Down Expand Up @@ -56,6 +57,7 @@ server_scripts {
"server/framework/esx/migrate.lua",
"server/framework/esx/callbacks.lua",
"server/framework/esx/management.lua",
"server/framework/ox/main.lua",
"server/util.lua",
"server/server.lua",
"server/permissions.lua"
Expand Down
36 changes: 36 additions & 0 deletions server/framework/ox/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if not Framework.Ox() then return end

local Ox = require '@ox_core.lib.init'

function Framework.GetPlayerID(playerId)
return Ox.GetPlayer(playerId).charId
end

function Framework.HasMoney(playerId, item, amount)
return exports.ox_inventory:GetItemCount(playerId, item) >= amount
end

function Framework.RemoveMoney(playerId, type, amount)
return exports.ox_inventory:RemoveItem(playerId, type, amount)
end

function Framework.GetJob()
return ---@todo
end

function Framework.GetGang()
return ---@todo
end

function Framework.SaveAppearance(appearance, charId)
Database.PlayerSkins.UpdateActiveField(charId, 0)
Database.PlayerSkins.DeleteByModel(charId, appearance.model)
Database.PlayerSkins.Add(charId, appearance.model, json.encode(appearance), 1)
end

function Framework.GetAppearance(charId, model)
local result = Database.PlayerSkins.GetByCitizenID(charId, model)
if result then
return json.decode(result)
end
end
4 changes: 4 additions & 0 deletions shared/framework/framework.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ end
function Framework.QBCore()
return GetResourceState("qb-core") ~= "missing"
end

function Framework.Ox()
return GetResourceState("ox_core") ~= "missing"
end

0 comments on commit b04f812

Please sign in to comment.