The intention here is to try and add multiple "billing" script functions, so the user can pre-set it for scripts that use `jim_bridge`
Currently only handles `jim-payments`
Workaround function made to detect if new QB Inventory functions are available
This can be used in other situations like checking if a script is working correctly or not and the export has been registered
I've moved the framework caching to a new file `frameworkCache.lua`
This now caches the framework data once when `jim_bridge` starts
Then in `coreloader.lua` now, the information that is cached is now called from that script
This also includes better handling of ESX cached data and should stop errors
This greatly optimizes the loading of all my scripts and lowers server load to speed up server start times
I have been testing this for just under a week and 6 different test servers and it appears to work fine
I've separated the built-in custom native GTA Notifications, skillcheck and draw text targets to separate files to be loaded along side `jim_bridge`
This now makes it so they only load once instead of with every single script, and each one can call on it
This change also makes these systems able to be called outside of `jim_bridge`
For example in my test server I'm currently using:
```lua
function QBCore.Functions.Notify(text, texttype, length, icon)
CreateThread(function()
exports.jim_bridge:Notify(nil, text, icon)
end)
end
```
This should fix issues for crafting complaining inventories are open when they aren't
I was trying to use per inventory checks for them being open until I realised I could just use `IsNuiFocused()` for all inventories to check if there was an nui on the screen that used the mouse, this should be a good workaround for it
This appeared to only happen with `jim-mechanic` repair from stash, due to the stashitem's table not being sent to the function
Making it save an empty table to the database
But this was possible in other places too
I've added fallbacks for if it didn't receive a table, grab a fresh one from cache/database
This function was created to help create random numbers
When you create a table of items with a random hunger value for example
`hunger = math.random(10, 20)` this will be set at script start and never change
using `hunger = {10, 20}` and then calling this function will make it generate a random number every time
It also fallsback if it simply recieved a number instead of a table
-- For example:
-- local hunger = {10, 20}
-- local hungerAmount = GetRandomTiming(hunger)
-- print(hungerAmount) -- number between 10, 20
Mainly older inventories may have had issues with custom stash sizes when opening them
This should fix compatibility with changing slots and max weight with them on trigger
When collecting Jobs from the server it tries it's best to determine which role is the "Boss"
It checks first of the Job Grade label containing the word "Boss"
If it can't find it, it then uses the highest number grade and adds `.isBoss = true` to it
Found the real issue that was causing the scripts to not think you had items, basically reverting this change as i didn't like having it in the first place
Apparently qs-inv reports two variables on the item data for how you have
`count` and `amount`
while other inventories appear to only have one of those
I'm assuming for compatibility sake
Apparently the `count` is updated differently, and `hasItem()` was checking for this first
I've swapped round the checks and appears to work better
Custom inventories apparently load items separately/later into qbshared
so the script starts thinking there is definitely 0 items but its checking too early, this forces it to wait until its available to continue
So..from what I can gather, QS-Inv doesn't seem to be updating the client cache of the players inventory correctly
This is all speculation, I can't check this myself
When `hasItem()` is used, its essentially reading from the client's cache.
This seemingly is only updated when there is a new item in a slot, **not** when the amount of an item in that slot changes
The only way to circumvent this is a workaround to the players inventory from the server side using a callback. This is painful to do because it can increase server load when checking multiples of items
This my attempt to aid ESX loading, essentially my scripts server side now need to be locked behind `onResourceStart()` because of ESX
Loading ESX into my scripts was delaying half of it and breaking the other half
This function forcibly waits until everythings loaded and then continues
This shouldn't affect other frameworks loading ability
My tests so far have been a success with it
So information and request for help.
The issue here is that my scripts require Job and Vehicle information when the script starts, to do a debug check if the job exists for the location.
ESX doesn't share this with the client for some reason, so this requires me to request it from the server side at script ensure.
This is causing issues because it delays loading of the rest of `jim_bridge` while it slowly requests `ESX.GetJobs()` table from server side
This is delayed even more when the script is placed towards the top of the server load order and it needs to load other things like MLO's
As its trying to load this the rest of the script carries on loading with missing information.
So it loads the script thinking there are 0 jobs and breaks it.
If anyone knows of a better way of doing this then please help.
The only partial solution is to start my scripts last in the server load order
I realised I was loading ESX the stupidest way
I think I was loading ESX object, then instantly clearing it and then used workarounds to try and reload it (thinking is hard ok)
It should now load correctly and faster
also I realised my custom `onPlayerLoaded()` function was loading too fast, so I've added a delay to it but removed the while loops for esx checks that could potentially break the script