Skip to content

Commit

Permalink
Merge pull request #1290 from Arctos2win/loadESXPlayer
Browse files Browse the repository at this point in the history
REwrite LoadESXPlayer
  • Loading branch information
Gellipapa authored Jan 24, 2024
2 parents 1f68b2b + a197ead commit 1d7572f
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 240 deletions.
4 changes: 1 addition & 3 deletions [core]/es_extended/client/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ exports('getSharedObject', function()
return ESX
end)

if GetResourceState('ox_inventory') ~= 'missing' then
Config.OxInventory = true
end
Config.OxInventory = GetResourceState('ox_inventory'):find('start') and true

AddEventHandler("esx:getSharedObject", function()
local Invoke = GetInvokingResource()
Expand Down
4 changes: 3 additions & 1 deletion [core]/es_extended/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin)
ESX.PlayerLoaded = true

while ESX.PlayerData.ped == nil do Wait(20) end


while not HasCollisionLoadedAroundEntity(ESX.PlayerData.ped) do Wait(0) end

if Config.EnablePVP then
SetCanAttackFriendly(ESX.PlayerData.ped, true, false)
NetworkSetFriendlyFireOption(true)
Expand Down
15 changes: 10 additions & 5 deletions [core]/es_extended/server/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Core.playersByIdentifier = {}

Core.vehicleTypesByModel = {}


RegisterNetEvent('esx:onPlayerSpawn', function()
ESX.Players[source].spawned = true
end)

AddEventHandler("esx:getSharedObject", function()
local Invoke = GetInvokingResource()
print(("[^1ERROR^7] Resource ^5%s^7 Used the ^5getSharedObject^7 Event, this event ^1no longer exists!^7 Visit https://documentation.esx-framework.org/tutorials/tutorials-esx/sharedevent for how to fix!"):format(Invoke))
Expand All @@ -23,11 +28,11 @@ exports('getSharedObject', function()
return ESX
end)

if GetResourceState('ox_inventory') ~= 'missing' then
Config.OxInventory = true
Config.PlayerFunctionOverride = 'OxInventory'
SetConvarReplicated('inventory:framework', 'esx')
SetConvarReplicated('inventory:weight', Config.MaxWeight * 1000)
if GetResourceState('ox_inventory'):find('start') then
Config.OxInventory = true
Config.PlayerFunctionOverride = 'OxInventory'
SetConvarReplicated('inventory:framework', 'esx')
SetConvarReplicated('inventory:weight', Config.MaxWeight * 1000)
end

local function StartDBSync()
Expand Down
4 changes: 4 additions & 0 deletions [core]/es_extended/server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ local function updateHealthAndArmorInMetadata(xPlayer)
end

function Core.SavePlayer(xPlayer, cb)
if not xPlayer.spawned then
return cb and cb()
end

updateHealthAndArmorInMetadata(xPlayer)
local parameters <const> = {
json.encode(xPlayer.getAccounts(true)),
Expand Down
Loading

0 comments on commit 1d7572f

Please sign in to comment.