Server Events
All of the server side events can be found below. And is already registered in the file omik_polititablet/server/events.lua
.
omik_polititablet:openTablet
This event is meant to be triggered from the client side to open the tablet for the player.
There is no listener in omik_polititablet/server/events.lua
It has to be triggered from the client side. It is dependent on a source to be able to check the players ranks and permissions.
A better way to open the tablet is to use the Native ExecuteCommand(<command>)
and then trigger the command from cfg.openCMD
(default: tablet
)
Examples
Open the tablet for the player with a keypress
RegisterKeyMapping('+openTablet', ' omik_polititablet', 'keyboard', cfg.hotkey)
RegisterCommand('+openTablet', function()
TriggerServerEvent("omik_polititablet:openTablet")
end)
Open the tablet with a command
RegisterCommand("tablet", function()
TriggerServerEvent("omik_polititablet:openTablet")
end)
omik_polititablet:newBillingEvent
This event is triggered when a new offense has been registered in the police tablet.
It comes with a lot of information about the offense, and can be used to integrate with other resources.
Data Schema
The following data is what is sent with the event and stored in the property 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
}
}
}
Examples
Trigger CodeM Billing to create a new billing for the player
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)
Trigger a kboks email and fine event
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)
Automatically charge player for the offense(s)
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
This event is triggered when a new employee has been added to the police tablet.
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
This event is triggered when an employee has been removed from the police tablet.
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
This event is triggered when an employee has been edited in the police tablet.
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
This event is triggered when an application has been accepted in the police tablet.
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
This event is triggered when an officer has joined a fleet.
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
This event is triggered when an officer has left a fleet.
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
This event is triggered when an officer has been linked to another officer in a fleet.
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
This is triggered when an officer has been updated in a fleet.
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)
omik_polititablet:server:fleetReset
This is triggered when the fleet has been reset.
Examples
/*
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
}
*/
RegisterNetEvent("omik_polititablet:server:fleetReset", function(officer)
print("Officer with officer_id: " .. officer.officer_id .. " has reset the fleet management data")
end)
omik_polititablet:server:configUpdated
This event is triggered when the tablet config has been updated. (not config.lua)
Examples
RegisterNetEvent("omik_polititablet:server:configUpdated", function(data)
print("Config has been updated")
print(json.encode(data))
end)