Postado Setembro 9, 2017 7 anos Oi galera do TK Então, eu estava configurando um NPC que funciona da seguinte forma : - Você chega nele e conversa com ele, apenas pra mudar sua vocação (só funciona pra level >=8 e <=20), é pra um sistema de dawnport com o NPC Oressa do Global. Eu reformulei o script assim : Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local vocation = {} local town = {} local config = { vocations = { ["sorcerer"] = { text = "A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 1, --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf --{{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, --container rope, shovel, mana potion --{{2120, 1}, {2554, 1}, {7620, 1}} }, ["druid"] = { text = "A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 2, --equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots scarf --{{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, --container rope, shovel, mana potion --{{2120, 1}, {2554, 1}, {7620, 1}} }, ["paladin"] = { text = "A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 3, --equipment dwrven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet --{{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}}, --container rope, shovel, health potion, bow, 50 arrow --{{2120, 1}, {2554, 1}, {7618, 1}, {2456, 1}, {2544, 50}} }, ["knight"] = { text = "A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 4, --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf --{{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}}, --container jagged sword, daramian mace, rope, shovel, health potion --{{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}} } } } 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 local function greetCallback(cid) local player = Player(cid) local level = player:getLevel() if level < 8 then npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP TO LEVEL 8 AND MAXIMUM LEVEL 20!", cid) npcHandler:resetNpc(cid) return false elseif level > 20 then npcHandler:say(player:getName() ..", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 20 OR LOWER.", cid) npcHandler:resetNpc(cid) return false else npcHandler:setMessage(MESSAGE_GREET, player:getName() ..", ARE YOU PREPARED TO FACE YOUR DESTINY?") end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if npcHandler.topic[cid] == 0 then if msgcontains(msg, "yes") then npcHandler:say("AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 1 end elseif npcHandler.topic[cid] == 1 then local vocationTable = config.vocations[msg:lower()] if vocationTable then vocation[cid] = vocationTable.vocationId npcHandler:say(vocationTable.text, cid) npcHandler:say("IN ".. string.upper(msg) .." VOCATION! ARE YOU SURE? IF YES SAY : ".. string.upper(msg) .." .", cid) npcHandler.topic[cid] = 2 else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 2 then local vocationTable = config.vocations[msg:lower()] if vocationTable then npcHandler:say(vocationTable.text, cid) npcHandler.topic[cid] = 3 vocation[cid] = vocationTable.vocationId else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 3 then if msgcontains(msg, "yes") then npcHandler:say("SO BE IT!", cid) if Vocation(vocation[cid]) ~= player:getVocation() then player:setVocation(Vocation(vocation[cid])) player:setMaxHealth(130 + (player:getVocation():getHealthGain() * player:getLevel())) player:addHealth(player:getMaxHealth()) player:setMaxMana(0 + (player:getVocation():getManaGain() * player:getLevel())) player:addMana(player:getMaxMana()) player:setCapacity(40000 + (player:getVocation():getCapacityGain() * player:getLevel())) player:setTown(Town(town[cid])) player:teleportTo(Town(town[cid]):getTemplePosition()) local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(player:getName():lower())) local accountId = result.getDataInt(resultId, "id") player:remove() db.query("UPDATE `players` SET `maglevel` = '0', `manaspent` = '0', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `players`.`id` = " .. accountId) return end player:setVocation(Vocation(vocation[cid])) player:setTown(Town(town[cid])) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) player:teleportTo(Town(town[cid]):getTemplePosition()) else npcHandler:say("THEN WHAT? {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 2 end end return true end local function onAddFocus(cid) town[cid] = 0 vocation[cid] = 0 end local function onReleaseFocus(cid) town[cid] = nil vocation[cid] = nil end npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!") npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!") npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) O script funciona normalmente, ele troca a vocation do player e reconfigura os stats (vida, mana, skills). Porém surge um erro na distro (segue no anexo). Quero saber como corrigir este erro e porque ele surge. Programador/Scripter/Mapper nível NOOB ?
Postado Setembro 9, 2017 7 anos Este tópico foi movido para a área correta. Esta é uma mensagem automática!Pedimos que leia as regras do fórum! Mostrar conteúdo oculto This topic has been moved to the correct area. This is an automated message!Please read the forum rules. @Xiolones Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local vocation = {} local town = {} local config = { vocations = { ["sorcerer"] = { text = "A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 1, --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf --{{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, --container rope, shovel, mana potion --{{2120, 1}, {2554, 1}, {7620, 1}} }, ["druid"] = { text = "A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 2, --equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots scarf --{{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, --container rope, shovel, mana potion --{{2120, 1}, {2554, 1}, {7620, 1}} }, ["paladin"] = { text = "A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 3, --equipment dwrven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet --{{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}}, --container rope, shovel, health potion, bow, 50 arrow --{{2120, 1}, {2554, 1}, {7618, 1}, {2456, 1}, {2544, 50}} }, ["knight"] = { text = "A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 4, --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf --{{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}}, --container jagged sword, daramian mace, rope, shovel, health potion --{{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}} } } } 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 local function greetCallback(cid) local player = Player(cid) local level = player:getLevel() if level < 8 then npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP TO LEVEL 8 AND MAXIMUM LEVEL 20!", cid) npcHandler:resetNpc(cid) return false elseif level > 20 then npcHandler:say(player:getName() ..", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 20 OR LOWER.", cid) npcHandler:resetNpc(cid) return false else npcHandler:setMessage(MESSAGE_GREET, player:getName() ..", ARE YOU PREPARED TO FACE YOUR DESTINY?") end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if npcHandler.topic[cid] == 0 then if msgcontains(msg, "yes") then npcHandler:say("AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 1 end elseif npcHandler.topic[cid] == 1 then local vocationTable = config.vocations[msg:lower()] if vocationTable then vocation[cid] = vocationTable.vocationId npcHandler:say(vocationTable.text, cid) npcHandler:say("IN ".. string.upper(msg) .." VOCATION! ARE YOU SURE? IF YES SAY : ".. string.upper(msg) .." .", cid) npcHandler.topic[cid] = 2 else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 2 then local vocationTable = config.vocations[msg:lower()] if vocationTable then npcHandler:say(vocationTable.text, cid) npcHandler.topic[cid] = 3 vocation[cid] = vocationTable.vocationId else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 3 then if msgcontains(msg, "yes") then npcHandler:say("SO BE IT!", cid) if Vocation(vocation[cid]) ~= player:getVocation() then player:setVocation(Vocation(vocation[cid])) player:setMaxHealth(130 + (player:getVocation():getHealthGain() * player:getLevel())) player:addHealth(player:getMaxHealth()) player:setMaxMana(0 + (player:getVocation():getManaGain() * player:getLevel())) player:addMana(player:getMaxMana()) player:setCapacity(40000 + (player:getVocation():getCapacityGain() * player:getLevel())) local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(player:getName():lower())) local accountId = result.getDataInt(resultId, "id") player:remove() db.query("UPDATE `players` SET `maglevel` = '0', `manaspent` = '0', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `players`.`id` = " .. accountId) return end player:setVocation(Vocation(vocation[cid])) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) else npcHandler:say("THEN WHAT? {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 2 end end return true end local function onAddFocus(cid) town[cid] = 0 vocation[cid] = 0 end local function onReleaseFocus(cid) town[cid] = nil vocation[cid] = nil end npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!") npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!") npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Outubro 23, 2023 1 ano Em 09/09/2017 em 15:03, KotZletY disse: Este tópico foi movido para a área correta. Esta é uma mensagem automática! Pedimos que leia as regras do fórum! Mostrar conteúdo oculto Mostrar conteúdo oculto This topic has been moved to the correct area. This is an automated message! Please read the forum rules. @Xiolones Mostrar conteúdo oculto Mostrar conteúdo oculto local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local vocation = {} local town = {} local config = { vocations = { ["sorcerer"] = { text = "A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 1, --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf --{{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, --container rope, shovel, mana potion --{{2120, 1}, {2554, 1}, {7620, 1}} }, ["druid"] = { text = "A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 2, --equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots scarf --{{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}}, --container rope, shovel, mana potion --{{2120, 1}, {2554, 1}, {7620, 1}} }, ["paladin"] = { text = "A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 3, --equipment dwrven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet --{{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}}, --container rope, shovel, health potion, bow, 50 arrow --{{2120, 1}, {2554, 1}, {7618, 1}, {2456, 1}, {2544, 50}} }, ["knight"] = { text = "A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", vocationId = 4, --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf --{{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}}, --container jagged sword, daramian mace, rope, shovel, health potion --{{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}} } } } 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 local function greetCallback(cid) local player = Player(cid) local level = player:getLevel() if level < 8 then npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP TO LEVEL 8 AND MAXIMUM LEVEL 20!", cid) npcHandler:resetNpc(cid) return false elseif level > 20 then npcHandler:say(player:getName() ..", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 20 OR LOWER.", cid) npcHandler:resetNpc(cid) return false else npcHandler:setMessage(MESSAGE_GREET, player:getName() ..", ARE YOU PREPARED TO FACE YOUR DESTINY?") end return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end local player = Player(cid) if npcHandler.topic[cid] == 0 then if msgcontains(msg, "yes") then npcHandler:say("AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 1 end elseif npcHandler.topic[cid] == 1 then local vocationTable = config.vocations[msg:lower()] if vocationTable then vocation[cid] = vocationTable.vocationId npcHandler:say(vocationTable.text, cid) npcHandler:say("IN ".. string.upper(msg) .." VOCATION! ARE YOU SURE? IF YES SAY : ".. string.upper(msg) .." .", cid) npcHandler.topic[cid] = 2 else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 2 then local vocationTable = config.vocations[msg:lower()] if vocationTable then npcHandler:say(vocationTable.text, cid) npcHandler.topic[cid] = 3 vocation[cid] = vocationTable.vocationId else npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) end elseif npcHandler.topic[cid] == 3 then if msgcontains(msg, "yes") then npcHandler:say("SO BE IT!", cid) if Vocation(vocation[cid]) ~= player:getVocation() then player:setVocation(Vocation(vocation[cid])) player:setMaxHealth(130 + (player:getVocation():getHealthGain() * player:getLevel())) player:addHealth(player:getMaxHealth()) player:setMaxMana(0 + (player:getVocation():getManaGain() * player:getLevel())) player:addMana(player:getMaxMana()) player:setCapacity(40000 + (player:getVocation():getCapacityGain() * player:getLevel())) local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(player:getName():lower())) local accountId = result.getDataInt(resultId, "id") player:remove() db.query("UPDATE `players` SET `maglevel` = '0', `manaspent` = '0', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `players`.`id` = " .. accountId) return end player:setVocation(Vocation(vocation[cid])) player:getPosition():sendMagicEffect(CONST_ME_TELEPORT) else npcHandler:say("THEN WHAT? {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid) npcHandler.topic[cid] = 2 end end return true end local function onAddFocus(cid) town[cid] = 0 vocation[cid] = 0 end local function onReleaseFocus(cid) town[cid] = nil vocation[cid] = nil end npcHandler:setCallback(CALLBACK_ONADDFOCUS, onAddFocus) npcHandler:setCallback(CALLBACK_ONRELEASEFOCUS, onReleaseFocus) npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!") npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!") npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Teria como deixar eles já com o promotion?
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.