AD

[Dúvida] Arrumar Script De Quest.

Por Adolfohrq, 13 de abr. de 2012 em Scripts

script de quest
script
10
1.1k
AdolfohrqA
13 de abril de 2012 às 10:14

O Devido script ele até funciona, ele responde todas as perguntas normalmente só que ele tira o item do player só que não manda a menssagem se ele tem ou não o item! Ajudem porfavor..

 

 

 

 

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, 'orcs') then

 

selfSay('Ok, confio na lealdade deles. Você quer ver a {Luna} não é?', cid)

talkState[talkUser] = 2

 

 

elseif talkState[talkUser] == 2 then

 

if msgcontains(msg, 'luna') then

selfSay('Você só poderá encontra-la se provar a sua fidelidade com os Elfos! Você deseja {continuar}?', cid)

talkState[talkUser] = 3

end

 

 

elseif talkState[talkUser] == 3 then

 

if msgcontains(msg, 'continuar') then

selfSay('Ok, prove sua bravura matando alguns Krakens e traga-me uma {Golden Armor}.', cid)

talkState[talkUser] = 3

 

elseif(msgcontains(msg, 'golden armor') and talkState[talkUser] == 3) then

if (getPlayerStorageValue(cid,2121) > 0) then

selfSay('Parabens, voce completou a missao!', cid)

else

if(doPlayerRemoveItem(cid, 2466, 1) == TRUE) then

setPlayerStorageValue(cid,2121,1)

doPlayerAddExperience(cid,10000)

doPlayeraddItem(cid, 2470, 1)

else

selfSay('Voce precisa ter mais items.', cid)

end

end

end

end

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

VodkartV
13 de abril de 2012 às 11:09

o erro está claramente na estrutura de controle if

 

if (getPlayerStorageValue(cid,2121) > 0) then
selfSay('Parabens, voce completou a missao!', cid)
else
if(doPlayerRemoveItem(cid, 2466, 1) == TRUE) then
setPlayerStorageValue(cid,2121,1)
doPlayerAddExperience(cid,10000)
doPlayeraddItem(cid, 2470, 1)
else
selfSay('Voce precisa ter mais items.', cid)
end
end

 

if bloco then

-- código

end

--------------------------------

if bloco then

--codigo

else

--codigo

end

--------------------------------

if bloco then

--codigo

elseif bloco then

-- codigo

end

--------------------------------

 

Toda vez que abrir um "if" se deve usar o "end" para fecha-lo

 

if (getPlayerStorageValue(cid,2121) <= 0) then
if (doPlayerRemoveItem(cid, 2466, 1) == TRUE) then
setPlayerStorageValue(cid,2121,1)
doPlayerAddExperience(cid,10000)
doPlayeraddItem(cid, 2470, 1)
selfSay('Parabens, voce completou a missao!', cid)
else
selfSay('Voce precisa ter mais items.', cid)
end
else
selfSay('você já recebeu sua recompensa!', cid)
talkState[talkUser] = 0
end

Editado Abril 13 por Vodkart

AdolfohrqA
13 de abril de 2012 às 12:26

Muito obrigado Vodkart, porém pode me passar o script corretamente?? não consegui wacko.png

VodkartV
13 de abril de 2012 às 12:36
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, 'orcs') then
selfSay('Ok, confio na lealdade deles. Você quer ver a {Luna} não é?', cid)
talkState[talkUser] = 2
elseif msgcontains(msg, 'luna') and talkState[talkUser] == 2 then 
selfSay('Você só poderá encontra-la se provar a sua fidelidade com os Elfos! Você deseja {continuar}?', cid)
talkState[talkUser] = 3
elseif msgcontains(msg, 'continuar') and talkState[talkUser] == 3 then
selfSay('Ok, prove sua bravura matando alguns Krakens e traga-me uma {Golden Armor}.', cid)
talkState[talkUser] = 4
elseif(msgcontains(msg, 'golden armor') and talkState[talkUser] == 4) then
if (getPlayerStorageValue(cid,2121) <= 0) then
if (doPlayerRemoveItem(cid, 2466, 1) == TRUE) then
setPlayerStorageValue(cid,2121,1)
doPlayerAddExperience(cid,10000)
doPlayeraddItem(cid, 2470, 1)
selfSay('Parabens, voce completou a missao!', cid)
else
selfSay('Voce precisa ter mais items.', cid)
end
else
selfSay('você já recebeu sua recompensa!', cid)
talkState[talkUser] = 0
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

AdolfohrqA
13 de abril de 2012 às 12:41

Ok, muito obrigado Vod.. Porém quando o npc retira o Item ele não manda uma msg entende? só tira, queria que ele mandasse uma msg qnd ele tirasse o item, tipo Parabéns e tal, pode fazer isso pra mim??

Agradeço desde já.. Aliás deu erro no console na lib dos Npcs quando ele tira a golden armor, deve ser isso ;)

Editado Abril 13 por adolfuu

VildenV
13 de abril de 2012 às 12:49

Não ta dizendo 'Parabens, voce completou a missao! ??

 

vodkart fiho me passa seu msn verdadeiro -.-

Editado Abril 13 por Vilden

SkyDangerousS
13 de abril de 2012 às 12:56

só trocar essa linha, para a mensagem que você quer quando você dar o item e receber outro

 

 

selfSay('Parabens, voce completou a missao!', cid)

else

 

o que o vilden disse

AdolfohrqA
13 de abril de 2012 às 14:02

Ocorreu o seguinte erro quando o npc pega o Item.. Além disse ele não manda a menssagem de "Parabéns" ele só pega o item e ocorre esse erro

post-57647-0-10286600-1334336615_thumb.png

Editado Abril 13 por adolfuu

VodkartV
13 de abril de 2012 às 14:59

adolffu eu só copei o seu script, mas deveria prestar mais atenção nas funções

 

você está chamando pelo

 

doPlayeraddItem(cid, 2470, 1)

 

enquanto o correto é

 

doPlayerAddItem((cid, 2470, 1)

 

¬¬

AdolfohrqA
13 de abril de 2012 às 15:07

Ok, me desculpe, sou novato em script.. Vou aprendendo olhando os outros scripts hahahaha.. Perdão, Mas obrigado por ajudar