Blz eu fiz no msm estilo ele vai no npc o npc da missao para ele e depois que o player acabar ele volta ao npc e o npc da uma nova missao e assim por diante quantos vc quiser.
Creaturescripts.xml
Lembra que vc botou o kill_task.lua agora toda vez que vc quiser uma nova task vc coloca as tag assim como eu botei abaixo e vc configura separadamente cada uma da maneira que vc quiser
<event type="kill" name="kill_task" event="script" value="kill_task3.lua"/>
<event type="kill" name="kill_task" event="script" value="kill_task2.lua"/>
creaturescripts/scripts
Ae vc precisa criar o arquivo .lua com os nomes novos "kill_task2.lua" e "kill_task3.lua" eu vou te mandar os 2 logo para vc nao ficar com duvida de como ta a configuração.
Lembrando que eu mudei umas coisinhas só para ficar mais facil na hr de configurar e n precisar mudar o nome do bicho na msg só na config.
kill_task2.lua
storage = 2501, Tem que ta igual a storage da missao 2 do npc pq a 1 foi a que eu te mandei antes e a 3 é a task_kill3
monster = 'Troll', Nome do monstro
premio = 2160, Id do premio
qtd = 1, Quantidade de itens do premio
exp = 100, Exp que ganha mas vc pode botar 0 caso n queira nenhuma
local Configs = {
storage = 2501,
monster = 'Troll',
premio = 2160,
qtd = 1,
exp = 100,
}
function onKill(cid, target, lastHit)
if isMonster(target) and getCreatureName(target) == Configs.monster then
local get = getPlayerStorageValue(cid, Configs.storage)
if get >=0 and get <=5 then
setPlayerStorageValue(cid, Configs.storage, (get+1))
local gett = getPlayerStorageValue(cid, Configs.storage)
doCreatureSay(cid, 'Voce matou '..gett..' '..Configs.monster..' ate agora.', TALKTYPE_ORANGE_1)
if gett == 5 then
doPlayerAddItem(cid, Configs.premio, Configs.qtd)
doPlayerAddExp(cid,Configs.exp)
doCreatureSay(cid, 'Voce acabou a missao!.', TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, Configs.storage, (gett+1))
end
end
end
return true
end
kill_task3.lua
local Configs = {
storage = 2502,
monster = 'Sheep',
premio = 2160,
qtd = 1,
exp = 100,
}
function onKill(cid, target, lastHit)
if isMonster(target) and getCreatureName(target) == Configs.monster then
local get = getPlayerStorageValue(cid, Configs.storage)
if get >=0 and get <=5 then
setPlayerStorageValue(cid, Configs.storage, (get+1))
local gett = getPlayerStorageValue(cid, Configs.storage)
doCreatureSay(cid, 'Voce matou '..gett..' '..Configs.monster..' ate agora.', TALKTYPE_ORANGE_1)
if gett == 5 then
doPlayerAddItem(cid, Configs.premio, Configs.qtd)
doPlayerAddExp(cid,Configs.exp)
doCreatureSay(cid, 'Voce acabou a missao!.', TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, Configs.storage, (gett+1))
end
end
end
return true
end
Npc/scripts
o Npc "task.lua" ficou assim:
storage_1 = 2500, É a storage da primeira task(missao)
storage_2 = 2501, msm coisa só que da 2
storage_3 = 2502, e da 3
qtd_kill1 = 5, Aqui é a quantidade de bichos que o player precisa matar da 1 missao
qtd_kill2 = 5, msm coisa só que da 2
qtd_kill3 = 5, da 3
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
local Configs = {
storage_1 = 2500,
storage_2 = 2501,
storage_3 = 2502,
qtd_kill1 = 5,
qtd_kill2 = 5,
qtd_kill3 = 5,
}
local get1 = getPlayerStorageValue(cid, Configs.storage_1)
local get2 = getPlayerStorageValue(cid, Configs.storage_2)
local get3 = getPlayerStorageValue(cid, Configs.storage_3)
if(msgcontains(msg, 'missao') and (get1 == -1)) then
selfSay('Para ganhar o premio mate '..Configs.qtd_kill1..' Rabbit! Voce ira receber automaticamente.', cid)
setPlayerStorageValue(cid, Configs.storage_1, 0)
return true
elseif get1 >=0 and get1 <=Configs.qtd_kill1 then
selfSay('Voce precisa matar '..(Configs.qtd_kill1-get1)..' Rabbits!', cid)
return true
end
if(msgcontains(msg, 'missao') and (get2 == -1)) then
selfSay('Para ganhar o premio mate '..Configs.qtd_kill2..' Troll! Voce ira receber automaticamente.', cid)
setPlayerStorageValue(cid, Configs.storage_2, 0)
return true
elseif get2 >=0 and get2 <=Configs.qtd_kill2 then
selfSay('Voce precisa matar '..(Configs.qtd_kill2-get2)..' Troll!', cid)
return true
end
if(msgcontains(msg, 'missao') and (get3 == -1)) then
selfSay('Para ganhar o premio mate '..Configs.qtd_kill3..' Sheep! Voce ira receber automaticamente.', cid)
setPlayerStorageValue(cid, Configs.storage_3, 0)
return true
elseif get3 >=0 and get3 <=Configs.qtd_kill3 then
selfSay('Voce precisa matar '..(Configs.qtd_kill3-get3)..' Sheep!', cid)
end
if get1>Configs.qtd_kill1 and get2>Configs.qtd_kill2 and get3>Configs.qtd_kill3 then
selfSay('Voce ja fez todas as missoes!', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Qualquer coisa só falar, e eu sei que outras pessoas vão dizer que o código não esta perfeito e que da para fazer de alguma outra maneira mas eu fui fazendo para treinar msm faz muito tempo que não programo para otserv e estou voltando agora e lembrando aos poucos.
@igorcano1 Para vc botar mais recompensas vc pode ir fazendo assim:
local Configs = {
storage = 2502,
monster = 'Sheep',
premio = 2160,
premio2= 2152,
qtd = 1,
qtd_2 = 1,
exp = 100,
}
function onKill(cid, target, lastHit)
if isMonster(target) and getCreatureName(target) == Configs.monster then
local get = getPlayerStorageValue(cid, Configs.storage)
if get >=0 and get <=5 then
setPlayerStorageValue(cid, Configs.storage, (get+1))
local gett = getPlayerStorageValue(cid, Configs.storage)
doCreatureSay(cid, 'Voce matou '..gett..' '..Configs.monster..' ate agora.', TALKTYPE_ORANGE_1)
if gett == 5 then
doPlayerAddItem(cid, Configs.premio, Configs.qtd)
doPlayerAddItem(cid, Configs.premio2, Configs.qtd_2)
doPlayerAddExp(cid,Configs.exp)
doCreatureSay(cid, 'Voce acabou a missao!.', TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, Configs.storage, (gett+1))
end
end
end
return true
end