Ir para conteúdo
  • Cadastre-se

Posts Recomendados

NPC Mission

Servidor testado: TFS

Autor: kawon

Primeiro crie um arquivo npc_mission.xml dentro da pasta data/npc/.

E coloque isso:

<npc name="Npc Mission" script="data/npc/scripts/mission.lua" walkinterval="1" floorchange="0" access="5" level="1" maglevel="1">

<health now="100" max="100"/>

<look type="132" head="57" body="59" legs="40" feet="76" addons="3"/>

<parameters>

<parameter key="message_greet" value="Hello |PLAYERNAME|. You can started 'quest'?" />

</parameters>

</npc>  
Em seguida crie um arquivo mission.lua na pasta /data/npc/scripts/ E adicione isso:
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, 'quest')) then

selfSay('Ok, you can started "first mission"?', cid)

end

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

if(msgcontains(msg, 'first mission')) then

selfSay('Please bring me 10 "meat"', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'meat') and talkState[talkUser] == 1) then

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

selfSay('You finished this mission.', cid)

else

if(doPlayerRemoveItem(cid, 2666, 10) == TRUE) then

setPlayerStorageValue(cid,100,1)

doPlayerAddExperience(cid,1000)

selfSay('Thank you! You can started "second mission".. (you received 1000 points of experience)', cid)

else

selfSay('You must have more items', cid)

end

end

return true

end

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

if(msgcontains(msg, 'second mission')) then

selfSay('Please bring me 10 "ham"', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'ham') and talkState[talkUser] == 1) then

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

selfSay('You finished this mission.', cid)

else

if(doPlayerRemoveItem(cid, 2671, 10) == TRUE) then

setPlayerStorageValue(cid,101,1)

doPlayerAddExperience(cid,1000)

selfSay('Thank you! You can started "third mission".. (you received 1000 points of experience)', cid)

else

selfSay('You must have more items', cid)

end

end

return true

end

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

if(msgcontains(msg, 'third mission')) then

selfSay('Please bring me 20 "ham"', cid)

talkState[talkUser] = 1

elseif(msgcontains(msg, 'ham') and talkState[talkUser] == 1) then

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

selfSay('You finished this mission.', cid)

else

if(doPlayerRemoveItem(cid, 2671, 20) == TRUE) then

setPlayerStorageValue(cid,102,1)

doPlayerAddExperience(cid,1000)

selfSay('Thank you! You finished all missions. (you received 1000 points of experience)', cid)

else

selfSay('You must have more items', cid)

end

end

return true

end



end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())  

Transcrições:

PLAYER: hi

NPC: Hello |PLAYERNAME|. You can started 'quest'?

PLAYER: quest

NPC: Ok, you can started "first mission"?

PLAYER: first mission

NPC: Please bring me 10 "meat"

PLAYER: meat

When player finish this mission

NPC: You finished this mission.

When player do first once

NPC: Thank you! You can started "second mission".. (you received 1000 points of experience)

When player don't have 10 meat

NPC: You must have more items

Contato;

6yonKDJ.png god.marinii

TaxNfhb.png

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo