final
This commit is contained in:
parent
fd934b69de
commit
48e4d51145
@ -10,13 +10,15 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
|||||||
PlayerData = {}
|
PlayerData = {}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterCommand(Config.Command, function()
|
if Config.UseCommand then
|
||||||
if PlayerData.job and PlayerData.job.name == Config.PoliceJob then
|
RegisterCommand(Config.Command, function()
|
||||||
|
if PlayerData.job and PlayerData.job.name == Config.PoliceJob or PlayerData.job and PlayerData.job.type == Config.PoliceJobType then
|
||||||
TriggerServerEvent('QBCore:ToggleDuty')
|
TriggerServerEvent('QBCore:ToggleDuty')
|
||||||
TriggerServerEvent('ngd-policeduty:Server:Log')
|
TriggerServerEvent('ngd-policeduty:Server:Log')
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
TriggerEvent('chat:addSuggestion', Config.ChatSuggestion, Config.ChatSuggestionM, {})
|
TriggerEvent('chat:addSuggestion', Config.ChatSuggestion, Config.ChatSuggestionM, {})
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
11
config.lua
11
config.lua
@ -1,6 +1,9 @@
|
|||||||
Config = {}
|
Config = {}
|
||||||
|
|
||||||
Config.PoliceJob = 'police'
|
--You can either use police job or the type below.
|
||||||
Config.Command = "pdduty"
|
Config.PoliceJob = 'police' --Police job qbcore>shared>jobs.lua
|
||||||
Config.ChatSuggestion = "/pdduty"
|
Config.PoliceJobType = 'leo' --Police job type in qbcore>shared>jobs.lua type =
|
||||||
Config.ChatSuggestionM = "Duty Toggle For Police"
|
Config.UseCommand = true --Enables a / command for police to toggle duty.
|
||||||
|
Config.Command = "pdduty" --Name of / command for duty toggle
|
||||||
|
Config.ChatSuggestion = "/pdduty" --Chat suggestion
|
||||||
|
Config.ChatSuggestionM = "Duty Toggle For Police" --Chat suggestion
|
||||||
|
@ -1,25 +1,16 @@
|
|||||||
|
-- ██ ██ ███████ ██████ ██ ██ ██████ ██████ ██ ██
|
||||||
|
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ██ █ ██ █████ ██████ ███████ ██ ██ ██ ██ █████
|
||||||
|
-- ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||||
|
-- ███ ███ ███████ ██████ ██ ██ ██████ ██████ ██ ██
|
||||||
|
|
||||||
Config.Webhook = 'CHANGEME'
|
Config.Webhook = 'CHANGEME'
|
||||||
|
---------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
local QBCore = exports['qb-core']:GetCoreObject()
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
local onDutyTimes = {}
|
local onDutyTimes = {}
|
||||||
|
|
||||||
RegisterNetEvent('ngd-policeduty:Server:Log', 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 onDutyTimes[src] then
|
|
||||||
sendDutyTimeWebhook(src, playerName)
|
|
||||||
onDutyTimes[src] = nil
|
|
||||||
else
|
|
||||||
onDutyTimes[src] = os.time()
|
|
||||||
sendToDiscord(playerName .. " went on duty.")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
AddEventHandler('playerDropped', function(reason)
|
AddEventHandler('playerDropped', function(reason)
|
||||||
local src = source
|
local src = source
|
||||||
if onDutyTimes[src] then
|
if onDutyTimes[src] then
|
||||||
@ -49,7 +40,7 @@ AddEventHandler('QBCore:ToggleDuty', function()
|
|||||||
if metadata and metadata.callsign then
|
if metadata and metadata.callsign then
|
||||||
playerName = playerName .. " (Callsign: " .. metadata.callsign .. ")"
|
playerName = playerName .. " (Callsign: " .. metadata.callsign .. ")"
|
||||||
end
|
end
|
||||||
if xPlayer.PlayerData.job and xPlayer.PlayerData.job.name == Config.PoliceJob then
|
if xPlayer.PlayerData.job and xPlayer.PlayerData.job.name == Config.PoliceJob or xPlayer.PlayerData.job and xPlayer.PlayerData.job.type == Config.PoliceJobType then
|
||||||
if onDutyTimes[src] then
|
if onDutyTimes[src] then
|
||||||
sendDutyTimeWebhook(src, playerName)
|
sendDutyTimeWebhook(src, playerName)
|
||||||
onDutyTimes[src] = nil
|
onDutyTimes[src] = nil
|
||||||
@ -60,12 +51,14 @@ AddEventHandler('QBCore:ToggleDuty', function()
|
|||||||
end
|
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
|
||||||
print('Please put webhook into editableserver.lua')
|
print('Please put webhook into editableserver.lua')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
local currentDateTime = os.date("%m-%d-%Y %H:%M:%S")
|
||||||
local connect = {
|
local connect = {
|
||||||
{
|
{
|
||||||
["color"] = 255,
|
["color"] = 255,
|
||||||
@ -73,7 +66,7 @@ function sendToDiscord(message)
|
|||||||
["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",
|
||||||
["text"] = "www.nemesisGD.com",
|
["text"] = "www.nemesisGD.com | " .. currentDateTime,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user