SQZ Scripts
Search…
sqz_Duty
Squizer's advanced duty system that allows you to go on/off duty, track your time and log it on Discord and make it accessible in in-game boss menu + automatic job convertion to off duty.

Get it now!

Instalation

  1. 1.
    Put ensure sqz_duty to your start config and resource called sqz_duty into your resources folder
  2. 2.
    Run the SQL file
  3. 3.
    Configure s_config.lua & sh_config.lua

Optional modifications

1) To add the duty element to your boss menu:
1
Change this:
2
local elements = {} in esx_society/client/main.lua:77 to
3
local elements = {
4
{label = 'Show Duty Time of employees', value = 'dutyTime'}
5
}
6
7
Add the part bellow to line 168 (the end of the if condition)
8
9
elseif data.current.value == 'dutyTime' then
10
TriggerServerEvent('sqz_duty:GetEmployes', ESX.PlayerData.job.name)
Copied!

Events used

  1. 1.
    TriggerServerEvent('sqz_duty:GetEmployes', ESX.PlayerData.job.name) Event for opening boss menu with time of players. Make sure you provide the job which maches xPlayer.job.name on server
  2. 2.
    TriggerServerEvent('sqz_duty:ResetTime', identifier, ESX.PlayerData.job.name) Event for reseting player time spent on server in the job, identifier should match targets xPlayer.identifier and the second argument is job name.
  3. 3.
    TriggerServerEvent('sqz_duty:ChangeJob') Event for changing job (mainly off <=> non off and if you have special job in Config, it will count on it with it.)

Configs

