Browns Duty Time Logger
What does it do?
It auto logs your the time you went on duty in your job, the time you went off duty on your job, and how long you were on duty Automatically
Key Features:
- Automatically logs when you went on duty, off duty, and how long you were on duty to discord withot you having to do or touch a single thing!
- Ability to add unlimited jobs along with a webhook to their own discord channel where you want to show the duty time logs.
Why did i make this?
I have been roleplaying in fivem for almost 5 years now and I noticed that in some servers players are to manually (via typing) log how long they were on duty for in a discord channel or some servers have a bot that allows you to click a button to log when you went on duty and a button to log when you went off duty, this script automatically detects when your on or off duty and when you clock off or leave the server it logs when you went on duty, when you went off duty, and how long you were on duty for without you having to do anything else literally
Versions Compatible with other frameworks?
I was going to make one for ESX but i dont think they have a built in duty toggle event or anything related to it in their framework and that intergation of it is done through third party scripts so to avoid the headache I just didnt bother however I might make this compatible with ND_Core & Qbox Upon request
As of now this script only works with QBCore
Developer Notes
I Have Left Comments on EVERY Line of Code to help you understand what is happening in the code so you can rewrite the code or make the script compatible with your framework or customize it, add new stuff, etc.
Here is a screenshot of some of the code so you can see how i made SUPER DETAILED comments for your convenience
Optimization
If i were reading this post (as a developer) one of my main questions would be “How are we keeping track of the amount of time spent on duty” and to answer your question:
- There are no while loops that are left running to update ever single second that you are on duty.
- The script keep tracks of the time by storing the time you went on duty in a table and then comparing that time to the time you went off duty with a lil bit of math which tells us how long you were on duty.
other than that the script runs at 0.00 with no peaks…
Security:
The script is completely server sided, even the config.lua is declared as a server script in the fxmanifest.lua file so everything is safe!