final
This commit is contained in:
parent
fd934b69de
commit
48e4d51145
@ -10,8 +10,9 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
|
||||
PlayerData = {}
|
||||
end)
|
||||
|
||||
if Config.UseCommand then
|
||||
RegisterCommand(Config.Command, function()
|
||||
if PlayerData.job and PlayerData.job.name == Config.PoliceJob then
|
||||
if PlayerData.job and PlayerData.job.name == Config.PoliceJob or PlayerData.job and PlayerData.job.type == Config.PoliceJobType then
|
||||
TriggerServerEvent('QBCore:ToggleDuty')
|
||||
TriggerServerEvent('ngd-policeduty:Server:Log')
|
||||
end
|
||||
@ -20,3 +21,4 @@ end)
|
||||
CreateThread(function()
|
||||
TriggerEvent('chat:addSuggestion', Config.ChatSuggestion, Config.ChatSuggestionM, {})
|
||||
end)
|
||||
end
|
||||
|
11
config.lua
11
config.lua
@ -1,6 +1,9 @@
|
||||
Config = {}
|
||||
|
||||
Config.PoliceJob = 'police'
|
||||
Config.Command = "pdduty"
|
||||
Config.ChatSuggestion = "/pdduty"
|
||||
Config.ChatSuggestionM = "Duty Toggle For Police"
|
||||
--You can either use police job or the type below.
|
||||
Config.PoliceJob = 'police' --Police job qbcore>shared>jobs.lua
|
||||
Config.PoliceJobType = 'leo' --Police job type in qbcore>shared>jobs.lua type =
|
||||
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'
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
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)
|
||||
local src = source
|
||||
if onDutyTimes[src] then
|
||||
@ -49,7 +40,7 @@ AddEventHandler('QBCore:ToggleDuty', function()
|
||||
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 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
|
||||
sendDutyTimeWebhook(src, playerName)
|
||||
onDutyTimes[src] = nil
|
||||
@ -60,12 +51,14 @@ AddEventHandler('QBCore:ToggleDuty', function()
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
function sendToDiscord(message)
|
||||
local webhook = Config.Webhook
|
||||
if webhook == '' or webhook == 'CHANGEME' then
|
||||
print('Please put webhook into editableserver.lua')
|
||||
return
|
||||
end
|
||||
local currentDateTime = os.date("%m-%d-%Y %H:%M:%S")
|
||||
local connect = {
|
||||
{
|
||||
["color"] = 255,
|
||||
@ -73,7 +66,7 @@ function sendToDiscord(message)
|
||||
["description"] = message,
|
||||
["footer"] = {
|
||||
["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