Server Events
Alle server side events kan findes herunder. Og er allerede registreret i filen omik_polititablet/server/events.lua
.
omik_polititablet:openTablet
Det er meningen at dette event skal triggeres fra client siden for at åbne tabletten for spilleren.
Der er ingen listener i omik_polititablet/server/events.lua
Det skal triggeres fra client siden. Det er afhængig af en source for at kunne tjekke spillerens rang og tilladelser.
En bedre måde at åbne tabletten på er at bruge Native ExecuteCommand(<command>)
og derefter trigger kommandoen fra cfg.openCMD
(standard: tablet
)
Eksempler
Åben tabletten med en hotkey
RegisterKeyMapping('+openTablet', ' omik_polititablet', 'keyboard', cfg.hotkey)
RegisterCommand('+openTablet', function()
TriggerServerEvent("omik_polititablet:openTablet")
end)
Åben tabletten med en command
RegisterCommand("tablet", function()
TriggerServerEvent("omik_polititablet:openTablet")
end)
omik_polititablet:newBillingEvent
Dette event bliver triggered når en ny sigtelse er blevet oprettet i politi tabletten.
Det kommer med en masse information om sigtelsen, og kan bruges til at integrere med andre resources.
Skema over data
Følgende data er hvad der bliver sendt med eventet og gemt i objektet data
{
officer: {
officer_id: number
badge_number: string
name: string
rank: string
responsible_area: string
phone_number: string
profile_logo: string
employment_date: string
fleetStatus: string
total_cases: number
permissions: [key: string]: 0 | 1
on_duty: number
},
targetCitizen: {
identifier: string
firstname: string
lastname: string
address: string
dateofbirth: string
phone_number: string
sex?: string | number | null
profile_logo: string
},
formattedMail: string,
fineAmount: number,
rawData: [key: string]: {
amount: number,
ticket: {
id: number | string,
type: string,
law: string,
paragraph: string,
title: string,
cols: string
}
}
}
Eksempler
Opret en ny bøde for spilleren i CodeM Billing
RegisterNetEvent("omik_polititablet:newBillingEvent")
AddEventHandler("omik_polititablet:newBillingEvent", function(data)
-- Source can be nil if the event is triggered from the server
if source == nil then
-- Get source from player identifier if it's not provided
end
exports['codem-billing']:createBilling(source, data.targetCitizen.identifier, data.fineAmount, data.formattedMail, society)
end)
Send en mail med KBoks og opret en bøde
RegisterNetEvent("omik_polititablet:newBillingEvent")
AddEventHandler("omik_polititablet:newBillingEvent", function(data)
-- Source can be nil if the event is triggered from the server
if source == nil then
-- Get source from player identifier if it's not provided
end
local user_id = vRP.getUserId({source})
TriggerEvent('kboks:newticket', user_id, data.targetCitizen.identifier, "Rigspolitiet", data.fineAmount)
TriggerEvent('kboks:newmail', user_id, data.targetCitizen.identifier, "Bøde", data.formattedMail, "Rigspolitiet")
end)
Træk automatisk penge fra spilleren for overtrædelserne
RegisterNetEvent("omik_polititablet:newBillingEvent")
AddEventHandler("omik_polititablet:newBillingEvent", function(data)
if (cfg.framework == "vrp") then
local receiverSource = vRP.getUserSource({data.targetCitizen.identifier})
if vRP.tryFullPayment({data.targetCitizen.identifier, data.fineAmount}) then
TriggerClientEvent("pNotify:SendNotification", receiverSource, {text = "Du betalte din bøde på "..data.fineAmount.." DKK", type = "info",timeout = (4000),layout = "centerRight",queue = "global",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
else
TriggerClientEvent("pNotify:SendNotification", receiverSource, {text = "Du har ikke nok penge til at betale din bøde", type = "info",timeout = (4000),layout = "centerRight",queue = "global",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
end
elseif (cfg.framework == "esx") then
local xPlayer = ESX.GetPlayerFromIdentifier(data.targetCitizen.identifier)
local accountMoney = xPlayer.getAccount("bank").money
if accountMoney >= data.fineAmount then
xPlayer.removeAccountMoney("bank", data.fineAmount)
TriggerClientEvent("pNotify:SendNotification", xPlayer.source, {text = "Du betalte din bøde på "..data.fineAmount.." DKK", type = "info",timeout = (4000),layout = "centerRight",queue = "global",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
else
TriggerClientEvent("pNotify:SendNotification", xPlayer.source, {text = "Du har ikke nok penge til at betale din bøde", type = "info",timeout = (4000),layout = "centerRight",queue = "global",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
end
elseif (cfg.framework == "qbcore") then
local Player = QBCore.Functions.GetPlayerByCitizenId(data.targetCitizen.identifier)
if Player.PlayerData.accounts.bank.money >= data.fineAmount then
Player.PlayerData.accounts.bank.money = Player.PlayerData.accounts.bank.money - data.fineAmount
TriggerClientEvent("pNotify:SendNotification", Player.PlayerData.source, {text = "Du betalte din bøde på "..data.fineAmount.." DKK", type = "info",timeout = (4000),layout = "centerRight",queue = "global",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
else
TriggerClientEvent("pNotify:SendNotification", Player.PlayerData.source, {text = "Du har ikke nok penge til at betale din bøde", type = "info",timeout = (4000),layout = "centerRight",queue = "global",animation = {open = "gta_effects_fade_in", close = "gta_effects_fade_out"}})
end
end
end)
omik_polititablet:server:newEmployee
Dette event bliver triggered når en ny betjent er blevet tilføjet til politi tabletten.
Examples
/*
officer_id: number
data: {
identifier: string
badgenumber: string
password: string (encrypted)
rank: string
responsible_area: string
profile_logo: string
certificates: string[]
educations: string[]
permissions: {[key: string]: 0 | 1}
}
*/
RegisterNetEvent("omik_polititablet:server:newEmployee", function(officer_id, data)
print("New employee added to the police tablet with officer_id: " .. officer_id.. " and data: " .. json.encode(data))
end)
omik_polititablet:server:deleteEmployee
Dette event bliver triggered når en betjent er blevet fjernet fra politi tabletten.
Examples
/*
officer_id: number
*/
RegisterNetEvent("omik_polititablet:server:deleteEmployee", function(officer_id)
print("Employee with officer_id: " .. officer_id .. " has been removed from the police tablet")
end)
omik_polititablet:server:editEmployee
Dette event bliver triggered når en betjent er blevet redigeret i politi tabletten.
Examples
/*
officer_id: number
data: {
officer_id: string
badgenumber: string
rank: string
responsible_area: string
certificates: string[]
educations: string[]
permissions: {[key: string]: 0 | 1}
}
*/
RegisterNetEvent("omik_polititablet:server:editEmployee", function(officer_id, data)
print("Employee with officer_id: " .. officer_id .. " has been edited with data: " .. json.encode(data))
end)
omik_polititablet:server:acceptApplication
Dette event bliver triggered når en ansøgning er blevet accepteret i politi tabletten.
Examples
/*
applicationType: "Education" | "Certificate"
title: string
officer_id: number
*/
RegisterNetEvent("omik_polititablet:server:acceptApplication", function(applicationType, title, officer_id)
print("Application with title: " .. title .. " has been accepted for officer_id: " .. officer_id)
end)
omik_polititablet:server:fleetJoin
Dette event bliver triggered når en betjent er blevet tilføjet til en flåde.
Examples
/*
role: string
officer: {
officer_id: number
badge_number: string
name: string
patrolNumber: string
}
*/
RegisterNetEvent("omik_polititablet:server:fleetJoin", function(role, officer)
print("Officer with officer_id: " .. officer.officer_id .. " has joined the fleet with role: " .. role)
end)
omik_polititablet:server:fleetLeave
Dette event bliver triggered når en betjent har forladt en flåde.
Examples
/*
role: string
officer: {
officer_id: number
badge_number: string
name: string
patrolNumber: string
}
*/
RegisterNetEvent("omik_polititablet:server:fleetLeave", function(role, officer)
print("Officer with officer_id: " .. officer.officer_id .. " has left the fleet with role: " .. role)
end)
omik_polititablet:server:fleetLink
Dette event bliver triggered når en betjent er blevet linket til en anden betjent i en flåde.
Examples
/*
role: string
linkOfficer: {
officer_id: number
badge_number: string
name: string
patrolNumber: string
}
officer: {
officer_id: number
badge_number: string
name: string
patrolNumber: string
}
*/
RegisterNetEvent("omik_polititablet:server:fleetLink", function(role, linkOfficer, officer)
print("Officer with officer_id: " .. officer.officer_id .. " has been linked to officer with officer_id: " .. linkOfficer.officer_id .. " in the fleet with role: " .. role)
end)
omik_polititablet:server:fleetUpdate
Dette event bliver triggered når en betjent er blevet opdateret i en flåde.
Examples
/*
role: string
newRole: string
officer: {
officer_id: number
badge_number: string
name: string
patrolNumber: string
}
*/
RegisterNetEvent("omik_polititablet:server:fleetUpdate", function(role, newRole, officer)
print("Officer with officer_id: " .. officer.officer_id .. " has been updated in the fleet from role: " .. role .. " to role: " .. newRole)
end)