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

Commit

Permalink
Implemented optional "tend item" properly
Browse files Browse the repository at this point in the history
...and scattered some more verbosity
  • Loading branch information
DemmyDemon committed Nov 10, 2019
1 parent 16b3996 commit 6d663ed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
17 changes: 12 additions & 5 deletions cropstate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ local cropstateMethods = {
function(id)
instance:import(id, location, stage, os.time(), soil)
TriggerClientEvent('esx_uteknark:planted',-1, id, location, stage)
verbose('Plant',id,'was planted.')
end)
else
Citizen.Trace("Attempt to cropstate:plant on client. Not going to work.\n")
end
end,
load = function(instance, callback)
if onServer then
verbose('Loading...')
MySQL.Async.fetchAll("SELECT `id`, `stage`, UNIX_TIMESTAMP(`time`) AS `time`, `x`, `y`, `z`, `soil` FROM `uteknark`;",
{},
function(rows)
Expand All @@ -33,6 +35,7 @@ local cropstateMethods = {
end
if callback then callback(#rows) end
instance.loaded = true
verbose('Load complete')
end)
end)
else
Expand All @@ -57,6 +60,7 @@ local cropstateMethods = {
['@stage'] = stage,
}, function(_)
TriggerClientEvent('esx_uteknark:update', -1, id, stage)
verbose('Set plant',id,'to stage',stage)
end)
elseif plant.data.object then
if DoesEntityExist(plant.data.object) then
Expand All @@ -82,6 +86,7 @@ local cropstateMethods = {
{ ['@id'] = id },
function()
TriggerClientEvent('esx_uteknark:removePlant', -1, id)
verbose('Removed plant',id)
end)
else
if object.data.object then
Expand All @@ -94,6 +99,7 @@ local cropstateMethods = {
end,
bulkData = function(instance, target)
if onServer then
verbose('Preparing bulk plant data for player',target)
target = target or -1
while not instance.loaded do
Citizen.Wait(1000)
Expand Down Expand Up @@ -178,15 +184,16 @@ if onServer then
end
else
makeToast(src, _U('interact_text'), _U('interact_full', yield))
abortAction(src)
end
else
if Config.Items.Tend then
-- TODO cost-to-tend
-- makeToast(src, _U('interact_text'), _U('interact_tended'))
else
if #Growth > plant.data.stage then
if #Growth > plant.data.stage then
if not Config.Items.Tend or TakeItem(src, Config.Items.Tend) then
makeToast(src, _U('interact_text'), _U('interact_tended'))
cropstate:update(plantID, plant.data.stage + 1)
else
abortAction(src)
makeToast(src, _U('interact_text'), _U('interact_missing_item'))
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion locales/en-US.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Locales['en-US'] = {
interact_destroyed = 'Plant destroyed',
interact_harvested = 'Plant harvested: %i weed, %i seeds',
interact_full = 'You can\'t hold %i more weed!',
}
interact_missing_item = 'You don\'t have what you need to tend this plant!',
}
3 changes: 2 additions & 1 deletion locales/sv-SE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Locales['sv-SE'] = {
interact_destroyed = 'Växt förstörd',
interact_harvested = 'Växt skördad: %i gräs, %i frön',
interact_full = 'Du har inte plats med %i mer gräs!',
}
interact_missing_item = 'Du har inte det du behöver för att vårda denna växten!',
}
1 change: 1 addition & 0 deletions sv_uteknark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ local commands = {
if args[2] and string.match(args[2], "^%d+$") then
local stage = tonumber(args[2])
if stage > 0 and stage <= #Growth then
log(source,GetPlayerName(source),'set plant',plant,'to stage',stage)
cropstate:update(plant, stage)
else
inChat(source, string.format("%i is an invalid stage", stage))
Expand Down

0 comments on commit 6d663ed

Please sign in to comment.