Skip to content

Commit

Permalink
Merge pull request #24 from it-scripts/v1.3.0beta7
Browse files Browse the repository at this point in the history
V1.3.0beta7
  • Loading branch information
AllRoundJonU authored Oct 13, 2024
2 parents 9f199e2 + 025f8d7 commit 4c6d662
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 15 deletions.
5 changes: 3 additions & 2 deletions client/cl_menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ RegisterNetEvent('it-drugs:client:showItemMenu', function(data)
end
if #options == 0 then
ShowNotification(nil, _U('NOTIFICATION__NO__ITEMS'), 'error')
TriggerEvent('it-drugs:client:syncRestLoop', false)
return
end

Expand Down Expand Up @@ -447,15 +448,15 @@ RegisterNetEvent("it-drugs:client:showProcessingMenu", function(data)
-- Menu only shows the amount not the name of the item
table.insert(options, {
title = _U('MENU__UNKNOWN__INGREDIANT'),
description = _U('MENU__INGREDIANT__DESC'):format(v),
description = _U('MENU__INGREDIANT__DESC'):format(v.amount),
icon = "flask",
})
end
else
for k, v in pairs(recipe.ingrediants) do
table.insert(options, {
title = it.getItemLabel(k),
description = _U('MENU__INGREDIANT__DESC'):format(v), --:replace("{amount}", v),
description = _U('MENU__INGREDIANT__DESC'):format(v.amount), --:replace("{amount}", v),
icon = "flask",
})
end
Expand Down
25 changes: 21 additions & 4 deletions client/cl_notarget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local restLoop = false
local function getClosestPlant(coords)

local closestPlant = nil
local closestDistance = 1000
local closestDistance = 20

for k, v in pairs(plants) do
local distance = #(coords - v.coords)
Expand All @@ -25,7 +25,7 @@ end
local function getClosestProcessingTable(coords)

local closestTable = nil
local closestDistance = 1000
local closestDistance = 20

for k, v in pairs(processingTables) do
local distance = #(coords - v.coords)
Expand All @@ -41,7 +41,7 @@ end
local function getClosestDealer(coords)

local closestDealer = nil
local closestDistance = 1000
local closestDistance = 20

for k, v in pairs(dealers) do
local vec3 = vector3(v.position.x, v.position.y, v.position.z)
Expand Down Expand Up @@ -107,4 +107,21 @@ CreateThread(function()
end
Wait(0)
end
end)
end)

CreateThread(function()
while true do
Wait(10000) -- Wait 10 Seconds for refresh Press E and refresh info

local newPlants = lib.callback.await('it-drugs:server:getPlants', false)
if newPlants then
plants = newPlants
end

local newProcessingTables = lib.callback.await('it-drugs:server:getTables', false)
if newProcessingTables then
processingTables = newProcessingTables
end

end
end)
9 changes: 7 additions & 2 deletions client/cl_planting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,12 @@ RegisterNetEvent('it-drugs:client:useItem', function (args)
end)

RegisterNetEvent('it-drugs:client:destroyPlant', function(args)

if not it.hasItem(Config.DestroyItemName, 1) and Config.ItemToDestroyPlant then
ShowNotification(nil, _U('NOTIFICATION__NEED_LIGHTER'), "error")
TriggerEvent('it-drugs:client:syncRestLoop', false)
return
end

local plantData = args.plantData
local type = plantData.seed
local entity = NetworkGetEntityFromNetworkId(plantData.netId)
Expand Down Expand Up @@ -512,4 +517,4 @@ RegisterNetEvent('it-drugs:client:startPlantFire', function(coords)
local effect = StartParticleFxLoopedAtCoord('ent_ray_paleto_gas_flames', coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, 0.6, false, false, false, false)
Wait(Config.FireTime)
StopParticleFxLooped(effect, 0)
end)
end)
5 changes: 3 additions & 2 deletions client/cl_processing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ RegisterNetEvent('it-drugs:client:placeProcessingTable', function(tableItem, met
RequestModel(hashModel)
while not HasModelLoaded(hashModel) do Wait(0) end

lib.showTextUI(_U('INTERACTION__PLACING__TEXT'), {
lib.showTextUI(_U('INTERACTION__PLACING_TABLE__TEXT'), {
position = "left-center",
icon = "spoon",
})
Expand Down Expand Up @@ -181,6 +181,7 @@ RegisterNetEvent('it-drugs:client:processDrugs', function(args)
if not it.hasItem(item, itemData.amount * amount) then
ShowNotification(nil, _U('NOTIFICATION__MISSING__INGIDIANT'), 'error')
proccessing = false
TriggerEvent('it-drugs:client:syncRestLoop', false)
return
end
end
Expand Down Expand Up @@ -338,4 +339,4 @@ RegisterNetEvent('it-drugs:client:syncparticlefx', function(status, tableId, net
else
CreateSmokeEffect(status, tableId, netId, particlefx)
end
end)
end)
5 changes: 4 additions & 1 deletion locales/de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Locales['de'] = {
['NOTIFICATION__ADD__BLIP'] = 'Blip wurde zur Karte hinzugefügt',
['NOTIFICATION__REMOVE__BLIP'] = 'Blip wurde von der Karte entfernt',

['NOTIFICATION__NEED_LIGHTER'] = 'Um die Pflanze zu zerstören, benötigen Sie ein Feuerzeug', -- NEED TRANSLATE

['PROGRESSBAR__SPAWN__PLANT'] = 'Pflanzen...',
['PROGRESSBAR__HARVEST__PLANT'] = 'Ernten...',
['PROGRESSBAR__SOAK__PLANT'] = 'Gießen...',
Expand All @@ -158,6 +160,7 @@ Locales['de'] = {
['PROGRESSBAR__PROCESS__DRUG'] = 'Verarbeiten...',

['INTERACTION__PLACING__TEXT'] = '[E] - Pflanze platzieren / [G] - Abbrechen',
['INTERACTION__PLACING_TABLE__TEXT'] = '[E] - Verarbeitungstisch platzieren / [G] - Abbrechen', -- Need Translate
['INTERACTION__INTERACT_TEXT'] = '[E] - Interagieren',

['INPUT__BUY__HEADER'] = 'Kaufen',
Expand All @@ -176,4 +179,4 @@ Locales['de'] = {
['COMMAND__GROUNDHASH'] = 'getGroundHash',

['COMMAND__GROUNDHASH__HELP'] = 'Bekomme den aktuellen groundHash'
}
}
6 changes: 5 additions & 1 deletion locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ Locales['en'] = {
['NOTIFICATION__ADD__BLIP'] = 'Added Blip to Map',
['NOTIFICATION__REMOVE__BLIP'] = 'Removed Blip from Map',

['NOTIFICATION__NEED_LIGHTER'] = 'You need a lighter to destroy the plant',

['PROGRESSBAR__SPAWN__PLANT'] = 'Planting...',
['PROGRESSBAR__HARVEST__PLANT'] = 'Harvesting...',
['PROGRESSBAR__SOAK__PLANT'] = 'Watering...',
Expand All @@ -172,6 +174,8 @@ Locales['en'] = {
['PROGRESSBAR__PROCESS__DRUG'] = 'Processing...',

['INTERACTION__PLACING__TEXT'] = '[E] - Place Plant / [G] - Cancel',
['INTERACTION__PLACING_TABLE__TEXT'] = '[E] - Place Table / [G] - Cancel',

['INTERACTION__INTERACT_TEXT'] = '[E] - Interact',

['INPUT__AMOUNT__HEADER'] = 'Processing',
Expand Down Expand Up @@ -201,4 +205,4 @@ function _U(string)
return string
end
return Locales[Config.Language][string]
end
end
4 changes: 3 additions & 1 deletion locales/es.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Locales['es'] = {
['NOTIFICATION__ADD__BLIP'] = 'Blip añadido al mapa',
['NOTIFICATION__REMOVE__BLIP'] = 'Blip eliminado del mapa',

['NOTIFICATION__NEED_LIGHTER'] = 'Necesitas un encendedor para destruir la planta.', -- NEED TRANSLATE

['PROGRESSBAR__SPAWN__PLANT'] = 'Plantando...',
['PROGRESSBAR__HARVEST__PLANT'] = 'Cosechando...',
['PROGRESSBAR__SOAK__PLANT'] = 'Regando...',
Expand Down Expand Up @@ -176,4 +178,4 @@ Locales['es'] = {
['COMMAND__GROUNDHASH'] = 'getGroundHash',

['COMMAND__GROUNDHASH__HELP'] = 'Obtener el hash de suelo actual.'
}
}
5 changes: 4 additions & 1 deletion locales/fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ Locales['fr'] = {
['NOTIFICATION__ADD__BLIP'] = 'Repère ajouté à la carte',
['NOTIFICATION__REMOVE__BLIP'] = 'Repère supprimé de la carte',

['NOTIFICATION__NEED_LIGHTER'] = 'Il vous faut un briquet pour détruire la plante',

['PROGRESSBAR__SPAWN__PLANT'] = 'Plantation...',
['PROGRESSBAR__HARVEST__PLANT'] = 'Récolte...',
['PROGRESSBAR__SOAK__PLANT'] = 'Arrosage...',
Expand All @@ -168,6 +170,7 @@ Locales['fr'] = {
['PROGRESSBAR__PROCESS__DRUG'] = 'Traitement...',

['INTERACTION__PLACING__TEXT'] = '[E] - Placer la plante / [G] - Annuler',
['INTERACTION__PLACING_TABLE__TEXT'] = '[E] - Placer la table / [G] - Annuler',
['INTERACTION__INTERACT_TEXT'] = '[E] - Interagir',

['INPUT__AMOUNT__HEADER'] = 'Traitement',
Expand All @@ -187,4 +190,4 @@ Locales['fr'] = {
['COMMAND__GROUNDHASH'] = 'getGroundHash',

['COMMAND__GROUNDHASH__HELP'] = 'Obtenez le hash du sol actuel'
}
}
3 changes: 3 additions & 0 deletions locales/he.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Locales['he'] = {
['NOTIFICATION__ADD__BLIP'] = 'נוסף בליפ למפה',
['NOTIFICATION__REMOVE__BLIP'] = 'הוסר בליפ מהמפה',

['NOTIFICATION__NEED_LIGHTER'] = '', -- NEED TRANSLATE

['PROGRESSBAR__SPAWN__PLANT'] = '...שותל',
['PROGRESSBAR__HARVEST__PLANT'] = '...קוצר',
['PROGRESSBAR__SOAK__PLANT'] = '...משקה',
Expand All @@ -162,6 +164,7 @@ Locales['he'] = {
['PROGRESSBAR__PROCESS__DRUG'] = '...מעבד',

['INTERACTION__PLACING__TEXT'] = '[E] - למקם עציץ / [G] - ביטול',
['INTERACTION__PLACING_TABLE__TEXT'] = '[E] - למקם עציץ / [G] - ביטול', -- NEED TRANSLATE
['INTERACTION__INTERACT_TEXT'] = '[E] - אינטראקציה',

['INPUT__AMOUNT__HEADER'] = 'מעבד',
Expand Down
8 changes: 7 additions & 1 deletion server/sv_planting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function Plant:updateHealth(health)

-- Update the plant health in the plants table
plants[self.id].health = health

-- Send data to database
MySQL.update('UPDATE drug_plants SET health = (:health) WHERE id = (:id)', {
['health'] = health,
['id'] = self.id,
})
end

--- Method to get the plant data
Expand Down Expand Up @@ -188,7 +194,7 @@ function Plant:calcHealth()
-- If the plant has no fertilizer and water, decrease the health
if fertilizer_amount == 0 and water_amount == 0 then
health -= math.random(Config.HealthBaseDecay[1], Config.HealthBaseDecay[2])
elseif fertilizer_amount < Config.FertilizerThreshold or water_amount < Config.WaterThreshold then
elseif fertilizer_amount < Config.FertilizerThreshold and water_amount < Config.WaterThreshold then
health -= math.random(Config.HealthBaseDecay[1], Config.HealthBaseDecay[2])
end

Expand Down
1 change: 1 addition & 0 deletions server/sv_processing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ RegisterNetEvent('it-drugs:server:createNewTable', function(coords, type, rotati
end
end)


RegisterNetEvent('it-drugs:server:syncparticlefx', function(status, tableId, netId, particlefx)
TriggerClientEvent('it-drugs:client:syncparticlefx',-1, status, tableId, netId, particlefx)
end)
3 changes: 3 additions & 0 deletions shared/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ Config.FertilizerThreshold = 10
Config.WaterThreshold = 10
Config.HealthBaseDecay = {7, 10} -- Min/Max Amount of health decay when the plant is below the above thresholds for water and nutrition

Config.ItemToDestroyPlant = false -- true to need an item to destroy a plant
Config.DestroyItemName = "lighter"


Config.Items = {
['watering_can'] = {
Expand Down

0 comments on commit 4c6d662

Please sign in to comment.