Postado Novembro 8, 2012 12 anos 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; god.marinii [email protected]
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.