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
I kept getting people asking how to remove prints because it "was filling up their f8 menu and looked like errors"
So I've made the "success" coreloader prints to be debugmode only.
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
This is still not in use for now, but it WILL be used in the future
I'm getting too many support tickets about the "Failed to load" warning in console about files they don't have/need
(if you don't run `ox_core` don't worry about `ox_core` not loading)
This system is intended to load it through the script instead of `fxmanifest.lua`
It is intended to check if the user has the required script and also warn them if it's not started (load order issue), or just load it as if it were told to in the fxmanifest
PS-Inv used to be exactly the same as QB-Inv so alot of the function calls were shared
This separates them and makes it easier to make changes to support their inventory
Also unified the calls for server side functions into single functions instead of having separate per inventory
Also moves:
- `invImg()` to inventories.lua
- `registerStash()` to stashcontrol.lua