Implemented esx_service:notifyAllInService and esx_service:getInServiceList

This commit is contained in:
ElPumpo
2018-07-22 14:46:06 +02:00
parent a636c5161d
commit 5d8b12a415
3 changed files with 37 additions and 0 deletions
+4
View File
@@ -8,4 +8,8 @@ server_scripts {
'server/main.lua'
}
client_scripts {
'client/main.lua'
}
dependency 'es_extended'
+20
View File
@@ -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)
+13
View File
@@ -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