From 238bcae7c0a251f134a6cf15b521d995a694d6e8 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 13 Apr 2020 17:50:20 +0200 Subject: [PATCH] Stop incompatible resources (see description) Automaticly stop resources that - a) not compatible with ESX, for example spawnmanager - b) does the same as esx does, but what esx probably does better --- config.lua | 14 ++++++++++++++ server/common.lua | 3 --- server/main.lua | 31 ++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/config.lua b/config.lua index fc28850e..888f7e65 100644 --- a/config.lua +++ b/config.lua @@ -18,3 +18,17 @@ Config.MaxWeight = 24 -- the max inventory weight without backpack Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds Config.EnableDebug = false + +Config.IncompatibleResourcesToStop = { + ['essentialmode'] = 'ES for short, the performance heavy RP framework no one uses - and source for the random unwanted ZAP ads you\'re seeing', + ['es_admin2'] = 'Adminstration tool for the ancient ES framework that wont work with ESX', + ['esplugin_mysql'] = 'MySQL "plugin" for the ancient ES framework that has a SQL injection vulnerability', + ['es_ui'] = 'Money HUD for ES', + ['spawnmanager'] = 'Default resource that takes care of spawning players, ESX does this already', + ['mapmanager'] = 'Default resource that was required by spawnmanager, but neither are used', + ['basic-gamemode'] = 'Resource that is solely for choosing the default game type', + ['fivem'] = 'Resource that is solely for choosing the default game type', + ['fivem-map-hipster'] = 'Default spawn locations for mapmanager', + ['fivem-map-skater'] = 'Default spawn locations for mapmanager', + ['baseevents'] = 'Default resource for handling death events, ESX does this already' +} diff --git a/server/common.lua b/server/common.lua index 0acd1c9b..4921c75c 100644 --- a/server/common.lua +++ b/server/common.lua @@ -19,9 +19,6 @@ function getSharedObject() end MySQL.ready(function() - SetMapName('San Andreas') - SetGameType('Roleplay') - MySQL.Async.fetchAll('SELECT * FROM items', {}, function(result) for k,v in ipairs(result) do ESX.Items[v.name] = { diff --git a/server/main.lua b/server/main.lua index 5992cfe6..ea069af0 100644 --- a/server/main.lua +++ b/server/main.lua @@ -1,3 +1,32 @@ +Citizen.CreateThread(function() + SetMapName('San Andreas') + SetGameType('Roleplay') + local resourcesStopped = {} + + for resourceName,reason in pairs(Config.IncompatibleResourcesToStop) do + local status = GetResourceState(resourceName) + + if status == 'started' or status == 'starting' then + while status == 'starting' do + Citizen.Wait(100) + end + + StopResource(resourceName) + resourcesStopped[resourceName] = reason + end + end + + if ESX.Table.SizeOf(resourcesStopped) > 0 then + local allStoppedResources = '' + + for resourceName,reason in pairs(resourcesStopped) do + allStoppedResources = ('%s\n- ^3%s^7, %s'):format(allStoppedResources, resourceName, reason) + end + + print(('[es_extended] [^3WARNING^7] Stopped %s incompatible resource(s) that can cause issues when used with ESX. They are not needed and can safely be removed from your server, remove these resource(s) from your resource directory and your configuration file:%s'):format(ESX.Table.SizeOf(resourcesStopped), allStoppedResources)) + end +end) + RegisterNetEvent('esx:onPlayerJoined') AddEventHandler('esx:onPlayerJoined', function() if not ESX.Players[source] then @@ -216,7 +245,7 @@ function loadESXPlayer(identifier, playerId) inventory = xPlayer.getInventory(), job = xPlayer.getJob(), loadout = xPlayer.getLoadout(), - maxWeight = xPlayer.maxWeight, + maxWeight = xPlayer.getMaxWeight(), money = xPlayer.getMoney() })