So there’s a lag switch item dupe on es_extended
I managed to fix it as its a fairly easy fix, all you have to do is go onto es_extended/server/main.lua (line ~473).
There should be an event called “esx:onPickup”
all you want to do is above the event add an variable called “lastTaken” and default it to 0
then every time someone picks up an item it overwrites the “lastTaken” into the pickup ID which is an function variable, but before overwriting it add an if statement “if lastTaken ~= id” when this is true it should allow the pickup to continue if not it would just do nothing,
I suck at explaining code so I’ll just show it:
local lastTaken = 0
RegisterServerEvent('esx:onPickup')
AddEventHandler('esx:onPickup', function(id)
local _source = source
local pickup = ESX.Pickups[id]
local xPlayer = ESX.GetPlayerFromId(_source)
if pickup.type == 'item_standard' then
local item = xPlayer.getInventoryItem(pickup.name)
local canTake = ((item.limit == -1) and (pickup.count)) or ((item.limit - item.count > 0) and (item.limit - item.count)) or 0
local total = pickup.count < canTake and pickup.count or canTake
local remaining = pickup.count - total
Citizen.Wait(math.random(15, 1000))
print(lastTaken .. "- " .. id)
pickup = ESX.Pickups[id]
if pickup ~= nil and lastTaken ~= id then
lastTaken = id
TriggerClientEvent('esx:removePickup', -1, id)
if total > 0 then
xPlayer.addInventoryItem(pickup.name, total)
end
if remaining > 0 then
TriggerClientEvent('esx:showNotification', _source, _U('cannot_pickup_room', item.label))
local pickupLabel = ('~y~%s~s~ [~b~%s~s~]'):format(item.label, remaining)
ESX.CreatePickup('item_standard', pickup.name, remaining, pickupLabel, _source)
end
end
elseif pickup.type == 'item_money' then
TriggerClientEvent('esx:removePickup', -1, id)
elseif pickup.type == 'item_account' then
TriggerClientEvent('esx:removePickup', -1, id)
end
end)
You can replace your entire event with mine but in mine I also fully removed pickups of “item_money” and “item_account”
Hope it helps anyone with the duping of items by using lag switches, it sure worked on my server