Kartik Scripts

Shift Logs

The Shift Log System automatically tracks and monitors officer duty status, documenting their active hours, shift counts, and optional summary notes when clocking off. Management can review these records to monitor department activity and performance.


Technical Features

  • Duty Monitoring: Hooks directly into the framework duty status changes via the kartik-policejob:bridge:dutyChanged event.
  • Lingering Shift Auto-Closure:
    • Auto-closes active shifts if an officer disconnects from the server (playerDropped handler).
    • Auto-ends lingering active shifts on server restarts with the note: "Shift auto-ended on server restart".
    • Auto-closes old shifts if a new clock-in occurs without a proper clock-out.
  • Auto-Heal Recovery: If an officer is marked as on-duty in the framework but lacks an active shift database row, the system automatically inserts one to maintain log integrity.
  • Custom Notes Support: Allows officers to provide a summary of their activities when clocking off (e.g., arrests made, citations issued, general notes).
  • Aggregated Stats: Generates career total hours and shift counts for both individual officers and the management dashboard.
  • Access Control: Reviewing officer logs requires the shift_logs permission flag, which can be restricted to management roles in shared/perms.lua.

Database Schema

Logs are persisted in the police_shift_logs table with the following structure:

ColumnTypeDescription
idINT (AUTO_INCREMENT)Unique ID of the shift log entry
citizenidVARCHARUnique identifier of the officer
nameVARCHARCharacter name of the officer
jobVARCHARJob/Department name
clock_inDATETIMETimestamp when duty started
clock_outDATETIMETimestamp when duty ended
durationINTShift length in seconds
notesTEXTSummary notes submitted by the officer

Server Callbacks & API

The system exposes the following endpoints for the client and UI integrations:

  • kartik-policejob:shiftlog:getMyStats
    • Fetches the active officer's career stats (total shifts, total hours) and recent history (last 50 shifts).
  • kartik-policejob:shiftlog:getOfficerLogs
    • (Requires shift_logs permission) Fetches aggregated shift durations and total counts for all officers within the department.
  • kartik-policejob:shiftlog:getOfficerHistory
    • (Requires shift_logs permission) Retrieves the detailed shift log history (last 50 shifts) for a specific officer by citizenid.
  • kartik-policejob:shiftlog:clockOffWithNotes
    • Saves the final summary notes and clocks the officer off duty synchronously.

On this page