Description:
This commit brings substantial enhancements to the time handling functionality in the 'esx_core/[core]/cron/server/main.lua' script for the FiveM server:
- Utilized Unix Timestamps: Replaced the existing `GetTime()` function with `GetUnixTimestamp()`, ensuring precise time representation by using the Unix timestamp format (seconds since January 1, 1970). This change mitigates potential issues related to Daylight Saving Time (DST) transitions.
- Refined Task Execution Logic: The `OnTime` function has been refactored to operate based on Unix timestamps, ensuring accurate execution of scheduled tasks without any inconsistencies due to local time conversions.
By introducing these improvements, the cron-like system now operates with enhanced accuracy, bolstering the stability and predictability of scheduled events on the FiveM server. Extensive testing has been conducted to guarantee compatibility with various server environments.
The requested features are now included. playerPed and playerCoords do have now two different locals for better orientation and included nil checking for the function.
By using the function you see the following:
source = GetPlayerPed(source)
-- So source is now the playerPed
source = GetEntityCoords(GetPlayerPed(source))
-- The source is getting new defined by calling the entity coords from the playerPed and then the playerPed once again.
Support for Clearing Specific Value:
You can now use the "clearMeta" function to remove a specific value associated with an index. By providing the "index" and the "subValue" (as a string), the function will remove that specific value from the metadata table.
Support for Clearing Multiple Values:
The function has been expanded to allow the removal of multiple values simultaneously. By passing a table of "subValues" to the function, you can specify several values to clear from the metadata table associated with a particular index.
Handling Entire Index Value:
If no "subValues" are provided, the function will clear the entire value associated with the given "index." This allows you to wipe out all the data related to that particular index.
-- Clear the "level" value within the "player1" index
self.clearMeta("player1", "level")
-- Clear the "score" and "level" values within the "player1" index
self.clearMeta("player1", {"score", "level"})
-- Clear the entire value associated with "player1" index
self.clearMeta("player1")