Postado Janeiro 4, 2017 8 anos 33 minutos atrás, koringa disse: alguém pode me ajuda ? Aqui vai a script arrumada Spoiler local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) --Config local cost = 2000000 local level = 200 local needPremium = true --If the player will need premium account local promotionNumber = 1 local basics = { --Adjust the level 8 stats health = 185, mana = 35, cap = 400 } local willTeleport = false --will the player be teleported to his town? local willLogout = false -- will the player be forced to logout? --/Config local function getExpForLevel(level) level = level - 1 return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3 end local function doPromote(cid) if player:getStorageValue(Storage.Promotion) == promotionNumber then npcHandler:say("You are already promoted!", cid) if player:getStorageValue(Storage.Promotion) == 1 and promotionNumber == 2 then npcHandler:say("You need the first promotion!", cid) else player:setStorageValue(Storage.Promotion, promotionNumber) player:setVocation(player:getVocation():getPromotion()) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) npcHandler:say("Congratulations! You are now promoted.", cid) player:setMaxHealth(basics.health) player:setMaxMana(basics.mana) player:setCapacity(basics.cap) player:removeExperience(player:getExperience() - getExpForLevel(8), false) npcHandler.topic[cid] = 0 if willTeleport then player:teleportTo(player:getTown():getTemplePosition()) end if willLogout then player:remove() end end end 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) npcHandler.topic[cid] = 0 return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false elseif msgcontains(msg, "promotion") and npcHandler.topic[cid] == 0 then npcHandler:say({"Do you want to be promoted?"}, cid) npcHandler.topic[cid] = 1 elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "yes") then if player:getLevel()<level then npcHandler:say({"You need level " .. level .. " to be promoted."}, cid) npcHandler.topic[cid] = 0 elseif needPremium and not player:isPremium() then npcHandler:say({"You need a premium account to be promoted."}, cid) npcHandler.topic[cid] = 0 elseif player:removeMoneyNpc(cost) then doPromote(cid) else npcHandler:say({"You can\'t be promoted."}, cid) npcHandler.topic[cid] = 0 end elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "no") then npcHandler:say({"Then no."}, cid) npcHandler.topic[cid] = 0 end return true end end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Janeiro 4, 2017 8 anos Autor @PedroSTT Rapaz na hora que eu consegui arruma vc posto isso ai, o meu aconteceu o seguinte, eu falo (hi - promotion) ele responde normal, mas quando eu falo "yes" ele já não me responde mais. o teu o npc nem responde ao "hi" mas valew pela ajuda ai.
Postado Janeiro 4, 2017 8 anos 2 minutos atrás, koringa disse: @PedroSTT Rapaz na hora que eu consegui arruma vc posto isso ai, o meu aconteceu o seguinte, eu falo (hi - promotion) ele responde normal, mas quando eu falo "yes" ele já não me responde mais. o teu o npc nem responde ao "hi" mas valew pela ajuda ai. O NPC não é meu , é o que o cara postou a cima que eu arrumei , se não esta dando certo é erro seu .
Postado Janeiro 5, 2017 8 anos Autor Se Alguém puder ajuda, está dando o seguinte erro aqui. Spoiler o script ta assim Spoiler local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) --Config local cost = 2000000 local level = 200 local needPremium = true --If the player will need premium account local promotionNumber = 1 local basics = { --Adjust the level 8 stats health = 185, mana = 35, cap = 400 } local willTeleport = false --will the player be teleported to his town? local willLogout = false -- will the player be forced to logout? --/Config local function getExpForLevel(level) level = level - 1 return ((50 * level * level * level) - (150 * level * level) + (400 * level)) / 3 end local function doPromote(cid) if player:getStorageValue(Storage.Promotion) == promotionNumber then npcHandler:say("You are already promoted!", cid) elseif player:getStorageValue(Storage.Promotion) == 1 and promotionNumber == 2 then npcHandler:say("You need the first promotion!", cid) else player:setStorageValue(Storage.Promotion, promotionNumber) player:setVocation(player:getVocation():getPromotion()) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) npcHandler:say("Congratulations! You are now promoted.", cid) player:setMaxHealth(basics.health) player:setMaxMana(basics.mana) player:setCapacity(basics.cap) player:removeExperience(player:getExperience() - getExpForLevel(8), false) npcHandler.topic[cid] = 0 if willTeleport then player:teleportTo(player:getTown():getTemplePosition()) end if willLogout then player:remove() end end end 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) npcHandler.topic[cid] = 0 return true end local function creatureSayCallback(cid, type, msg) if not npcHandler:isFocused(cid) then return false elseif msgcontains(msg, "promotion") and npcHandler.topic[cid] == 0 then npcHandler:say({"Do you want to be promoted?"}, cid) npcHandler.topic[cid] = 1 elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "yes") then if player:getLevel()<level then npcHandler:say({"You need level " .. level .. " to be promoted."}, cid) npcHandler.topic[cid] = 0 elseif needPremium and not player:isPremium() then npcHandler:say({"You need a premium account to be promoted."}, cid) npcHandler.topic[cid] = 0 elseif player:removeMoneyNpc(cost) then doPromote(cid) else npcHandler:say({"You can\'t be promoted."}, cid) npcHandler.topic[cid] = 0 end elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "no") then npcHandler:say({"Then no."}, cid) npcHandler.topic[cid] = 0 end return true end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
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.