DoPeMan17 / esx_drugs

GNU General Public License v3.0
23 stars 42 forks source link

attempt to compare nil with number #6

Open MrRiick10 opened 4 years ago

MrRiick10 commented 4 years ago

SCRIPT ERROR: @esx_drugs/server/main.lua:58: attempt to compare nil with number

Duqino commented 4 years ago

Same here. I got this for all drugs script i try. So ESX changed something

SCRIPT ERROR: @esx_drugs/server/main.lua:58: attempt to compare nil with number

TriggerServerCallback (@es_extended/server/functions.lua:33) handler (@es_extended/server/common.lua:89)

haarperr commented 4 years ago

try changing xItem.limit to xItem.weight

Envbis commented 4 years ago

That's the solution, changing (xItem.limit to xItem.weight) I tried it and it's working now, thank you.

josepimpam commented 4 years ago

esx_drugs/server/main.lua 58

To me you keep giving me the same mistake after putting it in weight, what can I do?

ESX.RegisterServerCallback('esx_illegal:canPickUp', function(source, cb, item) local xPlayer = ESX.GetPlayerFromId(source) local xItem = xPlayer.getInventoryItem(item)

if xItem.weight ~= -1 and xItem.count >= xItem.weight then
    cb(false)
else
    cb(true)
end

end)

Envbis commented 4 years ago

esx_drugs/server/main.lua 58

To me you keep giving me the same mistake after putting it in weight, what can I do?

ESX.RegisterServerCallback('esx_illegal:canPickUp', function(source, cb, item) local xPlayer = ESX.GetPlayerFromId(source) local xItem = xPlayer.getInventoryItem(item)

if xItem.weight ~= -1 and xItem.count >= xItem.weight then
  cb(false)
else
  cb(true)
end

end)


This is what I have, but I can´t make a limit, I just keep harvesting infinitely.

local function HarvestCoke(source)

if CopsConnected < Config.RequiredCopsCoke then
    TriggerClientEvent('esx:showNotification', source, _U('act_imp_police', CopsConnected, Config.RequiredCopsCoke))
    return
end

SetTimeout(Config.TimeToFarm, function()

    if PlayersHarvestingCoke[source] == true then

        local xPlayer  = ESX.GetPlayerFromId(source)

        local coke = xPlayer.getInventoryItem('coke')

        if coke.limit == 500 and coke.count == coke.limit then
            TriggerClientEvent('esx:showNotification', source, _U('inv_full_coke'))
        else
            xPlayer.addInventoryItem('coke', 1)
            HarvestCoke(source)
        end

    end
end)

end