• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient HELP OTVC8 CLIENT TFS1.4.2 + FREE GATHERING REVSCRIPT.

gnadaja98

New Member
Joined
May 15, 2024
Messages
13
Reaction score
2
Hi guys, can someone help me add a skill bar "gathering" on my otvc8 client?

Free Gathering Revscript
Lua:
gatheringInformations = {
    storages = {
        level = 131000,
        remainingExp = 131001,
    },
    flowers = {
        [2743] = {transformId = 6216, requiredLevel = 0, cooldown = 6, experience = 10, loot = 5921, maxQuantity = 3},
        [4017] = {transformId = 4014, requiredLevel = 5, cooldown = 60, experience = 20, loot = 7249, maxQuantity = 3},
    },
    opcode = {
        level = 184,
        percent = 185,
    }
}

-- Fórmula geral de experiência
function calculateGatheringExp(level)
    return 10 * (level + 1)
end

-- Pegar o nível de gathering do jogador
function Player.getGatheringLevel(self)
    return self:getStorageValue(gatheringInformations.storages.level)
end

-- Pegar a experiência faltante do jogador
function Player.getGatheringRemainingExp(self)
    return self:getStorageValue(gatheringInformations.storages.remainingExp)
end

-- Enviar informações de gathering para o cliente
function Player.sendGatheringInfo(self)
    local level = self:getGatheringLevel()
    local percent = 1 - (self:getGatheringRemainingExp() / calculateGatheringExp(level))

    self:sendExtendedOpcode(gatheringInformations.opcode.level, level)
    self:sendExtendedOpcode(gatheringInformations.opcode.percent, percent * 100)

    return true
end

-- Adicionar experiencia de gathering para el jugador
function Player.addGatheringExp(self, value)
    local remainingExp = self:getGatheringRemainingExp()
    self:setStorageValue(gatheringInformations.storages.remainingExp, remainingExp - value)
    self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce ganhou " .. value .. " de experiencia em Gathering.")

    -- Verificar si el jugador subió de nivel
    if remainingExp <= value then
        local newLevel = self:getGatheringLevel() + 1
        self:setStorageValue(gatheringInformations.storages.level, newLevel)
        self:setStorageValue(gatheringInformations.storages.remainingExp, calculateGatheringExp(newLevel))
        self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce aumentou o seu nivel de gathering para " .. newLevel)
        self:getPosition():sendMagicEffect(CONST_ME_FIREWORK_BLUE)
    end

    self:sendGatheringInfo()

    return true
end

-- Ação do jogador ao usar o item Sickle (2405)
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local targetId = target:getId()
    if not gatheringInformations.flowers[targetId] then
        player:sendCancelMessage("Oops!")
        return false
    end

    local info = gatheringInformations.flowers[targetId]
    if info.requiredLevel > player:getGatheringLevel() then
        player:sendCancelMessage("Voce precisa de nivel " .. info.requiredLevel .. " de gathering para realizar essa acao.")
        toPosition:sendMagicEffect(CONST_ME_POFF)
        return true
    end

    target:transform(info.transformId)
    toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:addGatheringExp(info.experience)
    player:addItem(info.loot, math.random(1, info.maxQuantity))

    addEvent(function()
        local tile = Tile(toPosition)
        local transformedItem = tile:getItemById(info.transformId)
        if transformedItem then
            transformedItem:remove()
            Game.createItem(targetId, 1, toPosition)
            toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
        end
    end, info.cooldown * 1000)

    return true
end

action:id(2405)
action:register()

-- Talkactions para teste

local talkaction = TalkAction("!gathering")

function talkaction.onSay(player, words, param)
    local level = player:getGatheringLevel()
    local remainingExp = player:getGatheringRemainingExp()
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu nivel de gathering é " .. level .. " com " .. remainingExp .. " de experiencia faltando.")
    return false
end

talkaction:register()

local talkactionXP = TalkAction("!gatheringxp")

function talkactionXP.onSay(player, words, param)
    local level = tonumber(param)
    if level then
        local expNeeded = calculateGatheringExp(level) - player:getGatheringRemainingExp()
        player:addGatheringExp(expNeeded)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce recebeu " .. expNeeded .. " de experiencia em gathering.")
    end
    return false
end

talkactionXP:register()

-- Evento de login para inicializar o sistema de gathering

local gatheringLogin = CreatureEvent("gatheringLogin")

function gatheringLogin.onLogin(player)
    if player:getStorageValue(gatheringInformations.storages.level) < 0 then
        player:setStorageValue(gatheringInformations.storages.level, 0)
        player:setStorageValue(gatheringInformations.storages.remainingExp, calculateGatheringExp(player:getGatheringLevel()))
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu nivel de gathering foi resetado!")
    end
    return true
end

gatheringLogin:register()

I try add the skillbar in \otclient\modules\game_skills archives but dont have succes.
If someone can help me i appreciate that! If is difficult PM ME please!
 
Back
Top