Postado Dezembro 26, 2016 8 anos Boa tarde, estou criando um npc que muda a vocação 0 do character para a vocação 1, 2 ou 3. Para isso o personagem precisa estar pelo menos no level 8. A mudança só pode ser feita uma única vez. O problema é que o npc não executa os comandos de quando o personagem está no nível 8. O script: Spoiler local level = 8 local stor = 437369 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) local playerlevel = getPlayerLevel(cid) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'yes') and playerlevel >= level) then selfSay('So you are a decided one. What is your path? Follow your natural instincts as a {savage}. Bend the elements arround you, become a {mage}. Face and fright your enemies, {warrior}!', cid) if(msgcontains(msg, 'mage') and getPlayerStorageValue(cid, stor) < 1) then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 1) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a mage.", cid) talkState[talkUser] = 1 elseif(msgcontains(msg, 'savage') and getPlayerStorageValue(cid, stor) < 1) then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 2) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a savage.", cid) talkState[talkUser] = 2 elseif(msgcontains(msg, 'warrior') and getPlayerStorageValue(cid, stor) < 1) then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 3) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a warrior.", cid) talkState[talkUser] = 3 end elseif(msgcontains(msg, 'no') or msgcontains(msg, 'No')) then selfSay('I will be waiting for you when you change your mind.', cid) else selfSay("You are not prepared yet. Come back when you get stronger. Reach level 8", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Quando o personagem digita mage, savage ou warrior estando level 8. O npc executa "selfSay("You are not prepared yet. Come back when you get stronger. Reach level 8", cid)" Grato pela atenção. Editado Dezembro 26, 2016 8 anos por Hoad (veja o histórico de edições)
Postado Dezembro 26, 2016 8 anos local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local level = 8 local stor = 437369 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) local playerlevel = getPlayerLevel(cid) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'yes') and playerlevel >= level and getPlayerVocation == 0 then selfSay('So you are a decided one. What is your path? Follow your natural instincts as a {savage}. Bend the elements arround you, become a {mage}. Face and fright your enemies, {warrior}!', cid) if msgcontains(msg, 'mage') and getPlayerStorageValue(cid, stor) <= 0 then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 1) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a mage.", cid) talkState[talkUser] = 1 elseif msgcontains(msg, 'savage') and getPlayerStorageValue(cid, stor) <= -1 then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 2) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a savage.", cid) talkState[talkUser] = 2 elseif msgcontains(msg, 'warrior') and getPlayerStorageValue(cid, stor) <= -1 then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 3) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a warrior.", cid) talkState[talkUser] = 3 end elseif msgcontains(msg, 'no') or msgcontains(msg, 'No') then selfSay('I will be waiting for you when you change your mind.', cid) else selfSay("You are not prepared yet. Come back when you get stronger. Reach level 8", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Dezembro 26, 2016 8 anos Autor Entao, fiz a mudança, entretanto o problema continua o mesmo. O npc manda a msg "So you are a decided one. What is your path? Follow your natural instincts as a {savage}. Bend the elements arround you, become a {mage}. Face and fright your enemies, {warrior}!" Entretanto, quando o personagem escolhe uma das vocações (mage, savage ou warrior) o npc retorna com: "You are not prepared yet. Come back when you get stronger. Reach level 8"
Postado Dezembro 26, 2016 8 anos tenta agora local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local level = 8 local stor = 437369 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) local playerlevel = getPlayerLevel(cid) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'yes') and getPlayerLevel(cid) >= 8 and getPlayerVocation == 0 then selfSay('So you are a decided one. What is your path? Follow your natural instincts as a {savage}. Bend the elements arround you, become a {mage}. Face and fright your enemies, {warrior}!', cid) if msgcontains(msg, 'mage') and getPlayerStorageValue(cid, stor) <= 0 then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 1) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a mage.", cid) talkState[talkUser] = 1 elseif msgcontains(msg, 'savage') and getPlayerStorageValue(cid, stor) <= -1 then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 2) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a savage.", cid) talkState[talkUser] = 2 elseif msgcontains(msg, 'warrior') and getPlayerStorageValue(cid, stor) <= -1 then doSendMagicEffect(getCreaturePosition(cid), 12) doPlayerSetVocation(cid, 3) setPlayerStorageValue(cid, stor, 1) selfSay("Congratulations! You have become a warrior.", cid) talkState[talkUser] = 3 end elseif msgcontains(msg, 'no') or msgcontains(msg, 'No') then selfSay('I will be waiting for you when you change your mind.', cid) else selfSay("You are not prepared yet. Come back when you get stronger. Reach level 8", cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Dezembro 26, 2016 8 anos Autor Nada ainda \: e pq na parte do savage e warrior vc pos storage tem q ser menos ou igual a -1?
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.