I did some research and wrote some code in order to prevent item duplication.
What i am trying to do is very simple actually. When a player is already doing staff in the inventory, disable access to it.
What i did so far:
My problem is that when i hit E to open the inventory i get the message it turns to true and returns to me and i receive the notification also other players can access the inventory!
Client Event
RegisterNetEvent('popOpenTheMenu')
AddEventHandler('popOpenTheMenu', function(canOpen)
if canOpen == false then
OpenArmoryMenu(CurrentActionData.station)
print(canOpen)
canOpen = true
TriggerServerEvent('esx_policejob:menuopen', canOpen)
else
print(canOpen)
ESX.ShowNotification('This inventory is not accessible right now!')
end
end)
Server Event
canOpen = nil
RegisterNetEvent('esx_policejob:menuopen')
AddEventHandler('esx_policejob:menuopen', function(canOpen)
if canOpen == nil then
canOpen = false
end
if canOpen == false then
TriggerClientEvent('popOpenTheMenu', source, canOpen)
print(canOpen)
else
canOpen = true
print(canOpen)
TriggerClientEvent('popOpenTheMenu', source, canOpen)
end
end)
Thanks for your time!