diff --git a/server-data/resources/[esx]/es_extended/client/main.lua b/server-data/resources/[esx]/es_extended/client/main.lua index 173076843..deff59dd2 100644 --- a/server-data/resources/[esx]/es_extended/client/main.lua +++ b/server-data/resources/[esx]/es_extended/client/main.lua @@ -14,9 +14,7 @@ CreateThread(function() end end) -RegisterNetEvent("esx:requestModel", function(model) - ESX.Streaming.RequestModel(model) -end) +RegisterNetEvent("esx:requestModel", ESX.Streaming.RequestModel) function ESX.SpawnPlayer(skin, coords, cb) local p = promise.new() @@ -212,8 +210,7 @@ AddEventHandler("esx:playerLoaded", function(xPlayer, _, skin) end) -RegisterNetEvent("esx:onPlayerLogout") -AddEventHandler("esx:onPlayerLogout", function() +RegisterNetEvent("esx:onPlayerLogout", function() ESX.PlayerLoaded = false end) @@ -278,7 +275,7 @@ AddStateBagChangeHandler("VehicleProperties", nil, function(bagName, _, value) local netId = bagName:gsub("entity:", "") local vehicle = NetToVeh(tonumber(netId)) - + ESX.Game.SetVehicleProperties(vehicle, value) end) @@ -295,8 +292,7 @@ AddEventHandler("esx:setAccountMoney", function(account) end) if not Config.OxInventory then - RegisterNetEvent("esx:addInventoryItem") - AddEventHandler("esx:addInventoryItem", function(item, count, showNotification) + RegisterNetEvent("esx:addInventoryItem", function(item, count, showNotification) for k, v in ipairs(ESX.PlayerData.inventory) do if v.name == item then ESX.UI.ShowInventoryItemNotification(true, v.label, count - v.count) @@ -310,8 +306,7 @@ if not Config.OxInventory then end end) - RegisterNetEvent("esx:removeInventoryItem") - AddEventHandler("esx:removeInventoryItem", function(item, count, showNotification) + RegisterNetEvent("esx:removeInventoryItem", function(item, count, showNotification) for i = 1, #ESX.PlayerData.inventory do if ESX.PlayerData.inventory[i].name == item then ESX.UI.ShowInventoryItemNotification(false, ESX.PlayerData.inventory[i].label, ESX.PlayerData.inventory[i].count - count) @@ -325,46 +320,38 @@ if not Config.OxInventory then end end) - RegisterNetEvent("esx:addWeapon") - AddEventHandler("esx:addWeapon", function() + RegisterNetEvent("esx:addWeapon", function() print("[^1ERROR^7] event ^5'esx:addWeapon'^7 Has Been Removed. Please use ^5xPlayer.addWeapon^7 Instead!") end) - RegisterNetEvent("esx:addWeaponComponent") - AddEventHandler("esx:addWeaponComponent", function() + RegisterNetEvent("esx:addWeaponComponent", function() print("[^1ERROR^7] event ^5'esx:addWeaponComponent'^7 Has Been Removed. Please use ^5xPlayer.addWeaponComponent^7 Instead!") end) - RegisterNetEvent("esx:setWeaponAmmo") - AddEventHandler("esx:setWeaponAmmo", function() + RegisterNetEvent("esx:setWeaponAmmo", function() print("[^1ERROR^7] event ^5'esx:setWeaponAmmo'^7 Has Been Removed. Please use ^5xPlayer.addWeaponAmmo^7 Instead!") end) - RegisterNetEvent("esx:setWeaponTint") - AddEventHandler("esx:setWeaponTint", function(weapon, weaponTintIndex) + RegisterNetEvent("esx:setWeaponTint", function(weapon, weaponTintIndex) SetPedWeaponTintIndex(ESX.PlayerData.ped, joaat(weapon), weaponTintIndex) end) - RegisterNetEvent("esx:removeWeapon") - AddEventHandler("esx:removeWeapon", function() + RegisterNetEvent("esx:removeWeapon", function() print("[^1ERROR^7] event ^5'esx:removeWeapon'^7 Has Been Removed. Please use ^5xPlayer.removeWeapon^7 Instead!") end) - RegisterNetEvent("esx:removeWeaponComponent") - AddEventHandler("esx:removeWeaponComponent", function(weapon, weaponComponent) + RegisterNetEvent("esx:removeWeaponComponent", function(weapon, weaponComponent) local componentHash = ESX.GetWeaponComponent(weapon, weaponComponent).hash RemoveWeaponComponentFromPed(ESX.PlayerData.ped, joaat(weapon), componentHash) end) end -RegisterNetEvent("esx:setJob") -AddEventHandler("esx:setJob", function(Job) +RegisterNetEvent("esx:setJob", function(Job) ESX.SetPlayerData("job", Job) end) if not Config.OxInventory then - RegisterNetEvent("esx:createPickup") - AddEventHandler("esx:createPickup", function(pickupId, label, coords, itemType, name, components, tintIndex) + RegisterNetEvent("esx:createPickup", function(pickupId, label, coords, itemType, name, components, tintIndex) local function setObjectProperties(object) SetEntityAsMissionEntity(object, true, false) PlaceObjectOnGroundProperly(object) @@ -379,33 +366,30 @@ if not Config.OxInventory then } end - if itemType == "item_weapon" then - local weaponHash = joaat(name) - ESX.Streaming.RequestWeaponAsset(weaponHash) - local pickupObject = CreateWeaponObject(weaponHash, 50, coords.x, coords.y, coords.z, true, 1.0, 0) - SetWeaponObjectTintIndex(pickupObject, tintIndex) + if itemType ~= 'item_weapon' then + return ESX.Game.SpawnLocalObject('prop_money_bag_01', coords, setObjectProperties) + end - for _, v in ipairs(components) do - local component = ESX.GetWeaponComponent(name, v) - GiveWeaponComponentToWeaponObject(pickupObject, component.hash) - end + local weaponHash = joaat(name) + ESX.Streaming.RequestWeaponAsset(weaponHash) + local pickupObject = CreateWeaponObject(weaponHash, 50, coords.x, coords.y, coords.z, true, 1.0, 0) + SetWeaponObjectTintIndex(pickupObject, tintIndex) - setObjectProperties(pickupObject) - else - ESX.Game.SpawnLocalObject("prop_money_bag_01", coords, setObjectProperties) + for _, v in ipairs(components) do + local component = ESX.GetWeaponComponent(name, v) + GiveWeaponComponentToWeaponObject(pickupObject, component.hash) end + setObjectProperties(pickupObject) end) - RegisterNetEvent("esx:createMissingPickups") - AddEventHandler("esx:createMissingPickups", function(missingPickups) + RegisterNetEvent("esx:createMissingPickups", function(missingPickups) for pickupId, pickup in pairs(missingPickups) do TriggerEvent("esx:createPickup", pickupId, pickup.label, vector3(pickup.coords.x, pickup.coords.y, pickup.coords.z - 1.0), pickup.type, pickup.name, pickup.components, pickup.tintIndex) end end) end -RegisterNetEvent("esx:registerSuggestions") -AddEventHandler("esx:registerSuggestions", function(registeredCommands) +RegisterNetEvent("esx:registerSuggestions", function(registeredCommands) for name, command in pairs(registeredCommands) do if command.suggestion then TriggerEvent("chat:addSuggestion", ("/%s"):format(name), command.suggestion.help, command.suggestion.arguments) @@ -414,12 +398,11 @@ AddEventHandler("esx:registerSuggestions", function(registeredCommands) end) if not Config.OxInventory then - RegisterNetEvent("esx:removePickup") - AddEventHandler("esx:removePickup", function(pickupId) - if pickups[pickupId] and pickups[pickupId].obj then - ESX.Game.DeleteObject(pickups[pickupId].obj) - pickups[pickupId] = nil - end + RegisterNetEvent("esx:removePickup", function(pickupId) + if not pickups[pickupId] and not pickups[pickupId].obj then return end + + ESX.Game.DeleteObject(pickups[pickupId].obj) + pickups[pickupId] = nil end) end @@ -456,9 +439,8 @@ end if not Config.OxInventory and Config.EnableDefaultInventory then ESX.RegisterInput("showinv", TranslateCap("keymap_showinventory"), "keyboard", "F2", function() - if not ESX.PlayerData.dead then - ESX.ShowInventory() - end + if ESX.PlayerData.dead then return end + ESX.ShowInventory() end) end @@ -517,8 +499,7 @@ end ----- Admin commands from esx_adminplus -RegisterNetEvent("esx:tpm") -AddEventHandler("esx:tpm", function() +RegisterNetEvent("esx:tpm", function() local GetEntityCoords = GetEntityCoords local GetGroundZFor_3dCoord = GetGroundZFor_3dCoord local GetFirstBlipInfoId = GetFirstBlipInfoId @@ -527,17 +508,15 @@ AddEventHandler("esx:tpm", function() local GetBlipInfoIdCoord = GetBlipInfoIdCoord local GetVehiclePedIsIn = GetVehiclePedIsIn - ESX.TriggerServerCallback("esx:isUserAdmin", function(admin) - if not admin then - return - end + ESX.TriggerServerCallback('esx:isUserAdmin', function(isAdmin) + if not isAdmin then return end + local blipMarker = GetFirstBlipInfoId(8) if not DoesBlipExist(blipMarker) then ESX.ShowNotification(TranslateCap("tpm_nowaypoint"), true, false, 140) return "marker" end - -- Fade screen to hide how clients get teleported. DoScreenFadeOut(650) while not IsScreenFadedOut() do Wait(0) @@ -547,8 +526,6 @@ AddEventHandler("esx:tpm", function() local vehicle = GetVehiclePedIsIn(ped, false) local oldCoords = GetEntityCoords(ped) - -- Unpack coords instead of having to unpack them while iterating. - -- 825.0 seems to be the max a player can reach while 0.0 being the lowest. local x, y, groundZ, Z_START = coords["x"], coords["y"], 850.0, 950.0 local found = false FreezeEntityPosition(vehicle > 0 and vehicle or ped, true) @@ -578,7 +555,6 @@ AddEventHandler("esx:tpm", function() Wait(0) end - -- Get ground coord. As mentioned in the natives, this only works if the client is in render distance. found, groundZ = GetGroundZFor_3dCoord(x, y, z, false) if found then Wait(0) @@ -588,18 +564,14 @@ AddEventHandler("esx:tpm", function() Wait(0) end - -- Remove black screen once the loop has ended. DoScreenFadeIn(650) FreezeEntityPosition(vehicle > 0 and vehicle or ped, false) if not found then - -- If we can't find the coords, set the coords to the old ones. - -- We don't unpack them before since they aren't in a loop and only called once. SetPedCoordsKeepVehicle(ped, oldCoords["x"], oldCoords["y"], oldCoords["z"] - 1.0) ESX.ShowNotification(TranslateCap("tpm_success"), true, false, 140) end - -- If Z coord was found, set coords in found coords. SetPedCoordsKeepVehicle(ped, x, y, groundZ) ESX.ShowNotification(TranslateCap("tpm_success"), true, false, 140) end) @@ -650,12 +622,9 @@ local function noclipThread() end end -RegisterNetEvent("esx:noclip") -AddEventHandler("esx:noclip", function() - ESX.TriggerServerCallback("esx:isUserAdmin", function(admin) - if not admin then - return - end +RegisterNetEvent("esx:noclip", function() + ESX.TriggerServerCallback('esx:isUserAdmin', function(isAdmin) + if not isAdmin then return end if not noclip then noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false) @@ -671,13 +640,11 @@ AddEventHandler("esx:noclip", function() end) end) -RegisterNetEvent("esx:killPlayer") -AddEventHandler("esx:killPlayer", function() +RegisterNetEvent("esx:killPlayer", function() SetEntityHealth(ESX.PlayerData.ped, 0) end) -RegisterNetEvent("esx:repairPedVehicle") -AddEventHandler("esx:repairPedVehicle", function() +RegisterNetEvent("esx:repairPedVehicle", function() local ped = ESX.PlayerData.ped local vehicle = GetVehiclePedIsIn(ped, false) SetVehicleEngineHealth(vehicle, 1000) @@ -686,18 +653,12 @@ AddEventHandler("esx:repairPedVehicle", function() SetVehicleDirtLevel(vehicle, 0) end) -RegisterNetEvent("esx:freezePlayer") -AddEventHandler("esx:freezePlayer", function(input) - local player = PlayerId() - if input == "freeze" then - SetEntityCollision(ESX.PlayerData.ped, false) - FreezeEntityPosition(ESX.PlayerData.ped, true) - SetPlayerInvincible(player, true) - elseif input == "unfreeze" then - SetEntityCollision(ESX.PlayerData.ped, true) - FreezeEntityPosition(ESX.PlayerData.ped, false) - SetPlayerInvincible(player, false) - end +RegisterNetEvent("esx:freezePlayer", function(input) + local state = input == 'freeze' + + SetEntityCollision(ESX.PlayerData.ped, not state) + FreezeEntityPosition(ESX.PlayerData.ped, state) + SetPlayerInvincible(PlayerId(), state) end) ESX.RegisterClientCallback("esx:GetVehicleType", function(cb, model) diff --git a/server-data/resources/[esx]/es_extended/client/modules/callback.lua b/server-data/resources/[esx]/es_extended/client/modules/callback.lua index cf58c391c..0c3dbdd6e 100644 --- a/server-data/resources/[esx]/es_extended/client/modules/callback.lua +++ b/server-data/resources/[esx]/es_extended/client/modules/callback.lua @@ -9,7 +9,7 @@ local clientCallbacks = {} ESX.TriggerServerCallback = function(eventName, callback, ...) serverRequests[RequestId] = callback - TriggerServerEvent("esx:triggerServerCallback", eventName, RequestId, GetInvokingResource() or "unknown", ...) + TriggerServerEvent('esx:triggerServerCallback', eventName, RequestId, GetInvokingResource() or 'unknown', ...) RequestId = RequestId + 1 end diff --git a/server-data/resources/[esx]/es_extended/fxmanifest.lua b/server-data/resources/[esx]/es_extended/fxmanifest.lua index de5445070..832df5d84 100644 --- a/server-data/resources/[esx]/es_extended/fxmanifest.lua +++ b/server-data/resources/[esx]/es_extended/fxmanifest.lua @@ -66,5 +66,5 @@ dependencies { '/native:0x6AE51D4B', '/native:0xA61C8FC6', 'oxmysql', - 'spawnmanager', + 'spawnmanager' } diff --git a/server-data/resources/[esx]/es_extended/server/main.lua b/server-data/resources/[esx]/es_extended/server/main.lua index d6b3e80fe..1f14c4ceb 100644 --- a/server-data/resources/[esx]/es_extended/server/main.lua +++ b/server-data/resources/[esx]/es_extended/server/main.lua @@ -26,17 +26,12 @@ if Config.Multichar then end if not ESX.Players[src] then - local identifier = char .. ":" .. ESX.GetIdentifier(src) - if data then - createESXPlayer(identifier, src, data) - else - loadESXPlayer(identifier, src, false) - end + local identifier = ('%s:%s'):format(char, ESX.GetIdentifier(src)) + return data and createESXPlayer(identifier, src, data) or loadESXPlayer(identifier, src, false) end end) else - RegisterNetEvent("esx:onPlayerJoined") - AddEventHandler("esx:onPlayerJoined", function() + RegisterNetEvent("esx:onPlayerJoined", function() local _source = source while not next(ESX.Jobs) do Wait(50) @@ -50,25 +45,16 @@ end function onPlayerJoined(playerId) local identifier = ESX.GetIdentifier(playerId) - if identifier then - if ESX.GetPlayerFromIdentifier(identifier) then - DropPlayer( - playerId, - ("there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s"):format( - identifier - ) - ) - else - local result = MySQL.scalar.await("SELECT 1 FROM users WHERE identifier = ?", { identifier }) - if result then - loadESXPlayer(identifier, playerId, false) - else - createESXPlayer(identifier, playerId) - end - end - else - DropPlayer(playerId, "there was an error loading your character!\nError code: identifier-missing-ingame\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") + if not identifier then + return DropPlayer(playerId, "there was an error loading your character!\nError code: identifier-missing-ingame\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") + end + + if ESX.GetPlayerFromIdentifier(identifier) then + return DropPlayer(playerId, ("there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s"):format(identifier)) end + + local result = MySQL.scalar.await("SELECT 1 FROM users WHERE identifier = ?", { identifier }) + return result and loadESXPlayer(identifier, playerId, false) or createESXPlayer(identifier, playerId) end function createESXPlayer(identifier, playerId, data) @@ -110,13 +96,7 @@ if not Config.Multichar then end if identifier then - if ESX.GetPlayerFromIdentifier(identifier) then - return deferrals.done( - ("[ESX] There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s"):format(identifier) - ) - else - return deferrals.done() - end + return ESX.GetPlayerFromIdentifier(identifier) and deferrals.done(("[ESX] There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s"):format(identifier)) or deferrals.done() else return deferrals.done("[ESX] There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") end @@ -140,8 +120,7 @@ function loadESXPlayer(identifier, playerId, isNew) local result = MySQL.prepare.await(loadPlayer, { identifier }) -- Accounts - local accounts = result.accounts - accounts = (accounts and accounts ~= "") and json.decode(accounts) or {} + local accounts = (result.accounts and result.accounts ~= "") and json.decode(result.accounts) or {} for account, data in pairs(Config.Accounts) do data.round = data.round or data.round == nil @@ -164,7 +143,7 @@ function loadESXPlayer(identifier, playerId, isNew) job, grade = "unemployed", "0" end - jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] + local jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] userData.job = { id = jobObject.id, @@ -363,24 +342,19 @@ AddEventHandler("esx:playerLogout", function(playerId, cb) end) if not Config.OxInventory then - RegisterNetEvent("esx:updateWeaponAmmo") - AddEventHandler("esx:updateWeaponAmmo", function(weaponName, ammoCount) + RegisterNetEvent("esx:updateWeaponAmmo", function(weaponName, ammoCount) local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer then - xPlayer.updateWeaponAmmo(weaponName, ammoCount) - end + return xPlayer and xPlayer.updateWeaponAmmo(weaponName, ammoCount) end) - RegisterNetEvent("esx:giveInventoryItem") - AddEventHandler("esx:giveInventoryItem", function(target, itemType, itemName, itemCount) + RegisterNetEvent("esx:giveInventoryItem", function(target, itemType, itemName, itemCount) local playerId = source local sourceXPlayer = ESX.GetPlayerFromId(playerId) local targetXPlayer = ESX.GetPlayerFromId(target) local distance = #(GetEntityCoords(GetPlayerPed(playerId)) - GetEntityCoords(GetPlayerPed(target))) if not sourceXPlayer or not targetXPlayer or distance > Config.DistanceGive then - print(("[^3WARNING^7] Player Detected Cheating: ^5%s^7"):format(GetPlayerName(playerId))) - return + return print(("[^3WARNING^7] Player Detected Cheating: ^5%s^7"):format(GetPlayerName(playerId))) end if itemType == "item_standard" then @@ -526,58 +500,51 @@ if not Config.OxInventory then end end) - RegisterNetEvent("esx:useItem") - AddEventHandler("esx:useItem", function(itemName) + RegisterNetEvent("esx:useItem", function(itemName) local source = source local xPlayer = ESX.GetPlayerFromId(source) local count = xPlayer.getInventoryItem(itemName).count - if count > 0 then - ESX.UseItem(source, itemName) - else - xPlayer.showNotification(TranslateCap("act_imp")) - end + return count > 0 and ESX.UseItem(source, itemName) or xPlayer.showNotification(TranslateCap('act_imp')) end) - RegisterNetEvent("esx:onPickup") - AddEventHandler("esx:onPickup", function(pickupId) + RegisterNetEvent("esx:onPickup", function(pickupId) local pickup, xPlayer, success = Core.Pickups[pickupId], ESX.GetPlayerFromId(source) - if pickup then - local playerPickupDistance = #(pickup.coords - xPlayer.getCoords(true)) - if playerPickupDistance > 5.0 then - print(("[^3WARNING^7] Player Detected Cheating (Out of range pickup): ^5%s^7"):format(xPlayer.getIdentifier())) - return - end + if not pickup then return end - if pickup.type == "item_standard" then - if xPlayer.canCarryItem(pickup.name, pickup.count) then - xPlayer.addInventoryItem(pickup.name, pickup.count) - success = true - else - xPlayer.showNotification(TranslateCap("threw_cannot_pickup")) - end - elseif pickup.type == "item_account" then + local playerPickupDistance = #(pickup.coords - xPlayer.getCoords(true)) + if playerPickupDistance > 5.0 then + return print(("[^3WARNING^7] Player Detected Cheating (Out of range pickup): ^5%s^7"):format(xPlayer.getIdentifier())) + end + + if pickup.type == "item_standard" then + if xPlayer.canCarryItem(pickup.name, pickup.count) then + xPlayer.addInventoryItem(pickup.name, pickup.count) success = true - xPlayer.addAccountMoney(pickup.name, pickup.count, "Picked up") - elseif pickup.type == "item_weapon" then - if xPlayer.hasWeapon(pickup.name) then - xPlayer.showNotification(TranslateCap("threw_weapon_already")) - else - success = true - xPlayer.addWeapon(pickup.name, pickup.count) - xPlayer.setWeaponTint(pickup.name, pickup.tintIndex) + else + xPlayer.showNotification(TranslateCap("threw_cannot_pickup")) + end + elseif pickup.type == "item_account" then + success = true + xPlayer.addAccountMoney(pickup.name, pickup.count, "Picked up") + elseif pickup.type == "item_weapon" then + if xPlayer.hasWeapon(pickup.name) then + xPlayer.showNotification(TranslateCap("threw_weapon_already")) + else + success = true + xPlayer.addWeapon(pickup.name, pickup.count) + xPlayer.setWeaponTint(pickup.name, pickup.tintIndex) - for _, v in ipairs(pickup.components) do - xPlayer.addWeaponComponent(pickup.name, v) - end + for _, v in ipairs(pickup.components) do + xPlayer.addWeaponComponent(pickup.name, v) end end + end - if success then - Core.Pickups[pickupId] = nil - TriggerClientEvent("esx:removePickup", -1, pickupId) - end + if success then + Core.Pickups[pickupId] = nil + TriggerClientEvent("esx:removePickup", -1, pickupId) end end) end @@ -602,7 +569,7 @@ ESX.RegisterServerCallback("esx:isUserAdmin", function(source, cb) end) ESX.RegisterServerCallback("esx:getGameBuild", function(_, cb) - cb(tonumber(GetConvar("sv_enforceGameBuild", 1604))) + cb(tonumber(GetConvarInt("sv_enforceGameBuild", 1604))) end) ESX.RegisterServerCallback("esx:getOtherPlayerData", function(_, cb, target) @@ -626,11 +593,7 @@ ESX.RegisterServerCallback("esx:getPlayerNames", function(source, cb, players) for playerId, _ in pairs(players) do local xPlayer = ESX.GetPlayerFromId(playerId) - if xPlayer then - players[playerId] = xPlayer.getName() - else - players[playerId] = nil - end + players[playerId] = xPlayer and xPlayer.getName() or nil end cb(players) @@ -653,19 +616,17 @@ ESX.RegisterServerCallback("esx:spawnVehicle", function(source, cb, vehData) end) AddEventHandler("txAdmin:events:scheduledRestart", function(eventData) - if eventData.secondsRemaining == 60 then - CreateThread(function() - Wait(50000) - Core.SavePlayers() - end) - end -end) + if eventData.secondsRemaining ~= 60 then return end -AddEventHandler("txAdmin:events:serverShuttingDown", function() - Core.SavePlayers() + CreateThread(function() + Wait(50000) + Core.SavePlayers() + end) end) -local DoNotUse = { +AddEventHandler("txAdmin:events:serverShuttingDown", Core.SavePlayers) + +local doNotUse = { ["essentialmode"] = true, ["es_admin2"] = true, ["basic-gamemode"] = true, @@ -677,7 +638,7 @@ local DoNotUse = { } AddEventHandler("onResourceStart", function(key) - if DoNotUse[string.lower(key)] then + if doNotUse[string.lower(key)] then while GetResourceState(key) ~= "started" do Wait(0) end @@ -687,7 +648,7 @@ AddEventHandler("onResourceStart", function(key) end end) -for key in pairs(DoNotUse) do +for key in pairs(doNotUse) do if GetResourceState(key) == "started" or GetResourceState(key) == "starting" then StopResource(key) print(("[^1ERROR^7] WE STOPPED A RESOURCE THAT WILL BREAK ^1ESX^7, PLEASE REMOVE ^5%s^7"):format(key))