Interior Stuck Prevention
If a player leaves the server in the interiors of the underground garage, he will get stuck in it which will cause him to have to contact the administration to teleport him outside, with this option you can avoid such problems by writing the player coordinates when he leaves the server while in the interiors.
The code below is from ESX 1.10.7!
The function code may vary depending on your version of es_extended.
If the code is different, do not copy the code below, make your own changes to the lines that was marked -- MODIFIED
, to avoid problems.
Navigate to es_extended/server/functions.lua
Find function
Core.SavePlayer
Replace the function with the one below or make the changes highlighted on the code below
function Core.SavePlayer(xPlayer, cb)
if not xPlayer.spawned then
return cb and cb()
end
local garageInterior, garageCoords = exports['vms_garagesv2']:isInInterior(xPlayer.source); -- MODIFIED
updateHealthAndArmorInMetadata(xPlayer)
local parameters <const> = {
json.encode(xPlayer.getAccounts(true)),
xPlayer.job.name,
xPlayer.job.grade,
xPlayer.group,
json.encode(garageInterior and garageCoords or xPlayer.getCoords(false, true)), -- MODIFIED
json.encode(xPlayer.getInventory(true)),
json.encode(xPlayer.getLoadout(true)),
json.encode(xPlayer.getMeta()),
xPlayer.identifier,
}
MySQL.prepare(
"UPDATE `users` SET `accounts` = ?, `job` = ?, `job_grade` = ?, `group` = ?, `position` = ?, `inventory` = ?, `loadout` = ?, `metadata` = ? WHERE `identifier` = ?",
parameters,
function(affectedRows)
if affectedRows == 1 then
print(('[^2INFO^7] Saved player ^5"%s^7"'):format(xPlayer.name))
TriggerEvent("esx:playerSaved", xPlayer.playerId, xPlayer)
end
if cb then
cb()
end
end
)
end
Find function
Core.SavePlayers
Replace the function with the one below or make the changes highlighted on the code below
function Core.SavePlayers(cb)
local xPlayers <const> = ESX.Players
if not next(xPlayers) then
return
end
local startTime <const> = os.time()
local parameters = {}
for _, xPlayer in pairs(ESX.Players) do
updateHealthAndArmorInMetadata(xPlayer)
local garageInterior, garageCoords = exports['vms_garagesv2']:isInInterior(xPlayer.source); -- MODIFIED
parameters[#parameters + 1] = {
json.encode(xPlayer.getAccounts(true)),
xPlayer.job.name,
xPlayer.job.grade,
xPlayer.group,
json.encode(garageInterior and garageCoords or xPlayer.getCoords()),
json.encode(xPlayer.getInventory(true)),
json.encode(xPlayer.getLoadout(true)),
json.encode(xPlayer.getMeta()),
xPlayer.identifier,
}
end
MySQL.prepare(
"UPDATE `users` SET `accounts` = ?, `job` = ?, `job_grade` = ?, `group` = ?, `position` = ?, `inventory` = ?, `loadout` = ?, `metadata` = ? WHERE `identifier` = ?",
parameters,
function(results)
if not results then
return
end
if type(cb) == "function" then
return cb()
end
print(("[^2INFO^7] Saved ^5%s^7 %s over ^5%s^7 ms"):format(#parameters, #parameters > 1 and "players" or "player", ESX.Math.Round((os.time() - startTime) / 1000000, 2)))
end
)
end
Last updated
Was this helpful?