Postado Dezembro 26, 2018 7 anos Base: OTX 3.8 Qual erro está surgindo/O que você procura? Lua Script Error: [Action Interface] data/actions/scripts/skills/woodcutting.lua:onUse data/lib/custom/skill.lua:71: attempt to call method 'send' (a nil value) stack traceback: [C]: in function 'send' data/lib/custom/skill.lua:71: in function 'update' data/actions/scripts/skills/woodcutting.lua:26: in function <data/actions/scripts/skills/woodcutting.lua:24> Você tem o código disponível? Se tiver publique-o aqui: Woodcutting.lua local multi = 10 -- multiplicador de tries pra ganhar no skill (2x + rapido de upar) cortar = {} -- players que estao no evento de cortar arvore continuamente :) local tree = { [7024] = {itemid = 7024, dead = 2709, level = 00, logs = 5901, minlog = 03, maxlog = 05, hard = 1.0, regmin = 050, regmax = 080}, -- cedar [188] = {itemid = 188, dead = 190, level = 05, logs = 2111, minlog = 05, maxlog = 07, hard = 1.0, regmin = 080, regmax = 105}, -- cedar [191] = {itemid = 191, dead = 193, level = 20, logs = 2680, minlog = 03, maxlog = 05, hard = 1.6, regmin = 100, regmax = 160}, -- oak [192] = {itemid = 192, dead = 195, level = 25, logs = 2680, minlog = 05, maxlog = 07, hard = 1.6, regmin = 130, regmax = 190}, -- oak [196] = {itemid = 196, dead = 198, level = 35, logs = 2674, minlog = 03, maxlog = 05, hard = 1.9, regmin = 270, regmax = 350}, -- teak [197] = {itemid = 197, dead = 199, level = 40, logs = 2674, minlog = 05, maxlog = 07, hard = 1.9, regmin = 300, regmax = 380}, -- teak } local breac = { -- machados [2430] = {skill = 00, soul = 0, breakchance = 00250, bonus = 1.0}, [2428] = {skill = 15, soul = 0, breakchance = 00600, bonus = 1.2}, [2427] = {skill = 30, soul = 0, breakchance = 01500, bonus = 1.6}, [2431] = {skill = 45, soul = 0, breakchance = 03000, bonus = 1.8}, [2432] = {skill = 60, soul = 0, breakchance = 06000, bonus = 2.2}, } if not WoodcuttingSkill then WoodcuttingSkill = SKILLClass:new(SKILL_CONST.IDS.WOODCUTTING) end function onUse(cid, item, fromPosition, itemEx, toPosition) WoodcuttingSkill:update(cid) if not tree[itemEx.itemid] then ---- I N V A L I D A X E return doPlayerSendCancel(cid, "You cannot use the axe here.") elseif tree[itemEx.itemid].level > WoodcuttingSkill:getLevel(cid) then return doPlayerSendCancel(cid, "You need skill " .. tree[itemEx.itemid].level .. " to cut this tree.") end if not breac[item.itemid] then ---- I N V A L I D A X E doPlayerSendTextMessage(cid, 22, "Fail - invalid axe") print("[SKILL ERROR] - actions/scripts/skills/woodcutting.lua") return false elseif WoodcuttingSkill:getLevel(cid) < breac[item.itemid].skill then return doPlayerSendCancel(cid, "You need at least skill " .. breac[item.itemid].skill .. " to use this axe.") elseif breac[item.itemid].soul > getPlayerSoul(cid) then return doPlayerSendTextMessage(cid, 25, "You need " .. breac[item.itemid].soul .. " fatigue to woodcut with this axe.") end local chance = breac[item.itemid].bonus -- quanto maior mais facil -------------------------------------------------------------------------------- if not cortar[cid] then cortar[cid] = 0 -- inicializa end if cortar[cid] == 0 then doPlayerAddSoul(cid, - breac[item.itemid].soul) cortar[cid] = 1 getAtributo(itemEx.uid, "hp", true, math.random(tree[itemEx.itemid].minlog, tree[itemEx.itemid].maxlog)) -- pra resetar o atributo caso nao tenha continue_cut({cid=cid, item = item.itemid, pos = getPlayerPosition(cid), place = toPosition, chance = chance, name = getPlayerName(cid)}, tree[itemEx.itemid], breac[item.itemid].breakchance) else -- parar de cortar doPlayerSendCancel(cid, "You stopped cutting the tree.") stopEvent(cortar[cid]) cortar[cid] = 0 -- reseta end return true end local function retornat(p, tree) local arvore = getTileItemById(p.place, tree.dead) if arvore.uid > 0 then doItemSetAttribute(arvore.uid, "hp", math.random(tree.minlog, tree.maxlog)) doTransformItem( arvore.uid, tree.itemid) doSendMagicEffect(p.place, 3) end end function continue_cut(p, tree, break_chance) -- continua cortando continuamente local arvore = getTileItemById(p.place, tree.itemid) if arvore.uid > 0 then if isCreature(p.cid) and isCreature(getTopCreature(p.pos).uid) then -- as 4 condicoes necessarias sempre if p.name == getPlayerName( getTopCreature(p.pos).uid ) then if getPlayerItemCount(p.cid, p.item) > 0 then local hp = getAtributo(arvore.uid, "hp").value doSendDistanceShoot(p.pos, p.place, 39) --print("> Hp " .. hp ) if hp <= 0 then -- quebrar arvores doSendMagicEffect(p.place, 3) if getTileItemById(p.place, tree.itemid).uid > 0 then -- evitar conflitos doTransformItem(arvore.uid, tree.dead) addEvent(retornat, 1000 * math.random(tree.regmin, tree.regmax), p, tree) end elseif (math.random(1,1000) * p.chance / tree.hard) + (WoodcuttingSkill:getLevel(p.cid) * 10) >= 900 then -- GANHAR LOGS local bonus = math.random(1,10) == 10 and 2 or 1 -- 1 ou 2 doPlayerAddItem(p.cid, tree.logs, bonus) WoodcuttingSkill:addExp(p.cid, math.floor(bonus * multi * tree.hard)) ACHIEVEMENT.add(p.cid, 'skill_wc_1', bonus) ACHIEVEMENT.add(p.cid, 'skill_wc_2', bonus) ACHIEVEMENT.add(p.cid, 'skill_wc_3', bonus) doSendMagicEffect(p.place, 9) doItemSetAttribute(arvore.uid, "hp", hp - 1) elseif math.random(1,1000) >= 875 * p.chance then -- TOMAR DANO local dano = (math.random(10, 25)) --doCreatureAddHealth(p.cid, -dano) --doSendAnimatedText(p.pos, dano, 129) doSendMagicEffect(p.place, 2) -- era efeito 0(sangue) troquei pro 2 else -- NADA ACONTECEU doSendMagicEffect(p.place, 2) end if math.random(1, break_chance) == 1 then -- Q U E B R O U O A X E doPlayerSendTextMessage(p.cid, 22, "Your woodcutting axe has broken.") doSendMagicEffect(getPlayerPosition(p.cid), 3) doPlayerRemoveItem(p.cid, p.item, 1) return true end if hp > 0 then cortar[p.cid] = addEvent(continue_cut, 2500, p, tree, break_chance) return true end end end end end cortar[p.cid] = 0 -- como ele parou de bater na arvore, ele agora carrega o valor 0 pra poder voltar :) end -- SKILLS -- SKILL_CONST = { STARTING_LEVEL = 1, STRUCTURE = { STORAGE = STORAGE_SKILL_STRUCTURE, SIZE = 2, OFFSET = { LEVEL = 0, EXP = 1, }, }, } SKILL_CONST.IDS = { _FIRST = 0, WOODCUTTING = 0, MINING = 1, _LAST = 1, } SKILL_CONST.NAMES = { [SKILL_CONST.IDS.WOODCUTTING] = "Woodcutting", [SKILL_CONST.IDS.MINING] = "Mining", } SKILLClass = {} function SKILLClass:new(SKILL_ID) if not SKILL_ID then print("[ERROR - lib/skill_class.lua] Invalid SKILL_ID") end return setmetatable({id = SKILL_ID, name = SKILL_CONST.NAMES[SKILL_ID]}, { __index = self }) end function SKILLClass:__getStorage(cid, offset) -- internal only return SKILL_CONST.STRUCTURE.STORAGE + self.id * SKILL_CONST.STRUCTURE.SIZE + offset end function SKILLClass:getLevel(cid) return getPlayerStorageValue(cid, self:__getStorage(cid, SKILL_CONST.STRUCTURE.OFFSET.LEVEL)) end function SKILLClass:getExp(cid) return getPlayerStorageValue(cid, self:__getStorage(cid, SKILL_CONST.STRUCTURE.OFFSET.EXP)) end function SKILLClass:setLevel(cid, level) return setPlayerStorageValue(cid, self:__getStorage(cid, SKILL_CONST.STRUCTURE.OFFSET.LEVEL), level) end function SKILLClass:setExp(cid, exp) return setPlayerStorageValue(cid, self:__getStorage(cid, SKILL_CONST.STRUCTURE.OFFSET.EXP), exp) end function SKILLClass:update(cid, _DONT_SEND) -- Iniciar no skill pela primeira vez if self:getLevel(cid) < 0 then self:setLevel(cid, SKILL_CONST.STARTING_LEVEL) self:setExp(cid, 0) end -- Passar de level if self:getExp(cid) >= self:getExpToLevel( self:getLevel(cid) + 1) then self:setLevel(cid, self:getLevel(cid) + 1) self:setExp(cid, 0) doPlayerSendTextMessage(cid, 22, 'You advanced to ' .. self.name:lower() .. ' skill ' .. self:getLevel(cid) .. '.') end if not _DONT_SEND then local DLL = DLLClass:new(cid) :addSkill(self.id, self:getLevel(cid), 100 - self:getPercentToUp(cid)) :send() end end function SKILLClass:addExp(cid, exp) self:setExp(cid, self:getExp(cid) + exp) self:update(cid) end function SKILLClass:getExpToLevel(level) return math.ceil(20 * (1.1) ^ (- 10 + level)) * 10 end function SKILLClass:getPercentToUp(cid) return 100 - math.ceil((100 * self:getExp(cid)) / self:getExpToLevel(self:getLevel(cid) + 1)) end function SKILLClass:getStatsDescription(cid) local str = "Your " .. self.name .. " level is " .. self:getLevel(cid) .. ", remaining " .. self:getPercentToUp(cid) .. "% to the next level." doPlayerSendTextMessage(cid, 22, str) end Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. Editado Dezembro 26, 2018 7 anos por Guiibwe (veja o histórico de edições)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.