Postado Quinta às 15:561 dia Esta dando error nesse script de egg de exp, alguem poderia concerta-lo porfavor ?script:local potions = { [6541] = {needLevel = 100, rate = 3.0, duration = 1800}, [6542] = {needLevel = 200, rate = 5.0, duration = 1800}, [6543] = {needLevel = 300, rate = 7.0, duration = 1800}, [6544] = {needLevel = 400, rate = 9.0, duration = 1800}, [6545] = {needLevel = 500, rate = 11.0, duration = 1800}, [2328] = {needLevel = 550, rate = 13.0, duration = 1800},}if not expPotions then expPotions = {playerData = {}}endfunction expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) local expData = self.playerData[guid][itemId] if not expData then -- caso alguma nova exp potion seja adicionada às configurações em tempo real -- alguns jogadores online que tentarem usar, precisarão relogar. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.') return true end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format( potion.rate * 100, string.diff(potion.duration, true) )) doRemoveItem(item.uid, 1) return trueendfunction expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = {} for itemId in pairs(potions) do self.playerData[guid][itemId] = {rate = 0, duration = 0} end return trueendfunction expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for itemId, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsComboendfunction expPotions:onSay(cid, words, param) local str = 'Experience Potion Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return trueendErro:[12:52:26.789] [Error - Action Interface][12:52:26.790] data/actions/scripts/exp_potion.lua:onUse[12:52:26.791] Description:[12:52:26.792] data/lib/exp_potion.lua:27: attempt to index field '?' (a nil value)[12:52:26.793] stack traceback:[12:52:26.794] data/lib/exp_potion.lua:27: in function <data/lib/exp_potion.lua:14>[12:52:26.795] (tail call): ?
Postado Quinta às 18:481 dia Tenta dessa forma.local potions = { [6541] = {needLevel = 100, rate = 3.0, duration = 1800}, [6542] = {needLevel = 200, rate = 5.0, duration = 1800}, [6543] = {needLevel = 300, rate = 7.0, duration = 1800}, [6544] = {needLevel = 400, rate = 9.0, duration = 1800}, [6545] = {needLevel = 500, rate = 11.0, duration = 1800}, [2328] = {needLevel = 550, rate = 13.0, duration = 1800},}if not expPotions then expPotions = {playerData = {}}endfunction expPotions:onUse(cid, item, fromPosition, itemEx, toPosition) local itemId = item.itemid local potion = potions[itemId] if not potion then return false end if getPlayerLevel(cid) < potion.needLevel then doPlayerSendCancel(cid, ('Você precisa ser level %d+ para usar esta potion.'):format(potion.needLevel)) return true end local guid = getPlayerGUID(cid) -- Inicializa playerData se necessário if not self.playerData[guid] then self.playerData[guid] = {} for id in pairs(potions) do self.playerData[guid][id] = {rate = 0, duration = 0} end end local expData = self.playerData[guid][itemId] if not expData then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'É necessário relogar para atualizar.') return true end local now = os.time() if expData.duration > now then doCreatureSay(cid, 'Aguarde o bônus atual acabar para usar novamente.', TALKTYPE_ORANGE_1, false, cid) return true end expData.rate = expData.rate + potion.rate expData.duration = potion.duration + now doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ('Agora você tem +%d%% de experiência por %s.'):format( potion.rate * 100, string.diff(potion.duration, true) )) doRemoveItem(item.uid, 1) return trueendfunction expPotions:onLogin(cid) local guid = getPlayerGUID(cid) self.playerData[guid] = {} for itemId in pairs(potions) do self.playerData[guid][itemId] = {rate = 0, duration = 0} end return trueendfunction expPotions:getCombo(cid) local playerData = self.playerData[getPlayerGUID(cid)] local potionsCombo = 1 if playerData then for _, expData in pairs(playerData) do potionsCombo = potionsCombo + expData.rate end end return potionsComboendfunction expPotions:onSay(cid, words, param) local str = 'Experience Potion Combos:\n' local playerData = self.playerData[getPlayerGUID(cid)] if playerData then for itemId, expData in pairs(playerData) do str = str .. ('\n%s - %d%%'):format(getItemInfo(itemId).name, expData.rate * 100) end end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, str) return trueend
Postado Quinta às 22:161 dia Autor 3 horas atrás, Carlinsz disse:Tenta dessa forma.Nao funcionou, deu seguinte errror...[19:15:14.126] [Error - Action Interface][19:15:14.128] data/actions/scripts/exp_potion.lua:onUse[19:15:14.128] Description:[19:15:14.129] data/lib/exp_potion.lua:87: attempt to call field 'diff' (a nil value)[19:15:14.130] stack traceback:[19:15:14.131] data/lib/exp_potion.lua:87: in function <data/lib/exp_potion.lua:23>[19:15:14.132] (tail call): ?
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.