Postado Março 14, 2018 7 anos Fala, galera! Então, estou usando esse de reset, porém ele não está voltando para o level e nem aparecendo no look! Por favor, ajudam! Spoiler local config = { minlevel = 500, --- level inical para resetar price = 10000, --- preço inicial para resetar newlevel = 20, --- level após reset priceByReset = 0, --- preço acrescentado por reset percent = 8, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total) maxresets = 50, levelbyreset = 0 --- quanto de level vai precisar a mais no próximo reset } --- end config function getResets(uid) resets = getPlayerStorageValue(uid, 378378) if resets < 0 then resets = 0 end return resets end function onLook(cid, thing, position, lookDistance) if isPlayer(thing.uid) then resets = getPlayerStorageValue(thing.uid, 378378)+1 doPlayerSetSpecialDescription(thing.uid, "\nResets: [" .. resets .."]") end return true end local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid function addReset(cid) if(npcHandler:isFocused(cid)) then npcHandler:releaseFocus(cid) end talkState[talkUser] = 0 resets = getResets(cid) setPlayerStorageValue(cid, 378378, resets+1) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) local hp = getCreatureMaxHealth(cid) local resethp = hp*(config.percent/100) setCreatureMaxHealth(cid, resethp) local differencehp = (hp - resethp) doCreatureAddHealth(cid, -differencehp) local mana = getCreatureMaxMana(cid) local resetmana = mana*(config.percent/100) setCreatureMaxMana(cid, resetmana) local differencemana = (mana - resetmana) doCreatureAddMana(cid, -differencemana) doRemoveCreature(cid) local description = resets+1 db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."") db.executeQuery("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."") return true end local newPrice = config.price + (getResets(cid) * config.priceByReset) local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset) if msgcontains(msg, 'reset') then if getResets(cid) < config.maxresets then selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid) talkState[talkUser] = 1 else selfSay('You already reached the maximum reset level!', cid) end elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if getPlayerMoney(cid) < newPrice then selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid) elseif getPlayerLevel(cid) < newminlevel then selfSay('The minimum level for reseting is '..newminlevel..'!', cid) else doPlayerRemoveMoney(cid,newPrice) playerid = getPlayerGUID(cid) addEvent(function() if isPlayer(cid) then addReset(cid) end end, 3000) local number = getResets(cid)+1 local msg ="---[Reset: "..number.."]-- You have reseted! You'll be disconnected in 3 seconds." doPlayerPopupFYI(cid, msg) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end talkState[talkUser] = 0 elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then talkState[talkUser] = 0 npcHandler:releaseFocus(cid) selfSay('Ok.', cid) elseif msgcontains(msg, 'quantity') then selfSay('You have a total of '..getResets(cid)..' reset(s).', cid) talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) E está dando esse erro no console: Spoiler [21:51:24.263] [Error - NpcScript Interface] [21:51:24.269] In a timer event called from: [21:51:24.275] data/npc/scripts/isolda.lua:onCreatureSay [21:51:24.281] Description: [21:51:24.283] data/npc/scripts/isolda.lua:65: attempt to call field 'executeQuery' (a nil value) [21:51:24.295] stack traceback: [21:51:24.299] data/npc/scripts/isolda.lua:65: in function 'addReset' [21:51:24.305] data/npc/scripts/isolda.lua:91: in function <data/npc/scripts/isolda.lua:89> @Sttorm @jeremias Editado Março 14, 2018 7 anos por Yamborghini (veja o histórico de edições)
Postado Março 14, 2018 7 anos Vou tentar te ajudar por partes, certo? Esse errinho de executeQuery é que em algumas versões são compiladas como db.query, que são iguais, ou seja, mesmas funções. Então, tente trocar essas funções no código, ontem tem executeQuery, troque por db.query.
Postado Março 14, 2018 7 anos Autor Agora, lordzetros disse: Vou tentar te ajudar por partes, certo? Esse errinho de executeQuery é que em algumas versões são compiladas como db.query, que são iguais, ou seja, mesmas funções. Então, tente trocar essas funções no código, ontem tem executeQuery, troque por db.query. perfeito! saiu os erros! aproveitando o tópico, está dando esse erro tambem Spoiler [22:9:47.175] [Error - CreatureScript Interface] [22:9:47.180] In a timer event called from: [22:9:47.184] data/creaturescripts/scripts/aura.lua:onLogin [22:9:47.192] Description: [22:9:47.195] data/creaturescripts/scripts/aura.lua:11: attempt to index field '?' (a nil value) [22:9:47.204] stack traceback: [22:9:47.206] data/creaturescripts/scripts/aura.lua:11: in function <data/creaturescripts/scripts/aura.lua:10> Spoiler local tab = { [13] = {effect = 58}, -- [vocationID] = {effect = Number} [14] = {effect = 58}, [15] = {effect = 58}, [16] = {effect = 58} } local delay = 3 -- tempo do efeito da aura em segundos function ariseAura(cid) doSendMagicEffect(getThingPos(cid), tab[getPlayerVocation(cid)].effect) addEvent(ariseAura, delay * 1000, cid) return true end function onLogin(cid) if tab[getPlayerVocation(cid)] then ariseAura(cid) end return true end Editado Março 14, 2018 7 anos por Yamborghini (veja o histórico de edições)
Postado Março 14, 2018 7 anos Certo, então vamos para outra parte, pode me enviar como está na distro agora?
Postado Março 14, 2018 7 anos Autor Agora, lordzetros disse: Certo, então vamos para outra parte, pode me enviar como está na distro agora? então, deu tudo certo! o level mudou e agora apareceu no look os resets! poderia me ajudar nesse erro? aproveitando o tópico? erro: Spoiler [22:9:47.175] [Error - CreatureScript Interface] [22:9:47.180] In a timer event called from: [22:9:47.184] data/creaturescripts/scripts/aura.lua:onLogin [22:9:47.192] Description: [22:9:47.195] data/creaturescripts/scripts/aura.lua:11: attempt to index field '?' (a nil value) [22:9:47.204] stack traceback: [22:9:47.206] data/creaturescripts/scripts/aura.lua:11: in function <data/creaturescripts/scripts/aura.lua:10> script Spoiler local tab = { [13] = {effect = 58}, -- [vocationID] = {effect = Number} [14] = {effect = 58}, [15] = {effect = 58}, [16] = {effect = 58} } local delay = 3 -- tempo do efeito da aura em segundos function ariseAura(cid) doSendMagicEffect(getThingPos(cid), tab[getPlayerVocation(cid)].effect) addEvent(ariseAura, delay * 1000, cid) return true end function onLogin(cid) if tab[getPlayerVocation(cid)] then ariseAura(cid) end return true end
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.