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.

  1. Navigate to es_extended/server/functions.lua

  2. Find function Core.SavePlayer

  3. 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
  1. Find function Core.SavePlayers

  2. Replace the function with the one below or make the changes highlighted on the code below

Last updated

Was this helpful?