Fiz um aqui, ta meio POG, mas funciona no TFS 0.3.5.
Só falta mudar a fala, qualquer coisa é só detalhar melhor o pedido.
Funciona assim: hi, quest, yes
Ai muda storageQuest pra 1 que indica que a quest está sendo feita.
Cada rat que mata vai acrescenta 1 no storageRats enquanto estiver fazendo a quest.
Vc pode mudar os storages, o premio, e também pode colocar a quest no quest log (só procurar um tutorial).
NPC
data\npcs\scripts\npc_da_quest.lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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:addModule(FocusModule:new())
local talkState = {}
local storageQuest = 1000000000
local storageRats = 10000000001
local premio = 1234 -- id do premio
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
if getPlayerStorageValue(cid, storageQuest) <= 0 then
selfSay('Você precisa matar 20 Rats. Aceita?', cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storageQuest) == 1 then
if getPlayerStorageValue(cid, storageRats) < 20 then
selfSay('Volte quando matar 20 Rats.', cid)
else
selfSay('Você ja matou 20 Rats. Gostaria de receber seu premio?', cid)
talkState[talkUser] = 2
end
else
selfSay('Você ja recebeu seu prêmio.', cid)
end
elseif msgcontains(msg, 'yes') then
if talkState[talkUser] == 1 then
selfSay('Depois de matar 20 Rats volte para receber seu prêmio.', cid)
doPlayerSetStorageValue(cid, storageQuest, 1)
doPlayerSetStorageValue(cid, storageRats, 0)
elseif talkState[talkUser] == 2 then
selfSay('Toma seu prêmio.', cid)
doPlayerAddItem(cid, premio)
doPlayerSetStorageValue(cid, storageQuest, 2)
end
talkState[talkUser] = 0
elseif msgcontains(msg, 'no') then
if talkState[talkUser] == 1 or talkState[talkUser] == 2 then
selfSay('Ok.', cid)
end
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
data\npcs\npc_da_quest.xml:
<?xml version="1.0"?>
<npc name="Nome do NPC" script="npc_da_quest.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|. Se tiver intesse pode realizar uma {quest}." />
</parameters>
</npc>
Rat
data\creaturescripts\scripts\rat.lua:
local storageQuest = 1000000000
local storageRats = 10000000001
function onDeath(cid, corpse, deathList)
local player = isPlayer(deathList[1]) and deathList[1] or getCreatureMaster(deathList[1])
if isPlayer(player) then
if getPlayerStorageValue(player, storageQuest) == 1 then
doPlayerSetStorageValue(player, storageRats, getPlayerStorageValue(player, storageRats)+1)
doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_BLUE, "Você matou "..getPlayerStorageValue(player, storageRats).." Rats.")
end
end
return TRUE
end
data\creaturescripts\creaturescripts.xml:
<event type="death" name="rat" event="script" value="rat.lua"/>
data\monster\rats\rat.xml:
<script>
<event name="rat"/>
</script>
~ Kydrai
Programador / Scripter