Postado Novembro 15, 2017 7 anos quero um script de missão simples... o player mata 2 monstros e recebe a recompensa na bp sem precisar falar com o npc para pegar a recompensa por exemplo: mate um rabbit e ganhe 100 xp + 50 gp mate 2 troll e receba 1 scale armor
Postado Novembro 16, 2017 7 anos Fiz um bem simples ve se resolve seu problema. O jogador precisa ir até o npc falar "missao" e ae depois é só ele ir caçar e matar a quantidade certa de bichos para ganhar item/exp automaticamente. E se ele for no npc o npc indica para ele que não pode mais fazer aquela "missao" novamente. creaturescripts.xml <event type="kill" name="kill_task" event="script" value="kill_task.lua"/> creaturescripts/login.lua Antes do return true la do final bota isso. registerCreatureEvent(cid, "kill_task") creaturescripts/scripts Cria um arquivo .lua com o nome "kill_task" e cola isso dentro. local Configs = { storage = 2427, monster = 'Rabbit', 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..' Rabbits 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 Na pasta npc crie um arquivo .xml com o nome "Task" e cole isso <?xml version="1.0" encoding="UTF-8"?> <npc name="Task" script="task.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|, eu tenho uma missao para voce!"/> </parameters> </npc> Npc/scripts Crie um arquivo .lua com o nome "task" e cole 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 local storage = 2427 local get = getPlayerStorageValue(cid, storage) if(msgcontains(msg, 'missao') and (get == -1)) then selfSay('Para ganhar o premio mate 5 Rabbits! Voce ira receber automaticamente.', cid) setPlayerStorageValue(cid, storage, 0) elseif get >=5 then selfSay('Voce acabou a missao de matar Rabbits!', cid) else selfSay('Voce precisa matar '..(5-get)..' Rabbits!', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Editado Novembro 16, 2017 7 anos por Vabrindox (veja o histórico de edições)
Postado Novembro 16, 2017 7 anos Autor 5 horas atrás, Vabrindox disse: Fiz um bem simples ve se resolve seu problema. O jogador precisa ir até o npc falar "missao" e ae depois é só ele ir caçar e matar a quantidade certa de bichos para ganhar item/exp automaticamente. E se ele for no npc o npc indica para ele que não pode mais fazer aquela "missao" novamente. creaturescripts.xml <event type="kill" name="kill_task" event="script" value="kill_task.lua"/> creaturescripts/login.lua Antes do return true la do final bota isso. registerCreatureEvent(cid, "kill_task") creaturescripts/scripts Cria um arquivo .lua com o nome "kill_task" e cola isso dentro. local Configs = { storage = 2427, monster = 'Rabbit', 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..' Rabbits 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 Na pasta npc crie um arquivo .xml com o nome "Task" e cole isso <?xml version="1.0" encoding="UTF-8"?> <npc name="Task" script="task.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|, eu tenho uma missao para voce!"/> </parameters> </npc> Npc/scripts Crie um arquivo .lua com o nome "task" e cole 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 local storage = 2427 local get = getPlayerStorageValue(cid, storage) if(msgcontains(msg, 'missao') and (get == -1)) then selfSay('Para ganhar o premio mate 5 Rabbits! Voce ira receber automaticamente.', cid) setPlayerStorageValue(cid, storage, 0) elseif get >=5 then selfSay('Voce acabou a missao de matar Rabbits!', cid) else selfSay('Voce precisa matar '..(5-get)..' Rabbits!', cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Se eu quero q quando essa primeira missão acabe... tipo assim... mate um demon... o kara vai la mata o demon... na hora q ele mata, ele ganha a recompensa da quest e dá quest update dizendo agora mate um orshabaal... tem a possibilidade?
Postado Novembro 16, 2017 7 anos 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 Editado Novembro 16, 2017 7 anos por Vabrindox (veja o histórico de edições)
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.