server config
shared config
locales
server_edit
client_edit
1
SConfig = {}
2
3
SConfig.Webhooks = { -- Webhooks for jobs to send daily report
4
['police'] = 'https://discord.com/api/webhooks/xxxxx',
5
['sheriff'] = 'https://discord.com/api/webhooks/xxxxx',
6
['ambulance'] = 'https://discord.com/api/webhooks/xxxxx'
7
}
8
9
SConfig.AutoInsert = true -- If the script should check for all the jobs written in the config if all of them have off duty variable
10
SConfig.UsetxAdmin = true -- If you do not use txAdmin, disable this and the employees will be saved every 6 hours.
11
12
Config.Items = { -- Those items and jobs will be affected when going on/off duty
13
14
police = { -- Name of the job
15
Add = {'badge', 'radio'}, -- Table of items that will be added (each will be added once, so you can make: 'badge', 'badge' to add it twice)
16
Remove = {}
17
},
18
offpolice = {
19
Add = {},
20
Remove = {'badge', 'radio'} -- Those items will be removed, all in count that the player has -> If you have 7 radios, 7 will be removed
21
},
22
ambulance = {
23
Add = {'radio', 'medikit'},
24
Remove = {}
25
},
26
offambulance = {
27
Add = {},
28
Remove = {'radio', 'medikit'}
29
}
30
}
Copied!
1
Config = {}
2
3
4
Config.CustomEvents = {
5
['esx:getSharedObject'] = 'esx:getSharedObject',
6
['esx:setJob'] = 'esx:setJob'
7
}
8
9
Config.Locale = 'en' -- Language [en / cs]
10
Config.DrawDistance = 1.5 -- Distance from which will be the point visible
11
Config.AllowReportInEveryWhere = true -- If players can use /duty command everywhere on the map
12
13
Config.Points = { -- Locations where the players will be able to go on/off duty
14
15
{
16
Loc = vector3(450.1802,-987.6061,30.6896),
17
Jobs = { -- List of jobs that can use this point
18
['police'] = true, -- Police officers can use this point
19
['offpolice'] = true -- Police officers off duty can use this point
20
}
21
},
22
23
{
24
Loc = vector3(312.3144,-597.6319,43.2842),
25
Jobs = {
26
['ambulance'] = true,
27
['offambulance'] = true
28
}
29
},
30
31
{
32
Loc = vector3(1851.98,3691.2664,34.2669),
33
Jobs = {
34
['sheriff'] = true,
35
['offsheriff'] = true
36
}
37
}
38
39
}
40
41
Config.TrackedJobs = { -- Time of players with these jobs will be counted to the database + Discord daily report
42
['police'] = true,
43
['sheriff'] = true,
44
['ambulance'] = true
45
}
46
47
Config.SpecialJobs = { -- List of jobs that will go to other job
48
['mafia'] = 'ballas' -- For example, if you are mafia, you will go to ballas if this is enabled
49
}
Copied!
1
Locales['en'] = {
2
['loyalEmployee'] = 'No breaks, you have a loyal worker!',
3
['embedTitle'] = '**SQZ_DUTY: New Duty Report** %s',
4
['embedDescription'] = 'Employer has ended his today duty, his name is:\n ```yaml\n %s```\n He took breaks in times: ```yaml\n%s```In total time in duty:\n ```yaml\n%s```\n His first join | last leave from job:\n ```yaml\n%s``` Job: ```yaml\n%s```',
5
['no_spam'] = 'You must wait a little bit before reporting in. No need to spam',
6
['name'] = 'Name',
7
['job_grade'] = 'JobGrade',
8
['duty_time'] = 'Total Time In Duty',
9
['last_duty'] = 'Last Duty',
10
['reset_time'] = 'Reset Time',
11
['not_here'] = 'Employee not here?',
12
['not_legit'] = 'The worker is not legit!',
13
['not_worked'] = 'He has not worked yet!',
14
['blame'] = 'Blame him!',
15
['report_in'] = '~INPUT_PICKUP~ Report in',
16
['off_duty'] = '~INPUT_PICKUP~ Go off-duty',
17
['report'] = '%s [%s] StartTime: %s\n EndTime: %s\n',
18
['in_duty'] = 'Now you are on-duty',
19
['logged_off_duty'] = 'You have logged off-duty'
20
}
21
22
Locales['cs'] = {
23
['loyalEmployee'] = 'Zaměstnanec pracoval bez přestávek, dobrá práce!',
24
['embedTitle'] = '**SQZ_DUTY: Nový záznam* %s',
25
['embedDescription'] = 'Zaměstnanec ukončil jeho dnešní šichtu, jeho jméno:\n ```yaml\n %s```\n Odpočíval v době: ```yaml\n%s```Čas strávený v práci:\n ```yaml\n%s```\n Příchod do práce | Odchod z práce:\n ```yaml\n%s``` Hodnost: ```yaml\n%s```',
26
['no_spam'] = 'Hoď se do pohody, spamovat to není třeba',
27
['name'] = 'Jméno & Příjmení',
28
['job_grade'] = 'Hodnost',
29
['duty_time'] = 'Celkový čas strávený ve službě',
30
['last_duty'] = 'Naposledy ve službě',
31
['reset_time'] = 'Obnovit čas',
32
['not_here'] = 'Zaměstnanec zde není?',
33
['not_legit'] = 'Tu je něco špatně!',
34
['not_worked'] = 'Tento zaměstnanec ještě nepracoval!',
35
['blame'] = 'Vyřeš to!',
36
['report_in'] = '~INPUT_PICKUP~ Jít do služby',
37
['off_duty'] = '~INPUT_PICKUP~ Jít mimo službu',
38
['report'] = '%s [%s] Začátek: %s\n Konec: %s\n',
39
['in_duty'] = 'Přihlásil ses do služby',
40
['logged_off_duty'] = 'Odhlásil ses ze služby'
41
}
Copied!
1
if SConfig.UsetxAdmin then
2
3
AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
4
if eventData.secondsRemaining == 60 then
5
CreateThread(function()
6
Wait(45000)
7
print("[^2sqz_duty^0]: ^215 seconds before restart... saving all player duty data!")
8
TriggerEvent('sqz_duty:saveEmployes')
9
end)
10
end
11
end)
12
13
else
14
15
Citizen.CreateThread(function()
16
17
while true do
18
Wait(6 * 60 * 60 * 1000) -- 6 hours
19
print("[^2sqz_duty^0]: ^2Saving all player data and sending messages to Discord!")
20
TriggerEvent('sqz_duty:saveEmployes')
21
end
22
end)
23
24
end
Copied!
1
RegisterNetEvent('sqz_duty:ShowNotification', function(msg)
2
ESX.ShowNotification(msg)
3
end)
4
5
RegisterNetEvent('sqz_duty:ToggleDuty', function(duty)
6
-- THis event is called every time player goes on/off duty
7
if duty then
8
print('Player is now on-duty')
9
else
10
print('Player is now off-duty')
11
end
12
end)
Copied!

Common issues

  • I can not see duty times in the boss menu
    • If you use txAdmin, it saves (by default) on every scheduled restart
    • If you do not use txAdmin, you have to trun that option off in your config and it will be saved every 6 hours (by default)
      • It is due to prevetion of spam of Discord messages
  • I keep getting message: "You SHOULD restart your server now" even after restarting your server
    • One of the jobs in Config.Points Jobs is missing in your database. Then delete all the off jobs that were party inserted and then restart the script