I tried doing a test and that didn’t work this is what I did tho.
Client
local testc = nil
RegisterNetEvent(‘testc’)
AddEventHandler(‘testc’, function(test)
testc = test
print(testc)
end)
Server
local test = false
local barrel = xPlayer.getInventoryItem(‘barrel’).count,
if barrel >= 1 then
test = true
TriggerClientEvent(“testc”, source, test)
elseif barrel == 0 then
test = false
TriggerClientEvent(“testc”, source, test)
end
end)
Created a different post cause it’s a different script Plus idk how this could even be considered spam why don’t you look at the server bazar where post get bumped every hour
local barrel = xPlayer.getInventoryItem('barrel').count
if barrel >= 1 then
local test = true
TriggerClientEvent("testi", source, test)
elseif barrel == 0 then
local test = false
TriggerClientEvent("testi", source, test)
end
RegisterServerEvent(‘t’)
AddEventHandler(‘t’, function()
local xPlayer = ESX.GetPlayerFromId(source)
local barrel = xPlayer.getInventoryItem(‘barrel’).count
if barrel >= 1 then
local testit = true
TriggerClientEvent(“testi”, source, testit)
elseif barrel == 0 then
local testit = false
TriggerClientEvent(“testi”, source, testit)
end
end)
Idk, but you can also try this… TriggerClientEvent(“testi”, -1 ,source, testit)
On client:
local testc = nil
RegisterNetEvent(“testi”)
AddEventHandler(“testi”, function(id, testit)
local myId = PlayerId()
local pid = GetPlayerFromServerId(id)
if pid == myId then
testc = testit
print(testc)
end
end)
The way i explain you, should work, if you want specific help, PM me an pass me the resource, cause i think you might have an error on the resource, that make the client event cant be called