From fab9550eeaa8b4d6aeeef35ddc9b518b0ca7e283 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Sun, 28 Apr 2024 11:13:43 +0200 Subject: [PATCH] chore: (esx-npwd) esx-npwd removal This resource should no longer be necessary for the correct functioning of "npwd", as the necessary code has been implemented in es_extended --- .../resources/[phone]/esx-npwd/README.md | 9 --- .../resources/[phone]/esx-npwd/client.lua | 70 ------------------- .../resources/[phone]/esx-npwd/fxmanifest.lua | 16 ----- .../resources/[phone]/esx-npwd/patch.sql | 1 - .../resources/[phone]/esx-npwd/server.lua | 53 -------------- 5 files changed, 149 deletions(-) delete mode 100644 server-data/resources/[phone]/esx-npwd/README.md delete mode 100644 server-data/resources/[phone]/esx-npwd/client.lua delete mode 100644 server-data/resources/[phone]/esx-npwd/fxmanifest.lua delete mode 100644 server-data/resources/[phone]/esx-npwd/patch.sql delete mode 100644 server-data/resources/[phone]/esx-npwd/server.lua diff --git a/server-data/resources/[phone]/esx-npwd/README.md b/server-data/resources/[phone]/esx-npwd/README.md deleted file mode 100644 index 9da2cb277..000000000 --- a/server-data/resources/[phone]/esx-npwd/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# NPWD compatibility wrapper for ESX -If you are using the Overextended fork of ESX then this resource is _not required_. - - -Setup event handlers and export calls to create the player instance within NPWD after an xPlayer has loaded, ensuring correct no-fuss loading and minimal effort. - -- Tested with ESX Legacy -- Should work with ESX v1 Final and v1.2 -- Tested with ESX v1.1 diff --git a/server-data/resources/[phone]/esx-npwd/client.lua b/server-data/resources/[phone]/esx-npwd/client.lua deleted file mode 100644 index 017953b12..000000000 --- a/server-data/resources/[phone]/esx-npwd/client.lua +++ /dev/null @@ -1,70 +0,0 @@ -local function getESX() - local ESX = exports['es_extended']:getSharedObject() - - -- Already handled internally - if ESX.GetConfig().OxInventory then return end - - if ESX.SearchInventory then - return { - PlayerLoaded = ESX.PlayerLoaded, - SearchInventory = ESX.SearchInventory - } - else - -- Backwards compatibility for versions prior to 1.5 - ESX = { - PlayerLoaded = ESX.PlayerLoaded, - GetPlayerData = ESX.GetPlayerData - } - - function ESX.SearchInventory() - local inventory = ESX.GetPlayerData().inventory - - for _, item in pairs(inventory) do - if item.name == 'phone' then - return 1 - end - end - end - end -end - -local ESX = getESX() - -if not ESX then return end - -AddEventHandler('onClientResourceStart', function(resource) - if resource == 'es_extended' then - ESX = getESX() - end -end) - -local npwd = exports.npwd - -if ESX.PlayerLoaded and ESX.SearchInventory('phone', true) > 0 then - npwd:setPhoneDisabled(false) -else - npwd:setPhoneDisabled(true) -end - -RegisterNetEvent('esx:playerLoaded', function() - if ESX.SearchInventory('phone') > 0 then - npwd:setPhoneDisabled(false) - end -end) - -RegisterNetEvent('esx:onPlayerLogout', function() - npwd:setPhoneVisible(false) - npwd:setPhoneDisabled(true) -end) - -RegisterNetEvent('esx:removeInventoryItem', function(item, count) - if item == 'phone' and count == 0 then - npwd:setPhoneDisabled(true) - end -end) - -RegisterNetEvent('esx:addInventoryItem', function(item, count) - if item == 'phone' then - npwd:setPhoneDisabled(false) - end -end) diff --git a/server-data/resources/[phone]/esx-npwd/fxmanifest.lua b/server-data/resources/[phone]/esx-npwd/fxmanifest.lua deleted file mode 100644 index deeec81ff..000000000 --- a/server-data/resources/[phone]/esx-npwd/fxmanifest.lua +++ /dev/null @@ -1,16 +0,0 @@ -fx_version 'cerulean' -game 'gta5' - -use_experimental_fxv2_oal 'yes' -lua54 'yes' - -client_script 'client.lua' - -server_scripts { - '@mysql-async/lib/MySQL.lua', - 'server.lua' -} - -dependencies { - 'es_extended', -} diff --git a/server-data/resources/[phone]/esx-npwd/patch.sql b/server-data/resources/[phone]/esx-npwd/patch.sql deleted file mode 100644 index c2b68d728..000000000 --- a/server-data/resources/[phone]/esx-npwd/patch.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE users ADD COLUMN `phone_number` VARCHAR(20) DEFAULT NULL; \ No newline at end of file diff --git a/server-data/resources/[phone]/esx-npwd/server.lua b/server-data/resources/[phone]/esx-npwd/server.lua deleted file mode 100644 index 75466e1ef..000000000 --- a/server-data/resources/[phone]/esx-npwd/server.lua +++ /dev/null @@ -1,53 +0,0 @@ -local function getESX() - local ESX = exports['es_extended']:getSharedObject() - - return { - GetPlayers = ESX.GetExtendedPlayers or ESX.GetPlayers, - GetPlayerFromId = ESX.GetPlayerFromId - } -end - -local ESX = getESX() -local npwd = exports.npwd - -AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) - if not xPlayer then - xPlayer = ESX.GetPlayerFromId(playerId) - end - - npwd:newPlayer({ - source = playerId, - identifier = xPlayer.identifier, - firstname = xPlayer.firstName or xPlayer.variables?.firstName or xPlayer.get('firstName'), - lastname = xPlayer.lastName or xPlayer.variables?.lastName or xPlayer.get('lastName') - }) -end) - -AddEventHandler('esx:playerLogout', function(playerId) - npwd:unloadPlayer(playerId) -end) - -AddEventHandler('onServerResourceStart', function(resource) - if resource == 'es_extended' then - ESX = getESX() - elseif resource == 'npwd' then - local xPlayers = ESX.GetPlayers() - - if next(xPlayers) then - Wait(100) - local isTable = type(xPlayers[1]) == 'table' - - for i=1, #xPlayers do - -- Fallback to `GetPlayerFromId` if playerdata was not already returned - local xPlayer = isTable and xPlayers[i] or ESX.GetPlayerFromId(xPlayers[i]) - - npwd:newPlayer({ - source = xPlayer.source, - identifier = xPlayer.identifier, - firstname = xPlayer.firstName or xPlayer.variables?.firstName or xPlayer.get('firstName'), - lastname = xPlayer.lastName or xPlayer.variables?.lastName or xPlayer.get('lastName') - }) - end - end - end -end)