lukas8118 0 Postado Julho 17, 2009 Share Postado Julho 17, 2009 Olha eu tentei tentei e saiu isso dae é minha primeira script : if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then elseif getPlayerLevel >= 9 then selfSay('Você deseja comprar a magia {Light Healing} ?', cid) talkState[talkUser] = 1 else selfSay('Você não tem level suficiente.', cid) end if talkState[talkUser] == 1 then elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') then elseif pay(cid,1) then doPlayerLearnInstantSpell(cid, 'Light Healing') selfSay('Você aprendeu a magia {Light healing}.', cid) else selfSay('Você não tem dinheiro suficiente!', cid) end O executavel do ot nao da nenhum detalhe sobre o erro so fala que nao foi possivel carregar... Eu colokei talk state pq eu não tava entendendo mtu bem como posicionar os else sem os talk state , entao queria saber como posicionar eles sem o talk state. Outra duvida é como fasso para os char que criarem conta no acc manager nao virem com todas as magias ( essa duvida só to dizendo aki pra ver se alguem sabe se nao souberem eu posto la na area certa ) . vlw Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/ Compartilhar em outros sites More sharing options...
lucasjockey 1 Postado Julho 18, 2009 Share Postado Julho 18, 2009 (editado) local cost = 1000if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then if doPlayerRemoveMoney(cid, cost) == TRUE then doPlayerLearnInstantSpell(cid, 'Light Healing') selfSay('Você aprendeu a magia {Light healing}.', cid) else selfSay('Você não tem dinheiro suficiente!', cid) end end Preço da magia em vermelho. Editado Julho 18, 2009 por lucasjockey Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-764108 Compartilhar em outros sites More sharing options...
lukas8118 0 Postado Julho 18, 2009 Autor Share Postado Julho 18, 2009 Eu adiciono isso com a primeira parte ( que vai até o primeiro end ) e removo a segunda? Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-764110 Compartilhar em outros sites More sharing options...
satan666 12 Postado Julho 18, 2009 Share Postado Julho 18, 2009 pelo visto sim porque ele esta usando o talkstate entao seria a segunda parte do script. vai em spells.xml e la procura por isso: needlearn="x" se tiver 0 e porque nao necessita aprender a magia se tiver 1 precisa aprender a magia. Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-764121 Compartilhar em outros sites More sharing options...
lukas8118 0 Postado Julho 18, 2009 Autor Share Postado Julho 18, 2009 @Marcryzius Obrigado não sabia disso de learnspells xD @TOPIC O alguem pode me ajudar agora o problema é que o npc não responde quando eu falo hi >.< quando eu mechia em 8.1 ( raramente.. ) tinha la os negocios de hi mas eu olhei scripts de varios npc do ot 8.40 aki e nenhum eu encherguei algo com hi nem nada parecido vo manda a script do npc : 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 if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then elseif getPlayerLevel >= 9 then selfSay('Você deseja comprar a magia {Light Healing} ?', cid) talkState[talkUser] = 1 else selfSay('Você não tem level suficiente.', cid) end end local cost = 1000 if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then if doPlayerRemoveMoney(cid, cost) == TRUE then doPlayerLearnInstantSpell(cid, 'Light Healing') selfSay('Você aprendeu a magia {Light healing}.', cid) else selfSay('Você não tem dinheiro suficiente!', cid) end end Alias, muito obrigado lucasjockey! Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-764133 Compartilhar em outros sites More sharing options...
satan666 12 Postado Julho 18, 2009 Share Postado Julho 18, 2009 uma pequena correçao no script. 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 if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then if getPlayerLevel >= 9 then selfSay('Você deseja comprar a magia {Light Healing} ?', cid) talkState[talkUser] = 1 else selfSay('Você não tem level suficiente.', cid) end end local cost = 1000 if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then if doPlayerRemoveMoney(cid, cost) == TRUE then doPlayerLearnInstantSpell(cid, 'Light Healing') selfSay('Você aprendeu a magia {Light healing}.', cid) else selfSay('Você não tem dinheiro suficiente!', cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) e verifique se o xml do npc tem esse parametro. <parameters><parameter key="message_greet" value="Hello, |PLAYERNAME| bla bla bla" /> <parameter key="message_walkaway" value="ate mais." /> </parameters> Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-764152 Compartilhar em outros sites More sharing options...
lukas8118 0 Postado Julho 18, 2009 Autor Share Postado Julho 18, 2009 (editado) Então cara agora o npc até fala hi mas depois não fala nada! Ta ai a SS : Script : 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 if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then if getPlayerLevel >= 9 then selfSay('Você deseja comprar a magia {Light Healing} ?', cid) talkState[talkUser] = 1 else selfSay('Você não tem level suficiente.', cid) end end local cost = 1000 if talkState[talkUser] == 1 and (msgcontains(msg, 'yes') or msgcontains(msg, 'sim')) then if doPlayerRemoveMoney(cid, cost) == TRUE then doPlayerLearnInstantSpell(cid, 'Light Healing') selfSay('Você aprendeu a magia {Light healing}.', cid) else selfSay('Você não tem dinheiro suficiente!', cid) end end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) XML do NPC pra qualquer coisa : <?xml version="1.0" encoding="UTF-8"?><npc name="Eremo" script="data/npc/scripts/pow.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="142" head="79" body="118" legs="115" feet="114" corpse="2212" /> <parameters><parameter key="message_greet" value="Ola |PLAYERNAME|, eu vendo magias!"/> <parameter key="message_walkaway" value="Adeus |PLAYERNAME|." /> </parameters> </npc> Ah , e muito obrigado tambem pela ajuda que estão dando! @@EDIT Então só to com mais uma duvida é em questão de posicionamento dos else vo posta uma script em portugues ( só um exemplo sem os comandos certos .. ) só pra vc me dizer se to fazendo certo : Se mensagem conter light healing façaSe lvl do player >= 9 Faça Senão fale Você não tem level suficiente end fale Você deseja comprar light healing? Se mensagem conter sim faça Senao fale 'eu não entendi por favor começe tudo denovo!' end fale É 200 gps deseja mesmo comprar? Se mensagem conter sim faça Senao fale 'Desculpe eu não entendi comece tudo denovo!' end Checar dinheiro do player >= 200 faça Senao fale ' você nao tem dinheiro suficiente por favor consiga mais!' end Remova 200 gps do player Adiciona a magia light healing ao player fale 'Você comprou a magia Light Healing' end end Editado Julho 18, 2009 por lucaslokin Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-764245 Compartilhar em outros sites More sharing options...
joaohd 200 Postado Julho 23, 2009 Share Postado Julho 23, 2009 esse servidor é o styller yurots?? Tenta esse aki ó : 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 if msgcontains(msg, 'Light Healing') or msgcontains(msg, 'light healing') then if getPlayerLevel >= 9 then selfSay('Você deseja comprar a magia {Light Healing} ?', cid) talk_state = 1 else selfSay('Você não tem level suficiente.', cid) talk_state = 0 end local cost = 1000 elseif msgcontains(msg, 'yes') or msgcontains(msg, 'sim') and talk_state == 1 then if doPlayerRemoveMoney(cid, cost) then doPlayerLearnInstantSpell(cid, 'Light Healing') selfSay('Você aprendeu a magia {Light healing}.', cid) else selfSay('Você não tem dinheiro suficiente!', cid) talk_state = 0 end elseif msgcontains(msg, 'no') then selfSay('Ok than.', cid) talk_state = 0 end -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself. return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) esse eu acho que funciona. eu acho que o erro todo tava na linha "if doPlayerRemoveMoney(cid,cost) == true then se n me engano n precisava dakele == true porque o if ja faz a condição só ocorrer se for verdadeira. flws Link para o comentário https://xtibia.com/forum/topic/116532-erro-numa-script-de-npc/#findComment-766778 Compartilhar em outros sites More sharing options...
Posts Recomendados