mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 19:01:35 +00:00
Implemented esx_service:notifyAllInService and esx_service:getInServiceList
This commit is contained in:
@@ -8,4 +8,8 @@ server_scripts {
|
||||
'server/main.lua'
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
'client/main.lua'
|
||||
}
|
||||
|
||||
dependency 'es_extended'
|
||||
@@ -0,0 +1,20 @@
|
||||
ESX = nil
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while ESX == nil do
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
Citizen.Wait(0)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_service:notifyAllInService')
|
||||
AddEventHandler('esx_service:notifyAllInService', function(notification, target)
|
||||
target = GetPlayerFromServerId(target)
|
||||
if target == PlayerId() then return end
|
||||
|
||||
local targetPed = GetPlayerPed(target)
|
||||
local mugshot, mugshotStr = ESX.Game.GetPedMugshot(targetPed)
|
||||
|
||||
ESX.ShowAdvancedNotification(notification.title, notification.subject, notification.msg, mugshotStr, notification.iconType)
|
||||
UnregisterPedheadshot(mugshot)
|
||||
end)
|
||||
@@ -26,6 +26,15 @@ AddEventHandler('esx_service:disableService', function(name)
|
||||
InService[name][source] = nil
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_service:notifyAllInService')
|
||||
AddEventHandler('esx_service:notifyAllInService', function(notification, name)
|
||||
for k,v in pairs(InService[name]) do
|
||||
if v == true then
|
||||
TriggerClientEvent('esx_service:notifyAllInService', k, notification, source)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_service:enableService', function(source, cb, name)
|
||||
local inServiceCount = GetInServiceCount(name)
|
||||
|
||||
@@ -47,6 +56,10 @@ ESX.RegisterServerCallback('esx_service:isInService', function(source, cb, name)
|
||||
cb(isInService)
|
||||
end)
|
||||
|
||||
ESX.RegisterServerCallback('esx_service:getInServiceList', function(source, cb, name)
|
||||
cb(InService[name])
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function()
|
||||
local _source = source
|
||||
|
||||
|
||||
Reference in New Issue
Block a user