Need help to solve item duplication

For a long time players using methods in order to gather less resources. As a lot of you know, there is glitch that many server owners trying to fix, item duplication! The method that they follow in order to duplicate items, guns even black money can be done in any inventory: Property, police armoury, player inventory when you search him in order to mug him. The simply put a weapon on the Inventory and then two other guys open the Inventory and hit withdraw at the same time, so every single one of them gets a weapon!

Any help would be awesome thanks in advance!!:slightly_smiling_face:

3 Likes

Add a check to determine whether the inventory is currently open or not, and then disallow others from opening it?

1 Like

Can you help me on how to do it?

3 Likes

ill write something later, but right now i cant really, please tell me the names of the inventory resource and mugging thing u use.

I use esx_inventory_hud and for mugging esx_thief, but if you write me the determination code i cam fit it on all the scripts i want to use it!

Well, for the future reference, this problem isn’t really that hard to fix. It’s definitely not something “server owners try to fix”, because it’s just a couple lines of code :wink:

Preface

What you have to understand firstly is how server- and client-side work. Server is 1 entity (your machine), while client is basically each player connected. When your script has the logic on the client side, this means that each player can run it, without any limitations - that’s where the “bug” comes from.

How to fix

Long story short, your server should guard the access to inventories/trunks/backpacks/etc. So before you let the player open something up, you have to “ask” your server if he’s allowed to do so.

A few steps to create a guard script:

  • ask server if player is allowed to open (eg. ESX.TriggerServerCallback())
  • notify server that a player opens up inventory/trunk/etc (eg. TriggerServerEvent())
  • notify server that a player closes it (eg. TriggerServerEvent())
1 Like

@Mentozz Still i cant understand how to do it…:slightly_frowning_face:

@Mentozz its been a while and i haven’t found it yet…

1 Like

i fixed this item duplication for alot of servers. only thing you need to do is input a couple line of code in server side script that checks if Player actually has that weapon because by default it doesn’t check it. and this problem is with i think everything inventory related.

1 Like

You were looking for help, on how to deal with this problem. I gave you steps and the idea how to do so. There’s nothing more than I (or anyone else) can help you, other than actually writing the script for you - which is time consuming, since the problem is easy-to-fix, but you have to spend some time on it. Also, without programming knowledge, it’s hard to do anything with FiveM scripts :wink:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.