When the Menu.Open function is called, a new key-value pair labeled "resourceName" is now added to the menu object. This addition serves the purpose of capturing and storing the invoking resource's name that triggers the function by calling the GetInvokingResource() native.
By implementing this change, we establish a more direct and reliable method for checking the "resourceName" key within the menu object. This approach eliminates the need to solely rely on matching the namespace and resource name. As a result, the code becomes more robust and less prone to errors.
I have encountered several frustrating instances when accidentally restarting a script that still had an open ESX UI. This situation prevents the UI from closing properly and leads to a cascade of errors, ultimately forcing a game restart. To address this issue, I propose the following code changes.
The code introduces an event handler for the onResourceStop event, enabling us to loop through all open ESX UIs and identify any opened menus within the same namespace as the resource name. Following the best practice, the namespace should ideally align with the resource name.
I believe implementing these changes will provide a smoother user experience. I look forward to your feedback and merging these improvements into the main branch.
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")