Postado Abril 30, 2020 5 anos Oi pessoal! Estou com um problema no meu ot. Nele há um sistema de upar o lvl dos itens, de acordo com a exp que o player vai acumulando ao longo do tempo. Acontece que, quando o item alcança o level máximo (10), ocorre um bug que os bichos não morrem mais. O hp chega a zero, mas ele "não vira corpo" (print para exemplificar) Desde já agradeço! ? Mensagem de erro: Citar [Error - CreatureScript Interface] data/creaturescripts/scripts/killuaItemUp.lua:onKill Description: data/creaturescripts/scripts/killuaItemUp.lua:41: attempt to compare two nil values stack traceback: data/creaturescripts/scripts/killuaItemUp.lua:41: in function 'doItemAddExp' data/creaturescripts/scripts/killuaItemUp.lua:88: in function Você tem o código disponível? Se tiver publique-o aqui: -- Itens Upgrade System feito por Killua (Vítor Bertolucci) local min_exp = 2000 -- Exp mínima para o monstro valer (exp que fica no monster.xml) local exp_levels = {100000, 245000, 499500, 743300, 967000, 1317400, 2038000, 3800000, 5214000, 7130000} -- Exp pra upar. A cada vez que um item atingir um desses valores de exp, ele upa 1 lvl. (Tem 10, ou seja, nível máximo do item = 10) Pode por mais leveis se quiser. local slots = {1,4,7,8,5,6} local wands = {7735,7414,7410,7424} local function getItemExp(item) if item.itemid > 0 then return getItemAttribute(item.uid, "exp") or tonumber(0) end return false end local function getItemLevel(experience) if experience < exp_levels[1] then return tonumber(0) end local old = 1 for i = 2,10 do if experience < exp_levels and experience >= exp_levels[old] then return tonumber(old) end old = i end end local function getMonsterItemExp (cid,monsterExp) local n = monsterExp * 2.71828182846 local lvl = getPlayerLevel(cid) n = (n / (lvl ^ (2.71828182846/10)))/1000 return math.floor(n) end local function doItemAddExp(cid,item,exp) if item.itemid > 0 and tonumber(exp) then local exp_now = getItemExp(item) local oldLevel = getItemLevel(exp_now) doItemSetAttribute(item.uid, "exp", exp_now + exp) local newLevel = getItemLevel(getItemExp(item)) if oldLevel < newLevel then local isPair = newLevel%2 == 0 and true or false local attribute = isPair and 1 or 2 -- Upar o item local itemName = getItemNameById(item.itemid) doItemSetAttribute(item.uid,"name",itemName.." +"..newLevel) if isShield(item.uid) then local def = getItemAttribute(item.uid, "defense") or getItemInfo(item.itemid).defense doItemSetAttribute(item.uid,"defense", def + attribute) doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Seu "..itemName.." upou para o level "..newLevel.." e recebeu +".. attribute .." de defesa.") elseif (isSword(item.uid) or isAxe(item.uid) or isClub(item.uid) or isBow(item.uid)) then local atk = getItemAttribute(item.uid, "attack") or getItemInfo(item.itemid).attack doItemSetAttribute(item.uid,"attack", atk + attribute) doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Seu "..itemName.." upou para o level "..newLevel.." e recebeu +".. attribute .." de ataque.") elseif isArmor(item.itemid) then local arm = getItemAttribute(item.uid, "armor") or getItemInfo(item.itemid).armor doItemSetAttribute(item.uid,"armor", arm + attribute) doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Seu "..itemName.." upou para o level "..newLevel.." e recebeu +".. attribute .." de arm.") elseif isWand(item.uid) and isInArray(wands,item.itemid) then doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE,"Sua "..itemName.." upou para o level "..newLevel.." e recebeu +5% de poder de ataque") end end end return false end function onKill(cid, target, lastHit) if isPlayer(cid) and isMonster(target) and not isSummon(target) then local monsterName = getCreatureName(target) if not monsterName or type(monsterName) ~= "string" then return true end local monster = getMonsterInfo(monsterName) if not monster then return true end local monsterExp = getMonsterInfo(monsterName).experience if not monsterExp then return true end local exp_gain = getMonsterItemExp(cid,monsterExp) if monsterExp >= min_exp then for _,b in pairs(slots) do local item = getPlayerSlotItem(cid, b) if item.uid > 0 then if isArmor(item.itemid) or isShield(item.uid) or isWand(item.uid) or isAxe(item.uid) or isSword(item.uid) or isClub(item.uid) or isBow(item.uid) then doItemAddExp(cid, item, exp_gain) --local itemExp = getItemExp(item) --doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,"Seu "..getItemNameById(item.itemid).." ganhou "..exp_gain.." pontos de exp ao derrotar um "..monsterName..". Ele tem ["..itemExp.."/".. exp_levels[ getItemLevel(itemExp) +1] .."] pontos atualmente.") end end end end end return true end function onLogin(cid) registerCreatureEvent(cid, "Item level") return true end Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
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.