Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- -- Created by IntelliJ IDEA.
- -- User: Sling
- -- Date: 17-12-2018
- -- Time: 00:39
- -- Made for CiviliansNetwork
- --
- local Proxy = module("vrp", "lib/Proxy")
- vRP = Proxy.getInterface("vRP")
- local users = {}
- local PhoneNumbers = {}
- function notifyAlertSMS (number, alert, list)
- if PhoneNumbers[number] ~= nil then
- for k, _ in pairs(list) do
- vRP.getUserIdentity({users[tonumber(k)].userid, function(identity)
- local n = identity.phone
- if n ~= nil then
- TriggerEvent('gcPhone:_internalAddMessage', number, n, 'SMS fra #' .. alert.numero .. ' : ' .. alert.message, 0, function (smsMess)
- TriggerClientEvent("gcPhone:receiveMessage", tonumber(k), smsMess)
- end)
- if alert.coords ~= nil then
- TriggerEvent('gcPhone:_internalAddMessage', number, n, 'GPS: ' .. alert.coords.x .. ', ' .. alert.coords.y, 0, function (smsMess)
- TriggerClientEvent("gcPhone:receiveMessage", tonumber(k), smsMess)
- end)
- end
- end
- end})
- end
- end
- end
- --[[
- AddEventHandler('onResourceStart', function(name)
- if name:lower() == GetCurrentResourceName():lower() then
- local nusers = vRP.getUsers({})
- for k,v in pairs(nusers) do
- Citizen.Wait(50)
- if v ~= nil then
- local group = vRP.getUserGroupByType({k,"job"})
- addToPhoneNumbers(group,v)
- users[v] = {userid = k, job = group}
- end
- end
- end
- end)
- ]]
- AddEventHandler("vRP:playerLeave",function(user_id, source)
- if users[source] ~= nil then
- PhoneNumbers[users[source].job].sources[tostring(source)] = nil
- users[source] = nil
- end
- end)
- AddEventHandler("vRP:playerSpawn", function(user_id, source, first_spawn)
- if users[source] ~= nil then
- PhoneNumbers[users[source].job].sources[tostring(source)] = nil
- users[source] = nil
- end
- local group = vRP.getUserGroupByType({user_id,"job"})
- addToPhoneNumbers(group,source)
- users[source] = {userid = user_id, job = group}
- end)
- AddEventHandler("vRP:playerJoinGroup", function(user_id, group, gtype)
- if gtype == "job" then
- local source = vRP.getUserSource({user_id})
- if users[source] ~= nil then
- PhoneNumbers[users[source].job].sources[tostring(source)] = nil
- users[source] = nil
- end
- addToPhoneNumbers(group,source)
- users[source] = {userid = user_id, job = group}
- end
- end)
- RegisterServerEvent('service:startCall')
- AddEventHandler('service:startCall', function (number, message, coords)
- local source = source
- local user_id = vRP.getUserId({source})
- if number == "Politibetjent" or number == "Ambulanceredde" then
- vRP.getUserIdentity({user_id, function(identity)
- local discord = "https://discordapp.com/api/webhooks/612549618693308446/_4K-IbciILLATH6VGpa6ap5otJusC0IngLbJzRjBJouzK0BH72yAZ3zqZoZUBg195i40"
- if number == "Ambulanceredde" then
- discord = "https://discordapp.com/api/webhooks/612549812688125962/MjQxQn5pNUD9_G6TD_qSzkWBplVcQ5mz5t5l-R51sHOR1juWAmKHO253VE6av57KOypi"
- end
- webhookDiscord(identity.phone.." - "..identity.firstname.." "..identity.name,message,discord)
- end})
- end
- if number == "Mekaniker" or number == "Taxa" then
- vRP.getUserIdentity({user_id, function(identity)
- local discord = "https://discordapp.com/api/webhooks/612550451279298560/lDWbg_l_kO16wgSVsOX5DVeApHr8cgFV5Xq8Nn8EDUkwyvK5rqLPFTIWeMVvo9OcnUh1"
- if number == "Taxa" then
- discord = "https://discordapp.com/api/webhooks/612550059833425920/nbkvCKH8-STu9cvrjXjjvJLLhSqECzcDWHnnHiZ0uTqgfz1WtASrP7EAyaSzB63KxZaS"
- end
- webhookDiscord(identity.phone.." - "..identity.firstname.." "..identity.name,message,discord)
- end})
- end
- if number == "Advokat" or number == "Psykolog" then
- vRP.getUserIdentity({user_id, function(identity)
- local discord = "https://discordapp.com/api/webhooks/612550224006873119/tMamo7LoihN5WRE2MNvWVVtJGOWK_uP6aw6DmaYM-hGu5xEV6eIuGahnc3hYyzXh4Lnt"
- if number == "Psykolog" then
- discord = "https://discordapp.com/api/webhooks/614051679796592651/HBnJI90mlQ1BeRlz5HLZqX2xsnf5lhG6kvtSA2Ybyyle-JLJHVUutFwpTd5cIShQwdo3"
- end
- webhookDiscord(identity.phone.." - "..identity.firstname.." "..identity.name,message,discord)
- end})
- end
- if PhoneNumbers[number] ~= nil then
- vRP.getUserIdentity({user_id, function(identity)
- local phone = identity.phone
- notifyAlertSMS(number, {
- message = message,
- coords = (number == "Politibetjent" or number == "Ambulanceredde" or number == "Mekaniker" or number == "Taxa" or number == "Advokat" or number == "Psykolog") == true and coords or nil,
- numero = phone,
- userid = user_id,
- }, PhoneNumbers[number].sources)
- end})
- end
- end)
- function addToPhoneNumbers(number, source)
- if PhoneNumbers[number] == nil then
- PhoneNumbers[number] = {
- type = number,
- sources = {},
- alerts = {}
- }
- end
- PhoneNumbers[number].sources[tostring(source)] = true
- end
- function webhookDiscord(name,message,discord)
- if message == nil or message == '' or message:sub(1, 1) == '/' then return FALSE end
- PerformHttpRequest(discord, function(err, text, headers) end, 'POST', json.encode({username = name, content = message}), { ['Content-Type'] = 'application/json' })
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement