update for monitor
This commit is contained in:
parent
b0aa7258d9
commit
1da20f6a73
@ -11,7 +11,7 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterCommand(Config.Command, function()
|
RegisterCommand(Config.Command, function()
|
||||||
if PlayerData.job and PlayerData.job.name == 'police' then
|
if PlayerData.job and PlayerData.job.name == Config.PoliceJob then
|
||||||
TriggerServerEvent('QBCore:ToggleDuty')
|
TriggerServerEvent('QBCore:ToggleDuty')
|
||||||
TriggerServerEvent('ngd-policeduty:Server:Log')
|
TriggerServerEvent('ngd-policeduty:Server:Log')
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
Config = {}
|
Config = {}
|
||||||
|
|
||||||
|
Config.PoliceJob = 'police'
|
||||||
Config.Command = "pdduty"
|
Config.Command = "pdduty"
|
||||||
Config.ChatSuggestion = "/pdduty"
|
Config.ChatSuggestion = "/pdduty"
|
||||||
Config.ChatSuggestionM = "Duty Toggle For Police"
|
Config.ChatSuggestionM = "Duty Toggle For Police"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Config.Webhook = 'https://discord.com/api/webhooks/1119678233198207086/0dGlQPqWMiEWJ6mn7EvMosYDoq5gjZrZZjjVfEDU6ywyH5ShbprV27vgobMzF8WPXCD0'
|
Config.Webhook = 'CHANGEME'
|
||||||
|
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local onDutyTimes = {}
|
local onDutyTimes = {}
|
||||||
@ -40,6 +40,26 @@ function sendDutyTimeWebhook(src, playerName)
|
|||||||
" went off duty. Total time on duty: " .. hours .. "H " .. minutes .. "M " .. seconds .. "S")
|
" went off duty. Total time on duty: " .. hours .. "H " .. minutes .. "M " .. seconds .. "S")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent('QBCore:ToggleDuty')
|
||||||
|
AddEventHandler('QBCore:ToggleDuty', function()
|
||||||
|
local src = source
|
||||||
|
local xPlayer = QBCore.Functions.GetPlayer(src)
|
||||||
|
local playerName = xPlayer.PlayerData.charinfo.firstname .. " " .. xPlayer.PlayerData.charinfo.lastname
|
||||||
|
local metadata = xPlayer.PlayerData.metadata
|
||||||
|
if metadata and metadata.callsign then
|
||||||
|
playerName = playerName .. " (Callsign: " .. metadata.callsign .. ")"
|
||||||
|
end
|
||||||
|
if xPlayer.PlayerData.job and xPlayer.PlayerData.job.name == Config.PoliceJob then
|
||||||
|
if onDutyTimes[src] then
|
||||||
|
sendDutyTimeWebhook(src, playerName)
|
||||||
|
onDutyTimes[src] = nil
|
||||||
|
else
|
||||||
|
onDutyTimes[src] = os.time()
|
||||||
|
sendToDiscord(playerName .. " went on duty.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
function sendToDiscord(message)
|
function sendToDiscord(message)
|
||||||
local webhook = Config.Webhook
|
local webhook = Config.Webhook
|
||||||
if webhook == '' or webhook == 'CHANGEME' then
|
if webhook == '' or webhook == 'CHANGEME' then
|
||||||
@ -49,7 +69,7 @@ function sendToDiscord(message)
|
|||||||
local connect = {
|
local connect = {
|
||||||
{
|
{
|
||||||
["color"] = 255,
|
["color"] = 255,
|
||||||
["title"] = "Police Duty",
|
["title"] = "Police Duty Log",
|
||||||
["description"] = message,
|
["description"] = message,
|
||||||
["footer"] = {
|
["footer"] = {
|
||||||
["icon_url"] = "https://media.discordapp.net/attachments/1077462714902917171/1077462755625418862/96Logo.png",
|
["icon_url"] = "https://media.discordapp.net/attachments/1077462714902917171/1077462755625418862/96Logo.png",
|
||||||
|
Loading…
Reference in New Issue
Block a user