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
Not having the server convars added to the server.cfg was causing issues for some users
it should have worked, but this forces things to gta if you don't have any values set for them anywhere
I've added fallbacks to "gta" settings to hopefully stop fivem errors
This has several changes
When crafting, it now checks if the inventory is open and stops crafting dead and warns the player with a print.
Multicraft now checks if you have space in your inventory for the items and limits the max amount craftable
Also fixes the "title" of the qb-input box when crafting
Also changed the anim flag for the "placing items" to hopefully keep you in place
I forgot to correct the result as qb-input returns strings, this fixes that
Also added a fallback for if the user deletes the value and tries to craft `nil`
When a player logs out and back in (switches character) it was thinking that the `AuthEvent` was being called more than once, triggering a warning message
This should clear the event when a player unloads and then allows them to request a new one
This'll probably break it, (it works for me) but refactored the stash item check, it was calling `stashHasItem()` for every ingredient check, now it sends the whole table of ingredients per item to craft and checks them together instead of separately
Also removes a `Wait()`, as it shouldn't need it with this change..maybe
An attempt to speed up `multiCraft()` function creation logic
Before it created a table of items while it was trying to check them I've separated this so it just gets that out of the way and checks items in it's own `for` loop
Also added a `maxCreation` variable that users can edit if needed which decides how many of an item can be created (I'll change this soon probably to tie into the config options in scripts for multicraft again soon
Also removed a few `Wait()`s that were there to help it not get confused, but after testing I believe this didn't make a difference, let me know if there's any issues with stuff like it saying it can craft when you dont have the items
I think, if ox_inventory checks a stash that doesn't exist yet, it returns a boolean or `nil`
This checks for that and instead returns a table to hopefully stop the scripts from breaking
Completely overlooked that ox_target item variable is `items` not `item`
changes
```lua
item = opts[i].item or nil,
```
to:
```lua
items = opts[i].item or nil,
```
The slot data for CodeM apparently returns as a string, this fixes it trying to compare a string to a number
```lua
if v.name == item and v.slot <= lowestSlot then
```
to
```lua
if v.name == item and tonumber(v.slot) <= lowestSlot then
```