Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Checking for item validity on startup
Browse files Browse the repository at this point in the history
Also, support for people running newer ESX that does not have a "limt"
for items.
  • Loading branch information
DemmyDemon committed Nov 11, 2019
1 parent 293df5b commit a2efa9e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sv_uteknark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local VERBOSE = false
local lastPlant = {}
local tickTimes = {}
local tickPlantCount = 0
local VERSION = '1.0.0'
local VERSION = '1.1.0'

AddEventHandler('playerDropped',function(why)
lastPlant[source] = nil
Expand Down Expand Up @@ -99,7 +99,7 @@ function GiveItem(who, what, count)
end
local itemspec = xPlayer.getInventoryItem(what)
if itemspec then
if itemspec.limit == -1 or itemspec.count + count <= itemspec.limit then
if not itemspec.limit or itemspec.limit == -1 or itemspec.count + count <= itemspec.limit then
xPlayer.addInventoryItem(what, count)
return true
else
Expand Down Expand Up @@ -218,6 +218,11 @@ Citizen.CreateThread(function()
while ESX == nil and ESXTries > 0 do
TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
for forWhat,itemName in pairs(Config.Items) do
if not ESX.Items[itemName] then
log('WARNING:',forWhat,'item in cofiguration ('..itemName..') does not exist!')
end
end
ESX.RegisterUsableItem(Config.Items.Seed, function(source)
local now = os.time()
local last = lastPlant[source] or 0
Expand Down

0 comments on commit a2efa9e

Please sign in to comment.