Skip to content

Commit

Permalink
Added ToolUsage Fixed Bug To Cheat (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
RetryR1v2 authored Aug 11, 2024
1 parent a036249 commit eb57f94
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 6 deletions.
9 changes: 9 additions & 0 deletions client/services/planting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ function GetPositionInfrontOfElement(posX, posY, posZ, hed, distance)
return vec
end

local PlantingProcess = false

---@param plantData table
---@param fertCount number
RegisterNetEvent('bcc-farming:PlantingCrop', function(plantData, fertCount)
Expand All @@ -23,8 +25,11 @@ RegisterNetEvent('bcc-farming:PlantingCrop', function(plantData, fertCount)
end
end
if not stop then
if not PlantingProcess then
PlantingProcess = true
VORPcore.NotifyRightTip(_U("raking"), 16000)
PlayAnim("amb_work@world_human_farmer_rake@male_a@idle_a", "idle_a", 16000, true, true)
TriggerServerEvent("bcc-farming:PlantToolUsage",plantData)
VORPcore.NotifyRightTip(_U("plantingDone"), 16000)
if not IsEntityDead(PlayerPedId()) then
local PromptGroup = BccUtils.Prompt:SetupPromptGroup()
Expand Down Expand Up @@ -53,8 +58,12 @@ RegisterNetEvent('bcc-farming:PlantingCrop', function(plantData, fertCount)
local entRot = GetEntityHeading(PlayerPedId())
local plantCoords = GetPositionInfrontOfElement(entCoords.x, entCoords.y, entCoords.z, entRot, 0.75)
TriggerServerEvent('bcc-farming:AddPlant', plantData, plantCoords, fertilized)
PlantingProcess = false
else
VORPcore.NotifyRightTip(_U("failed"), 4000)
end
else
VORPcore.NotifyRightTip(_U("FinishPlantingProcessFirst"), 4000)
end
end
end)
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ dependencies {
'bcc-utils'
}

version '2.1.2'
version '2.1.3'
5 changes: 4 additions & 1 deletion languages/de_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ Locales["de_lang"] = {
harvested = "Du hast die Pflanze Geernted",
tooCloseToAnotherPlant = "Zu nah an einer Anderen Pflanze",
secondsUntilharvestOver = 'Fertig',
noCarry = "Du kannst keine Gegenstände tragen"
noCarry = "Du kannst keine Gegenstände tragen",
--New
UsageLeft = 'Haltbarkeit: ',
FinishPlantingProcessFirst = 'Beende erst den Anbaue der Aktuellen Pflanze',
}
5 changes: 4 additions & 1 deletion languages/en_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ Locales["en_lang"] = {
plantNotGrown = "The plant is not grown yet",
harvested = "You have harvested the plant",
tooCloseToAnotherPlant = "You are too close to another plant",
noCarry = "You cannot carry these items"
noCarry = "You cannot carry these items",
--New
UsageLeft = 'Haltbarkeit: ',
FinishPlantingProcessFirst = 'Beende erst den Anbaue der Aktuellen Pflanze',
}
5 changes: 4 additions & 1 deletion languages/fr_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ Locales["fr_lang"] = {
plantNotGrown = "La plante n'a pas encore poussé",
harvested = "Vous avez récolté la plante",
tooCloseToAnotherPlant = "Vous êtes trop près d'une autre plante",
noCarry = "Vous ne pouvez pas emporter ces"
noCarry = "Vous ne pouvez pas emporter ces",
--New
UsageLeft = 'Haltbarkeit: ',
FinishPlantingProcessFirst = 'Beende erst den Anbaue der Aktuellen Pflanze',
}
5 changes: 4 additions & 1 deletion languages/ro_lang.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ Locales["ro_lang"] = {
plantNotGrown = "Planta inca nu a crescut",
harvested = "Ai recoltat planta",
tooCloseToAnotherPlant = "Esti prea aproape de alta planta",
noCarry = "Nu puteți transporta aceste articole"
noCarry = "Nu puteți transporta aceste articole",
--New
UsageLeft = 'Haltbarkeit: ',
FinishPlantingProcessFirst = 'Beende erst den Anbaue der Aktuellen Pflanze',
}
22 changes: 22 additions & 0 deletions server/helpers/controllers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ RegisterServerEvent("bcc-farming:GiveBackSeed", function(seed,amount)
exports.vorp_inventory:addItem(src, seed, amount)
end)

RegisterServerEvent("bcc-farming:PlantToolUsage",function (plantData)
local src = source
local PlantItem = plantData.plantingTool
local RemoveUsage = plantData.plantingToolUsage
local Tool = exports.vorp_inventory:getItem(src, PlantItem)
local ToolMeta = Tool["metadata"]
if next(ToolMeta) == nil then
exports.vorp_inventory:subItem(src, PlantItem, 1,{})
exports.vorp_inventory:addItem(src, PlantItem, 1,{description = _U("UsageLeft") .. 100 - RemoveUsage,durability = 100 - RemoveUsage})
else
local Durability = ToolMeta.durability - RemoveUsage
local description = _U("UsageLeft") .. Durability
exports.vorp_inventory:subItem(src, PlantItem, 1,ToolMeta)
if Durability >= plantData.plantingToolDurability then
exports.vorp_inventory:subItem(src, PlantItem, 1,ToolMeta)
exports.vorp_inventory:addItem(src, PlantItem, 1,{description = description ,durability = Durability})
elseif Durability <= plantData.plantingToolDurability then
exports.vorp_inventory:subItem(src, 'Handtuch', 1,ToolMeta)
end
end
end)

RegisterServerEvent("bcc-farming:NewClientConnected", function()
local _source = source
if not Config.plantSetup.lockedToPlanter then
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<2.1.2>
<2.1.3>
See GitHub for Details!

0 comments on commit eb57f94

Please sign in to comment.