mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
refactor(es_extended): Cleanup messy files
This commit is contained in:
@@ -1,8 +1,30 @@
|
||||
exports("getSharedObject", function()
|
||||
return ESX
|
||||
end)
|
||||
Core = {}
|
||||
ESX.PlayerData = {}
|
||||
ESX.PlayerLoaded = false
|
||||
Core.Input = {}
|
||||
ESX.UI = {}
|
||||
ESX.UI.Menu = {}
|
||||
ESX.UI.Menu.RegisteredTypes = {}
|
||||
ESX.UI.Menu.Opened = {}
|
||||
|
||||
AddEventHandler("esx:getSharedObject", function()
|
||||
local Invoke = GetInvokingResource()
|
||||
error(("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))
|
||||
ESX.Game = {}
|
||||
ESX.Game.Utils = {}
|
||||
|
||||
ESX.Scaleform = {}
|
||||
ESX.Scaleform.Utils = {}
|
||||
|
||||
ESX.Streaming = {}
|
||||
|
||||
CreateThread(function()
|
||||
while not Config.Multichar do
|
||||
Wait(100)
|
||||
|
||||
if NetworkIsPlayerActive(PlayerId()) then
|
||||
exports.spawnmanager:setAutoSpawn(false)
|
||||
DoScreenFadeOut(0)
|
||||
Wait(500)
|
||||
TriggerServerEvent("esx:onPlayerJoined")
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
ESX = {}
|
||||
Core = {}
|
||||
ESX.PlayerData = {}
|
||||
ESX.PlayerLoaded = false
|
||||
Core.Input = {}
|
||||
ESX.UI = {}
|
||||
ESX.UI.Menu = {}
|
||||
ESX.UI.Menu.RegisteredTypes = {}
|
||||
ESX.UI.Menu.Opened = {}
|
||||
|
||||
ESX.Game = {}
|
||||
ESX.Game.Utils = {}
|
||||
|
||||
ESX.Scaleform = {}
|
||||
ESX.Scaleform.Utils = {}
|
||||
|
||||
ESX.Streaming = {}
|
||||
|
||||
function ESX.IsPlayerLoaded()
|
||||
return ESX.PlayerLoaded
|
||||
end
|
||||
@@ -68,6 +50,48 @@ function ESX.SetPlayerData(key, val)
|
||||
end
|
||||
end
|
||||
|
||||
function Core.FreezePlayer(freeze)
|
||||
local player = PlayerId()
|
||||
local ped = PlayerPedId()
|
||||
SetPlayerControl(player, not freeze, 0)
|
||||
|
||||
if freeze then
|
||||
SetEntityCollision(ped, false, false)
|
||||
FreezeEntityPosition(ped, true)
|
||||
else
|
||||
SetEntityCollision(ped, true, true)
|
||||
FreezeEntityPosition(ped, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ESX.SpawnPlayer(skin, coords, cb)
|
||||
local p = promise.new()
|
||||
TriggerEvent("skinchanger:loadSkin", skin, function()
|
||||
p:resolve()
|
||||
end)
|
||||
Citizen.Await(p)
|
||||
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local timer = GetGameTimer()
|
||||
|
||||
Core.FreezePlayer(true)
|
||||
SetEntityCoordsNoOffset(playerPed, coords.x, coords.y, coords.z, false, false, true)
|
||||
SetEntityHeading(playerPed, coords.heading)
|
||||
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
while not HasCollisionLoadedAroundEntity(playerPed) and (GetGameTimer() - timer) < 5000 do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, coords.heading, 0, true)
|
||||
TriggerEvent('playerSpawned', coords)
|
||||
cb()
|
||||
end
|
||||
|
||||
|
||||
function ESX.Progressbar(...)
|
||||
return IsResourceFound('esx_progressbar') and exports['esx_progressbar']:Progressbar(...)
|
||||
end
|
||||
|
||||
@@ -1,63 +1,9 @@
|
||||
local pickups = {}
|
||||
|
||||
CreateThread(function()
|
||||
while not Config.Multichar do
|
||||
Wait(100)
|
||||
|
||||
if NetworkIsPlayerActive(PlayerId()) then
|
||||
exports.spawnmanager:setAutoSpawn(false)
|
||||
DoScreenFadeOut(0)
|
||||
Wait(500)
|
||||
TriggerServerEvent("esx:onPlayerJoined")
|
||||
break
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("esx:requestModel", function(model)
|
||||
ESX.Streaming.RequestModel(model)
|
||||
end)
|
||||
|
||||
local function freezePlayer(freeze)
|
||||
local player = PlayerId()
|
||||
local ped = PlayerPedId()
|
||||
SetPlayerControl(player, not freeze, 0)
|
||||
|
||||
if freeze then
|
||||
SetEntityCollision(ped, false, false)
|
||||
FreezeEntityPosition(ped, true)
|
||||
else
|
||||
SetEntityCollision(ped, true, true)
|
||||
FreezeEntityPosition(ped, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function ESX.SpawnPlayer(skin, coords, cb)
|
||||
local p = promise.new()
|
||||
TriggerEvent("skinchanger:loadSkin", skin, function()
|
||||
p:resolve()
|
||||
end)
|
||||
Citizen.Await(p)
|
||||
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
local timer = GetGameTimer()
|
||||
|
||||
freezePlayer(true)
|
||||
SetEntityCoordsNoOffset(playerPed, coords.x, coords.y, coords.z, false, false, true)
|
||||
SetEntityHeading(playerPed, coords.heading)
|
||||
|
||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||
while not HasCollisionLoadedAroundEntity(playerPed) and (GetGameTimer() - timer) < 5000 do
|
||||
Wait(0)
|
||||
end
|
||||
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, coords.heading, 0, true)
|
||||
TriggerEvent('playerSpawned', coords)
|
||||
cb()
|
||||
end
|
||||
|
||||
local function EnablePvP()
|
||||
if Config.EnablePVP then
|
||||
@@ -237,7 +183,7 @@ AddEventHandler("esx:playerLoaded", function(xPlayer, _, skin)
|
||||
ClearPedTasksImmediately(ESX.PlayerData.ped)
|
||||
|
||||
if not Config.Multichar then
|
||||
freezePlayer(false)
|
||||
Core.FreezePlayer(false)
|
||||
end
|
||||
|
||||
if IsScreenFadedOut() then
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
ESX = {}
|
||||
|
||||
exports("getSharedObject", function()
|
||||
return ESX
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:getSharedObject", function()
|
||||
local Invoke = GetInvokingResource()
|
||||
error(("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))
|
||||
end)
|
||||
@@ -11,6 +11,10 @@ shared_scripts {
|
||||
|
||||
'config.lua',
|
||||
'config.weapons.lua',
|
||||
|
||||
'common/main.lua',
|
||||
'common/functions.lua',
|
||||
'common/modules/*.lua',
|
||||
}
|
||||
|
||||
server_scripts {
|
||||
@@ -27,24 +31,19 @@ server_scripts {
|
||||
'server/main.lua',
|
||||
'server/commands.lua',
|
||||
|
||||
'common/modules/*.lua',
|
||||
'common/functions.lua',
|
||||
'server/modules/actions.lua',
|
||||
'server/modules/npwd.lua',
|
||||
'server/modules/createJob.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client/common.lua',
|
||||
'client/common.lua',
|
||||
'client/functions.lua',
|
||||
'client/wrapper.lua',
|
||||
'client/modules/callback.lua',
|
||||
|
||||
'client/main.lua',
|
||||
|
||||
'common/modules/*.lua',
|
||||
'common/functions.lua',
|
||||
|
||||
'client/modules/actions.lua',
|
||||
'client/modules/death.lua',
|
||||
'client/modules/npwd.lua',
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
ESX = {}
|
||||
ESX.Players = {}
|
||||
ESX.Jobs = {}
|
||||
ESX.JobsPlayerCount = {}
|
||||
@@ -18,15 +17,6 @@ RegisterNetEvent("esx:onPlayerSpawn", function()
|
||||
ESX.Players[source].spawned = true
|
||||
end)
|
||||
|
||||
AddEventHandler("esx:getSharedObject", function()
|
||||
local Invoke = GetInvokingResource()
|
||||
error(("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))
|
||||
end)
|
||||
|
||||
exports("getSharedObject", function()
|
||||
return ESX
|
||||
end)
|
||||
|
||||
if Config.OxInventory then
|
||||
Config.PlayerFunctionOverride = "OxInventory"
|
||||
SetConvarReplicated("inventory:framework", "esx")
|
||||
|
||||
Reference in New Issue
Block a user