• 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!

Lua help skill craft system

poncex

New Member
Joined
Nov 11, 2012
Messages
19
Reaction score
2
hi all, I am trying to add a skill bar for crafting, the problem is that when raising skill, it is not reflected in the crafting system, making it impossible to create items

http://imgfz.com/i/kqPcdlv.png an example of the problem

Lua:
local storageOffset = 1000
local skillRate = 30
function Player.getCSkill(self, skill)
    return self:getStorageValue(cSkills[skill].storage)
end

function Player.setCSkill(self, skill, new)
    return self:setStorageValue(cSkills[skill].storage, new)
end

function Player.addCSkillTries(self, skill, count)
    local current = self:getCSkill(skill)
    self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You advanced to " .. string.lower(skill) .. " level " .. current + count .. ".")
    return self:setCSkill(skill, current + count)
end

function Player.getCSkillTries(self, skill)
    return self:getStorageValue(cSkills[skill].storage + storageOffset)
end

function Player.getRequiredCTries(self, skill)
    local currentLevel = self:getStorageValue(cSkills[skill].storage)
    local requiredTries = math.floor(50 * math.pow(cSkills[skill].ratetries, currentLevel - 10) / skillRate)
    return requiredTries
end

function Player.setCTries(self, skill, value)
    return self:setStorageValue(cSkills[skill].storage + storageOffset, value)
end

function Player.addSkillTries(self, skill, tries)
    local current = self:getCSkillTries(skill)
    if self:getCSkill(skill) >= cSkills[skill].maxskill then
        return false
    end
    self:setStorageValue(cSkills[skill].storage + storageOffset, current + tries)
    while self:getCSkillTries(skill) > self:getRequiredCTries(skill) do
        self:setCTries(skill, self:getCSkillTries(skill) - self:getRequiredCTries(skill))
        self:addSkillTries(SKILL_CRAFTING, 1)
    end
    return true
end

function Player.getCSkillPercent(self, skill)
    return 100 - math.floor((self:getCSkillTries(skill) / self:getRequiredCTries(skill)) * 100)
end

my script
 
Top