diff --git a/[SQL]/legacy.sql b/[SQL]/legacy.sql index 39e24040..2ba76874 100644 --- a/[SQL]/legacy.sql +++ b/[SQL]/legacy.sql @@ -402,7 +402,8 @@ CREATE TABLE `users` ( `disabled` TINYINT(1) NULL DEFAULT '0', `last_property` varchar(255) DEFAULT NULL, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `last_seen` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP + `last_seen` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + `phone_number` VARCHAR(20) DEFAULT NULL ) ENGINE=InnoDB; -- -------------------------------------------------------- diff --git a/[core]/es_extended/client/modules/npwd.lua b/[core]/es_extended/client/modules/npwd.lua new file mode 100644 index 00000000..fb04f356 --- /dev/null +++ b/[core]/es_extended/client/modules/npwd.lua @@ -0,0 +1,55 @@ +local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + +local function checkPhone() + if not npwd then + return + end + + npwd:setPhoneDisabled((ESX.SearchInventory('phone').count or 0) <= 0) +end +RegisterNetEvent('esx:playerLoaded', checkPhone) + +AddEventHandler('onClientResourceStart', function(resource) + if resource ~= 'npwd' then + return + end + + npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + + if ESX.PlayerLoaded then + checkPhone() + end +end) + +AddEventHandler('onClientResourceStop', function(resource) + if resource == 'npwd' then + npwd = nil + end +end) + +RegisterNetEvent('esx:onPlayerLogout', function() + if not npwd then + return + end + + npwd:setPhoneVisible(false) + npwd:setPhoneDisabled(true) +end) + +RegisterNetEvent('esx:removeInventoryItem', function(item, count) + if not npwd then + return + end + + if item == 'phone' and count == 0 then + npwd:setPhoneDisabled(true) + end +end) + +RegisterNetEvent('esx:addInventoryItem', function(item) + if not npwd or item ~= 'phone' then + return + end + + npwd:setPhoneDisabled(false) +end) \ No newline at end of file diff --git a/[core]/es_extended/fxmanifest.lua b/[core]/es_extended/fxmanifest.lua index 1c9c63be..0f5ca570 100644 --- a/[core]/es_extended/fxmanifest.lua +++ b/[core]/es_extended/fxmanifest.lua @@ -27,9 +27,9 @@ server_scripts { 'server/main.lua', 'server/commands.lua', - 'common/modules/math.lua', - 'common/modules/table.lua', - 'common/functions.lua' + 'common/modules/*.lua', + 'common/functions.lua', + 'server/modules/*.lua' } client_scripts { @@ -37,14 +37,11 @@ client_scripts { 'client/functions.lua', 'client/wrapper.lua', 'client/main.lua', + + 'common/modules/*.lua', + 'common/functions.lua', - 'client/modules/death.lua', - 'client/modules/scaleform.lua', - 'client/modules/streaming.lua', - - 'common/modules/math.lua', - 'common/modules/table.lua', - 'common/functions.lua' + 'client/modules/*.lua' } ui_page { diff --git a/[core]/es_extended/server/modules/npwd.lua b/[core]/es_extended/server/modules/npwd.lua new file mode 100644 index 00000000..3e0c1ffc --- /dev/null +++ b/[core]/es_extended/server/modules/npwd.lua @@ -0,0 +1,49 @@ +local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + +AddEventHandler('onServerResourceStart', function(resource) + if resource ~= 'npwd' then + return + end + + npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil + + for _, xPlayer in pairs(ESX.Players) do + npwd:newPlayer({ + source = xPlayer.source, + identifier = xPlayer.identifier, + firstname = xPlayer.get('firstName'), + lastname = xPlayer.get('lastName') + }) + end +end) + +AddEventHandler('onServerResourceStop', function(resource) + if resource == 'npwd' then + npwd = nil + end +end) + +AddEventHandler('esx:playerLoaded', function(playerId, xPlayer) + if not npwd then + return + end + + if not xPlayer then + xPlayer = ESX.GetPlayerFromId(playerId) + end + + npwd:newPlayer({ + source = playerId, + identifier = xPlayer.identifier, + firstname = xPlayer.get('firstName'), + lastname = xPlayer.get('lastName') + }) +end) + +AddEventHandler('esx:playerLogout', function(playerId) + if not npwd then + return + end + + npwd:unloadPlayer(playerId) +end) \ No newline at end of file