Postado Fevereiro 15, 2015 10 anos Possuo 2 npc um ele manda eu entregar uma letter escrita para o outro para que depois eu possa ser promovido,um tipo de missão,o outro é o recebedor da letter que vai recolher o item e me adicionar uma storage ,que ao volta ao primeiro npc ele vai checar e recolher a carta e colocar outra storage indicando que foi feita a entrega. Meu problema é o seguinte,do jeito que esta após fazer a quest eu posso me promover seguidamente no 1º NPC porque o script só ta trocando as vocações e não esta setando a promotion na database para o valor 1,porque não possui essa função relacionada a promotion,apenas a vocação em meus scripts,vou postar aqui para melhor entendimento: NPC 1: 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 status = getPlayerStorageValue(cid,2590) local text = "Querido como voce esta? Espero que tenha tratado de sua saude mande-me noticias" --- Texto da carta local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'promotion') then if status == -1 then if getPlayerVocation(cid) < 4 then selfSay("So you need a promotion? I can give her for you, but first, give this letter to my brother, he always ask me if i'm god, bad, you now...", cid) setPlayerStorageValue(cid,2590,0) local item = doPlayerAddItem(cid,2597,1) doSetItemText(item,text) else selfSay("Sorry, you alredy have a promotion.", cid) end elseif status == 0 then selfSay("I'm waiting you deliver the letter...", cid) elseif status == 1 then selfSay("Hey, you delivered, thanks man, here is your promotion!", cid) doPlayerSetVocation(cid,getPlayerVocation(cid)+4) doSendMagicEffect(getCreaturePosition(cid),CONST_ME_MAGIC_BLUE) end talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) NPC 2 que retira a carta e adiciona storage: 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 status = getPlayerStorageValue(cid,2590) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'letter') then if status == 0 then setPlayerStorageValue(cid,2590,1) selfSay("Hey, thanks, it's my brother's letter. Thank You very much. I'm gonna say to his about you.", cid) doPlayerRemoveItem(cid,2590,1) end talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Acredito que oque eu preciso fazer é substituir a função doPlayerSetVocation(cid,getPlayerVocation(cid)+4) por algo do tipo doPlayerSetPromotionLevel(cid, 1) ,não tenho certeza se é essa função correta e nem em qual local seria,alguem pode fazer essa correção para mim? Obrigado.. ___EDIT___ apenas ressaltar que esse script abaixo funciona perfeitamente,mas não possui rpg: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 node1 = keywordHandler:addKeyword({'promotion'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'}) node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, cost = 20000, level = 20, promotion = 1, text = 'Congratulations! You are now promoted.'}) node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then, come back when you are ready.', reset = true}) npcHandler:addModule(FocusModule:new()) Editado Fevereiro 15, 2015 10 anos por Lyon (veja o histórico de edições)
Postado Fevereiro 15, 2015 10 anos 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 configs ={ 2590; -- Storage "Querido como voce esta? Espero que tenha tratado de sua saude mande-me noticias"; --- Texto da carta } local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'promotion') then if getPlayerStorageValue(cid, configs[1]) < 1 then if getPlayerVocation(cid) <= 4 then selfSay("So you need a promotion? I can give her for you, but first, give this letter to my brother, he always ask me if i'm god, bad, you now...", cid) local item = doPlayerAddItem(cid,2597,1); doSetItemText(item, configs[2]); else selfSay("Sorry, you alredy have a promotion.", cid); end elseif getPlayerStorageValue(cid, configs[1]) == 1 then selfSay("Hey, you delivered, thanks man, here is your promotion!", cid); local vocation = getPlayerVocation(cid) + 4; doPlayerSetVocation(cid, vocation); doSendMagicEffect(getCreaturePosition(cid),CONST_ME_MAGIC_BLUE); else selfSay("I'm waiting you deliver the letter...", cid); end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Fevereiro 15, 2015 10 anos por Summ (veja o histórico de edições)
Postado Fevereiro 15, 2015 10 anos O segundo NPC não necessita de ajustes: 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 _onCreatureSay(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local storage = getCreatureStorage(cid, 2590) if msgcontains(msg, "promotion") then if storage == -1 then if getPlayerPromotionLevel(cid) == 0 then selfSay("So you need a promotion? I can give her for you, but first, give this letter to my brother, he always ask me if I am good, bad, you know...", cid) doCreatureSetStorage(cid, 2590, 0) local item = doPlayerAddItem(cid, 2597, 1) local text = "Querido, como você está? Espero que tenha tratado de sua saúde, mande-me notícias!" doSetItemText(item, text) else selfSay("You already are promoted!", cid) -- No caso de haver outra maneira de promotion (?) end npcHandler:releaseFocus(cid) elseif storage == 0 then selfSay("I am waiting for you to deliver my letter...", cid) npcHandler:releaseFocus(cid) else selfSay("Hey, you delivered my letter! Thanks, man. Here is your promotion!", cid) doPlayerSetPromotionLevel(cid, 1) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE) npcHandler:releaseFocus(cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, _onCreatureSay) npcHandler:addModule(FocusModule:new())
Postado Fevereiro 15, 2015 10 anos Autor 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 configs ={ 2590; -- Storage "Querido como voce esta? Espero que tenha tratado de sua saude mande-me noticias"; --- Texto da carta } local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if msgcontains(msg, 'promotion') then if getPlayerStorageValue(cid, configs[1]) < 1 then if getPlayerVocation(cid) <= 4 then selfSay("So you need a promotion? I can give her for you, but first, give this letter to my brother, he always ask me if i'm god, bad, you now...", cid) local item = doPlayerAddItem(cid,2597,1); doSetItemText(item, configs[2]); else selfSay("Sorry, you alredy have a promotion.", cid); end elseif getPlayerStorageValue(cid, configs[1]) == 1 then selfSay("Hey, you delivered, thanks man, here is your promotion!", cid); local vocation = getPlayerVocation(cid) + 4; doPlayerSetVocation(cid, vocation); doSendMagicEffect(getCreaturePosition(cid),CONST_ME_MAGIC_BLUE); else selfSay("I'm waiting you deliver the letter...", cid); end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Summ,obrigado por se dispor ajudar,mas eu precisava que fosse mudado a função doPlayerSetVocation pela doPlayerSetPromotionLevel,mas agora o do Garou funcionou,mas vou reputar você assim que tiver pontos porque você mostrou interesse em ajudar,valew! O segundo NPC não necessita de ajustes: 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 _onCreatureSay(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local storage = getCreatureStorage(cid, 2590) if msgcontains(msg, "promotion") then if storage == -1 then if getPlayerPromotionLevel(cid) == 0 then selfSay("So you need a promotion? I can give her for you, but first, give this letter to my brother, he always ask me if I am good, bad, you know...", cid) doCreatureSetStorage(cid, 2590, 0) local item = doPlayerAddItem(cid, 2597, 1) local text = "Querido, como você está? Espero que tenha tratado de sua saúde, mande-me notícias!" doSetItemText(item, text) else selfSay("You already are promoted!", cid) -- No caso de haver outra maneira de promotion (?) end npcHandler:releaseFocus(cid) elseif storage == 0 then selfSay("I am waiting for you to deliver my letter...", cid) npcHandler:releaseFocus(cid) else selfSay("Hey, you delivered my letter! Thanks, man. Here is your promotion!", cid) doPlayerSetPromotionLevel(cid, 1) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE) npcHandler:releaseFocus(cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, _onCreatureSay) npcHandler:addModule(FocusModule:new()) Bruno o seu codigo foi oque funcionou,apenas mudei uma função que é a doCreatureSetStorage(cid, 2590, 0) pela setPlayerStorageValue(cid,2590,0),agradeço sua colaboração,você me ajudou muito,assim que tiver meus pontos de reputação eu farei de ambos,obrigado! ++++++++++++EDITADO+++++++++++ Tive que reabrir porque passou 2 erros desapercebidos... O npc que recebe a letter ele esta entregando a storage mesmo se eu estiver sem a letter,apenas com a storage do npc que deu a carta,o correto seria ele falar comigo se eu estiver de posse da letter e da storage,se faltar algum não deveria ser completada a fase 1 da quest. O outro erro é o seguinte quando eu chego no npc para completa a quest da entrega da lettert ele me da a promotion do jeito que eu precisava,mas se eu iniciar a conversa com ele novamente e falar promotion ele fala (Hey, you delivered my letter! Thanks, man. Here is your promotion!) tipo ele me da a promotion novamente,toda vez que eu falar promotion para ele ele fica me dando a promotion ao invés de ele ler a parte do script (You already are promoted!) e me dizer que ja sou promovido,ele ignora minha promotion e me dá outra mesmo ja possuindo. No resto fico do jeito que eu preciso,só esses 2 bugs pra deixar 100%. Editado Fevereiro 15, 2015 10 anos por Lyon (veja o histórico de edições)
Postado Fevereiro 16, 2015 10 anos Solução Checagem da promotion no lugar errado dá nisso. NPC 1: 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 _onCreatureSay(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local storage = getCreatureStorage(cid, 2590) if msgcontains(msg, "promotion") then if getPlayerPromotionLevel(cid) == 0 then if storage == -1 then selfSay("So you need a promotion? I can give her for you, but first, give this letter to my brother, he always ask me if I am good, bad, you know...", cid) doCreatureSetStorage(cid, 2590, 0) local item = doPlayerAddItem(cid, 2597, 1) local text = "Querido, como você está? Espero que tenha tratado de sua saúde, mande-me notícias!" doSetItemText(item, text) npcHandler:releaseFocus(cid) elseif storage == 0 then selfSay("I am waiting for you to deliver my letter...", cid) npcHandler:releaseFocus(cid) else selfSay("Hey, you delivered my letter! Thanks, man. Here is your promotion!", cid) doPlayerSetPromotionLevel(cid, 1) doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE) npcHandler:releaseFocus(cid) end else selfSay("You already are promoted!", cid) end end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, _onCreatureSay) npcHandler:addModule(FocusModule:new()) NPC 2: 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 _onCreatureSay(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local status = getCreatureStorage(cid, 2590) if msgcontains(msg, "letter") then if status == -1 then selfSay("What? I think you didn't talk with my brother...", cid) elseif status == 0 then if doPlayerRemoveItem(cid, 2590) then selfSay("Hey, thanks, this is my brother's letter. Thank you very much. I am going to tell him about you.", cid) doCreatureSetStorage(cid, 2590, 1) else selfSay("You don't have my brother's letter", cid) end else selfSay("You already gave me my brother's letter", cid) end npcHandler:releaseFocus(cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, _onCreatureSay) npcHandler:addModule(FocusModule:new()) Como eu sou meio engessado, usei doCreatureSetStorage denovo, então sinta-se livre para fazer os ajustes necessários. Abraços. Editado Fevereiro 16, 2015 10 anos por Garou (veja o histórico de edições)
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.