alguem com um tempinho livre me diz como fazer um NPC DE QUEST
EXEMPLO:
Eu começo uma conversa com o NPC e falo QUEST ai ele me pede para eu pega uma KATANA e da pra ele. Depois disso feito ele me dava uma SPEAR
por favor!! preciso muito
alguem com um tempinho livre me diz como fazer um NPC DE QUEST
EXEMPLO:
Eu começo uma conversa com o NPC e falo QUEST ai ele me pede para eu pega uma KATANA e da pra ele. Depois disso feito ele me dava uma SPEAR
por favor!! preciso muito
PixelArt é um Estouro!
Acesse minha Galeria
não sei se esta correto.
nao testei ainda =X
--------------------------------------------------------------------------------------------
------------------------------------ Script 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
npcHandler:setMessage(MESSAGE_GREET, "olá |PLAYERNAME|. Voce pode me trazer uma katana? {Quest} .")
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, 'quest') or msgcontains(msg, 'yes') then
selfSay("eu tenho uma spear para trocar,trouxe a katana? {want}?",cid)
talkState[talkUser] = 1
elseif (msgcontains(msg, 'yes') or msgcontains(msg, 'want') or msgcontains(msg, 'trade')) and talkState[talkUser] == 1 then
if retirar(cid) then
doPlayerAddItem(cid,2389,1)
selfSay("Thank you so much!",cid)
else
selfSay("Desculpe mais voce nao tem o item que foi solicitado.",cid)
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
selfSay("Okay man.",cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
function retirar(cid)
if doPlayerRemoveItem(cid,2412,1) then
return TRUE
else
doPlayerAddItem(cid,2412,1)
end
end
return FALSE
end
O critico~
Te Ajudei? Então Por Favor Agradeça!
Caso esse ai não funcionar use esse:
-- NPC de troca -local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
local addon_state = 0
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Olá ' .. getCreatureName(cid) .. '...Hiho! eu preciso de ->queijos<- vc viu algum por ai?')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'trade') or msgcontains(msg, 'queijo') then
if doPlayerRemoveItem(cid,XXXX,5) == 0 then
selfSay('achou alguma queijo?!')
addon_state = 0
else
selfSay('Vc achou! pegue seu presente!!')
doPlayerAddItem(cid, XXXX, 1)
talk_start = 0
end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '! Obrigado!..')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Se achar mais queijos me avise...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
Basta mudar os XXXX em vermelho para o id dos itens e mudar as msgs, eu uso ele no meu server e roda perfeitamente...
Creditos: Conde Sapo 98% {quem criou eu acho}
GodBz (eu) 2% {arrumei uns bugs)
Vulcania Alternative Server Game! - 24 Horas Online!
________________________________________________________________________________
Procurando um servidor novo? está cansado de ver sempre a mesma coisa?
Então entre em nosso mundo!
________________________________________________________________________________
Crie sua conta no site!
lol achei um bug, é so ficar escrevendo trade toda hora, o npc nao para de entrega os itens..
usa esse
-- NPC de troca - local focus = 0 local talk_start = 0 local target = 0 local following = false local attacking = false local addon_state = 0 function onThingMove(creature, thing, oldpos, oldstackpos) end function onCreatureAppear(creature) end function onCreatureDisappear(cid, pos) if focus == cid then selfSay('Good bye then.') focus = 0 talk_start = 0 end end function onCreatureTurn(creature) end function msgcontains(txt, str) return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) end function onCreatureSay(cid, type, msg) msg = string.lower(msg) if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then selfSay('Olá ' .. getCreatureName(cid) .. '...Hiho! eu preciso de ->queijos<- vc viu algum por ai?') focus = cid talk_start = os.clock() elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.') elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'trade') or msgcontains(msg, 'queijo') then if doPlayerRemoveItem(cid,XXXX,5) == 0 then selfSay('achou alguma queijo?!') addon_state = 0 else if getPlayerStorageValue(cid,554411) == 1 them selfSay('Você ja pegou seu presente') else selfSay('Vc achou! pegue seu presente!!') doPlayerAddItem(cid, XXXX, 1) getPlayerStorageValue(cid,554411,1) talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. getCreatureName(cid) .. '! Obrigado!..') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() doNpcSetCreatureFocus(focus) if (os.clock() - talk_start) > 30 then if focus > 0 then selfSay('Se achar mais queijos me avise...') end focus = 0 end if focus ~= 0 then if getDistanceToCreature(focus) > 5 then selfSay('Good bye then.') focus = 0 end end end