Postado Maio 21, 2018 7 anos E ae galera blz? Gostaria de saber se é possível criar um npc que dê uma Queste depois que completar ela, ganhar exp e um outfitte.Explicando: Você fala com o NPC e ele pede para você matar X quantia de monstros e quando você matar ele te dê como recompensa um outfitte (Configurável) e uma quantia em EXP.Segue um como Modelo que tenho aqui: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local quest = 76669 local reward = 70000 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) local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(not npcHandler:isFocused(cid)) then return false elseif msgcontains(msg, "") and talkState[talkUser] == 1 then npcHandler:say("", cid) talkState[talkUser] = 2 elseif msgcontains(msg, "") and talkState[talkUser] == 2 then npcHandler:say("!", cid) setPlayerStorageValue(cid, quest, 2) talkState[talkUser] = 0 elseif msgcontains(msg, ".") then local str = getPlayerStorageValue(cid, quest) if(str < 2) then npcHandler:say(".", cid) talkState[talkUser] = 1 return true elseif(str == 2) then npcHandler:say("!", cid) elseif(str == 3) then npcHandler:say(".", cid) doPlayerAddItem(cid, x, x) doPlayerAddExp(cid, x) doPlayerSendTextMessage(cid, 22, '.') setPlayerStorageValue(cid, quest, 4) elseif(str == 4) then npcHandler:say(".", cid) end talkState[talkUser] = 0 end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Desde já grato
Postado Maio 22, 2018 7 anos Bom , vou compartilhar com você uma gambiarra que fiz aqui a um tempo atras , você vai perceber que é velho pelas gambiarras e identação do código , aqui vamos nós :NPCS XML <?xml version="1.0" encoding="UTF-8"?> <npc name="Tasker" script="data/npc/scripts/task/task.lua" walkinterval="2000" speed="0" floorchange="0"> <health now="100" max="100"/> <look type="167" head="38" body="79" legs="107" feet="114"/> <parameters> <parameter key="message_greet" value="I' have a task for you. [{accept}] or [{premio}] "/> </parameters></npc> SCRIPT 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 = 35678 -- monster kill | local sto = 24529 -- don't pick premio | -- | Não mecha nessa gambiarra aqui , só certifique que nenhuma dessas storages sejam usadas em outros sistemas local rage = 24525 -- inicializate contage | local ok = 45651 -- don't inicializate | local exp = 100 -- Quantidade de XP local monster = 100 -- Quantos monstros terá que matar local outfit = { male = 10, -- ID da outfit male female = 11 -- ID da outfit female } if(msgcontains(msg, 'premio')) then if getPlayerStorageValue(cid, sto) == -1 then if getPlayerStorageValue(cid, storage) >= 100 then selfSay("You have finished the task", cid) doPlayerAddExp(cid, exp) doSendMagicEffect(getCreaturePosition(cid), 5) setPlayerStorageValue(cid, rage, -1) setPlayerStorageValue(cid, sto, 1) setPlayerStorageValue(cid, fuck, 1) if getPlayerSex(cid) == 1 then doPlayerAddOutfit(cid, outfit.male, 0) else doPlayerAddOutfit(cid, outfit.female, 0) end else selfSay("You need kill 100 monsters do finish the task", cid) end else selfSay("back from here nigga", cid) end end if(msgcontains(msg, 'accept')) then if getPlayerStorageValue(cid, ok) == -1 then selfSay("You have intialized the task", cid) setPlayerStorageValue(cid, ok, 1) setPlayerStorageValue(cid, rage, 1) else selfSay("You started the task", cid) end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) CREATURESCRIPTS XML <event type="death" name="task" event="script" value="task.lua"/> Na XML do monstro <script> <event name="task"/> </script> Script local key = 35678 local rage = 24525 -- inicializate contage local monster = 100 -- Quantos monstros terá que matar function onDeath(cid, corpse, deathList) local killer = deathList[1] if not isPlayer(killer) then return true end if getPlayerStorageValue(killer, rage) == -1 then return true end setPlayerStorageValue(killer, key, getPlayerStorageValue(killer, key) + 1) doPlayerSendTextMessage(killer, 27, "Monster:: [".. getPlayerStorageValue(killer, key) .."//".. monster .."]") return true end
Postado Maio 22, 2018 7 anos @Sttorm Tem como colocar pra que quando o player tentar falar de novo, o npc mandar uma frase? Porque tipo, toda vez que o player fala yes, o npc sempre manda a frase "You started the task" E colocar tamebm que ele ganhe itens, como gold e potion
Postado Maio 22, 2018 7 anos Solução 3 minutos atrás, Zazeros disse: @Sttorm Tem como colocar pra que quando o player tentar falar de novo, o npc mandar uma frase? Porque tipo, toda vez que o player fala yes, o npc sempre manda a frase "You started the task" E colocar tamebm que ele ganhe itens, como gold e potion "You started the task" = Você já iniciou a missão , ou seja, está correto. 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 = 35678 -- monster kill | local sto = 24529 -- don't pick premio | -- | Não mecha nessa gambiarra aqui , só certifique que nenhuma dessas storages sejam usadas em outros sistemas local rage = 24525 -- inicializate contage | local ok = 45651 -- don't inicializate | local exp = 100 -- Quantidade de XP local monster = 100 -- Quantos monstros terá que matar local outfit = { male = 10, -- ID da outfit male female = 11 -- ID da outfit female } local potion, count = 2139, 10 -- ID da potion , Count. local gold = 1000 -- quanto de money irá ganhar if(msgcontains(msg, 'premio')) then if getPlayerStorageValue(cid, sto) == -1 then if getPlayerStorageValue(cid, storage) >= 100 then selfSay("You have finished the task", cid) doPlayerAddItem(cid, potion, count) doPlayerAddMoney(cid, gold) doPlayerAddExp(cid, exp) doSendMagicEffect(getCreaturePosition(cid), 5) setPlayerStorageValue(cid, rage, -1) setPlayerStorageValue(cid, sto, 1) setPlayerStorageValue(cid, fuck, 1) if getPlayerSex(cid) == 1 then doPlayerAddOutfit(cid, outfit.male, 0) else doPlayerAddOutfit(cid, outfit.female, 0) end else selfSay("You need kill 100 monsters do finish the task", cid) end else selfSay("back from here nigga", cid) end end if(msgcontains(msg, 'accept')) then if getPlayerStorageValue(cid, ok) == -1 then selfSay("voce iniciou a missao", cid) setPlayerStorageValue(cid, ok, 1) setPlayerStorageValue(cid, rage, 1) else selfSay("Voce ja iniciou a missao", cid) end end end
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.