Script works fine as intended, I do need to fix the backspace issue but also a known bug is that you can have multiple people enter the trunk and duplicate the item inside the trunk. Is there a way to have only one person looking in the trunk at a time because I was able to duplicate all items stored in a trunk while having someone already looking into it
Good work guys!! I have found one problem. The players can duplicate weapons with this script. If you put a weapon with like ‘‘250’’ ammo in it in the trunk you can then take out 250 weapons or am i doing somethning wrong?
Doing this is beyond me, however if you can limit the number of ammo you put into the trunk to “1”, it’s too much work to duplicate. In my testing with a double barrel shotgun, if I only put in one ammo, when I take it back out, I only end up with one extra ammo, not doubled.
As far as the backspace issue, I just copied the entire “-- Key Controls” section from esx_vehicle_inventory over to this one and it fixed it.
Ok, here is a workaround with this extremely small change. This is not foolproof, but it does take a little more work to figure out how to dupe ammo. Here is how I tested:
First I bought a special carbine which gave me 43 ammo:
Placed the gun in the trunk using a count of 43
Removed the gun from the trunk using a count of 43
Viewed weapon wheel and seen I only had 43 ammo, not 86
Then, next test:
Placed the gun in the trunk using a count of 43
Removed the gun from the trunk using a count of 20
Viewed weapon wheel and seen gun with 43 ammo
Opened trunk again and seen the gun with 23 ammo
Removed weapon using a count of 20 again
Viewed weapon wheel and seen gun still only had 43 ammo
Opened trunk again and seen the gun with 3 ammo
Removed weapon using a count of 3
Viewed weapon wheel and seen gun still only had 43 ammo
Opened the trunk again and seen gun was finally removed from it
Next test
Place the gun in the trunk using a count of 10
Viewed weapon wheel to see gun completely removed
Open trunk and seen the gun with a count of 10
Removed gun using a count of 1
Viewed weapon wheel and seen the gun with a count of 43
Opened trunk and seen the gun with a count of 9
Removed gun using a count of 9
Viewed weapon wheel and seen the gun with a count of 43
In conclusion, there was no duping using the trunk with guns with the fix seen below.
I also conducted the same test as above with throwable items and didn’t dupe them.
In the /server/main.lua, find
if itemType == 'item_weapon' then
xPlayer.addWeapon(item, count)
end
And change it to:
if itemType == 'item_weapon' then
xPlayer.addWeapon(item, 0)
end
There are other methods of duping weapon ammo. However, in my testing with this script, the trunk is no longer a way to do it.