Editable Files

Language File

config.langs.en = {
    waterButton = "water",
    fertilizeButton = "fertilize",
    closeButton = "close",
    collectButton = "pick harvest",
    burnButton = "burn",
    openButton = "[E] analyze",
    healtBar = "Plants Health",
    growingBar = "Growing",
    waterBar = "Water Rate",
    fertilizerBar = "Fertilizer Rate",
    alreadyDoing = "You are already doing something!",
    noItem = "You need %sx %s for this process!",
    plantsNearby = "There is a plant cultivated near it. Get away from it!",
    wrongGround = "You can't  plant on this ground",
    notYour = "The Plant Is Not Yours!",
    noFirstPlantItem = "You don't have the %sx %s item required for planting!",
    plantLimitError = "You can't plant more plants!",
}

client/editable.lua

RegisterCommand("getgroundhash", function()
    print(GetGroundHash(GetEntityCoords(PlayerPedId())))
end)

function disableControlsWhilePlayingAnim()
    CreateThread(function()
        while animation.playing do
            DisableAllControlActions(0)
            EnableControlAction(0, 1, true)
            EnableControlAction(0, 2, true)
            EnableControlAction(0, 38, true)
            EnableControlAction(0, 249, true)
            Wait(0)
        end
    end)
end

server/editable.lua

tgiCore = tgiCoreExports:getCore()

RegisterNetEvent('tgiann-planting:collectPlant')
AddEventHandler('tgiann-planting:collectPlant', function(name)
    local src = source
    if not plantsData[name] or plantsData[name].growing ~= 100 then return end
    local xPlayer = tgiCore.getPlayer(src)
    if not xPlayer then return end

    if not config.plant[plantsData[name].plantData.index].canCollect(xPlayer, src, plantsData[name]) then return end

    local itemData = plantsData[name].plantData.giveItem
    local amount = type(itemData.amount) == "table" and math.random(itemData.amount[1], itemData.amount[2]) or itemData.amount
    if tgiCore.addItem(xPlayer, itemData.item, amount) then
        plantsData[name] = nil
        TriggerClientEvent("tgiann-planting:client:removePlant", -1, name)
        SaveResourceFile(GetCurrentResourceName(), "plants.json", json.encode(plantsData), -1)
    end
end)

for i = 1, #config.plant do
    tgiCore.CreateUseableItem(config.plant[i].item, function(source)
        TriggerClientEvent("tgiann-planting:client:plant", source, config.plant[i], index)
    end)
end

Last updated