mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
feat(modules): add npwd support
This commit is contained in:
+2
-1
@@ -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;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
@@ -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)
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user