Olá (: , estou aqui de novo com um npc bom para servidores RPG'
~~> Como funciona? <~~
Você fala com o npc, o npc sumona um monstro e após matar este monstro,
ele te dá uma reconpensa.
~~> Como Instalar? <~~
-> Vá em data/creaturescripts/creaturescripts.xml e add essa tag:
<event type="death" name="NPC" event="script" value="npcquest.lua"/>
->Agora vá em creaturescripts/scripts e crie um novo arquivo com o nome npcquest.lua e bote isto dentro:
function onDeath(cid, corpse, killer) local monstName = "Monk" -- nome do monstro local Storage = 9755 -- nao mude if isMonster(cid) then if string.lower(getCreatureName(cid)) == string.lower(monstName) then setPlayerStorageValue(killer[1], Storage, 1) doCreatureSay(killer[1],'Você completo sua tarefa.',TALKTYPE_ORANGE_1) end end return TRUE end
->Agora você vai no xml do monstro que você escolheu e lá no final do script antes do </monster>, você add:
<script> <event name="NPC"/> </script>
->Agora em data/npc, crie um novo arquivo com o nome Jhow.xml e bote isto dentro:
<?xml version="1.0" encoding="UTF-8"?> <npc name="Jhow" script="data/npc/scripts/jhow.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="138" head="96" body="95" legs="0" feet="95" addons="0"/> <parameters> <parameter key="message_greet" value="Ola |PLAYERNAME|, voce quer testar suas habilidades?" /> <parameter key="module_keywords" value="1" /> </parameters> </npc>
->Agora vá em npc/script e crie um novo arquivo com o nome de jhow.lua e bote isto dentro:
local nomeMonst = "Monk" -- Nome do mosntro que ele vai sumonar local itemid = 2150 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 getPlayerStorageValue(cid, 9755) == -1 then if(msgcontains(msg, 'yes')) then selfSay('Mate este monstro para completar sua tarefa.', cid) doCreateMonster(nomeMonst,getThingPos(cid)) talkState[talkUser] = 1 end return true end if getPlayerStorageValue(cid, 9755) == 1 then selfSay('Você matou o monstro e ganhou um item.', cid) doPlayerAddItem(cid, itemid,1) setPlayerStorageValue(cid, 9755,2) talkState[talkUser] = 0 return true end if getPlayerStorageValue(cid, 9755) == 2 then selfSay('Você já fez esta tarefa.', cid) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
->Agora volte lá em creaturescripts/scripts/ e procure por login.lua e antes do ultimo return true add isto:
registerCreatureEvent(cid, "NPC")
Pronto amigo! NPC instalado :},
COMENTEM Por favor