Postado Abril 24, 2015 10 anos Olá, Galera estou com um problema no NPC reseter do meu servidor, é o seguinte; O script é do WhiteWolf e já corrigi alguns erros, no caso do meu servidor ele é 8.6. O problema é que tipo, ele não reseta, não desloga, apenas manda mensagem e fica no look o quanto de reset estou. Exemplo: Não resetei nenhuma vez, cheguei ao level 2500 e fui lá, resetei, só que voltei ao templo com a mesma vida, mana e level, apenas a mensagem no look muda. [Resets: 1]. Os erros na distro são: [24/04/2015 18:21:56] [Error - Npc interface] [24/04/2015 18:21:56] In a timer event called from: [24/04/2015 18:21:56] data/npc/scripts/resetador.lua:onCreatureSay [24/04/2015 18:21:56] Description: [24/04/2015 18:21:56] data/npc/scripts/resetador.lua:59: in function 'addReset' [24/04/2015 18:21:56] data/npc/scripts/resetador.lua:87: in function <data/npc/scripts/resetador.lua:85> Script do resetador.lua: --[[script made 100% by Nogard and Night Wolf. You can feel free to edit anything you want, but don't remove the credits]] local config = { minlevel = 2500, --- level inical para resetar price = 90000, --- preço inicial para resetar newlevel = 8, --- level após reset priceByReset = 0, --- preço acrescentado por reset percent = 100, ---- 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, 36378) if resets < 0 then resets = 0 end return resets 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, 36378, 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.query("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."") db.query("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 do resetador.xml: <npc name="Resetador" script="data/npc/scripts/resetador.lua" access="5" lookdir="1"> <health now="1000" max="1000"/> <look type="131" head="95" body="86" legs="86" feet="38" addons="3"/> <parameters> <parameter key="message_greet" value="Hello |PLAYERNAME|.I've been waiting for you to come.. Say 'reset' or 'quantity'" /> <parameter key="message_farewell" value="Cya folk." /> <parameter key="message_walkaway" value="How Rude!" /> </parameters> </npc> Versão: 8.6 TFS 0.4 Se alguém consegui me ajudar, ficarei muito grato, só falta isso para meu server, agradeço desde já. Feliz daquele que ensina o que sabe, e aprende o que ensina.
Postado Abril 24, 2015 10 anos adicione na primeira linha em libs/function function getResets(uid) resets = getPlayerStorageValue(uid, 36378) if resets < 0 then resets = 0 end return resets end Editado Abril 24, 2015 10 anos por poko360 (veja o histórico de edições)
Postado Abril 24, 2015 10 anos Autor adicione na primeira linha em libs/function function getResets(uid) resets = getPlayerStorageValue(uid, 36378) if resets < 0 then resets = 0 end return resets end Cara, continua esse erro: [24/04/2015 19:25:44] [Error - Npc interface] [24/04/2015 19:25:44] In a timer event called from: [24/04/2015 19:25:44] data/npc/scripts/resetador.lua:onCreatureSay [24/04/2015 19:25:44] data/npc/scripts/resetador.lua:59: in function 'addReset' [24/04/2015 19:25:44] data/npc/scripts/resetador.lua:87: in function <data/npc/scripts/resetador.lua:85> Desculpas a demora. Feliz daquele que ensina o que sabe, e aprende o que ensina.
Postado Abril 24, 2015 10 anos em npc/scripts/resetador.lua tente mudar todas as db.query por db.executeQuery ou db.Query
Postado Abril 24, 2015 10 anos Autor em npc/scripts/resetador.lua tente mudar todas as db.query por db.executeQuery ou db.Query Já fiz isso agora, nenhum bate Feliz daquele que ensina o que sabe, e aprende o que ensina.
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.