Postado Maio 22, 2014 11 anos Autor Data/Lib: taskstg = { kills = 3451, permission = 3452, killstotal = 3453, monster = 3454, stage = 3455, points = 3456, } timeBetweenTasks = 24 * 60 * 60 -- tempo até poder fazer outra task (24 * 60 * 60 = 24hs) taskLevel = false -- true se quiser que as tasks sejam feitas por level / false se quiser que elas sejam feitas na ordem taskMsg = {bool = true, msg = 'Voce acaba de matar monstros suficientes para completar sua task!'} -- bool = false > sem mensagens; bool = true > aviso quando terminar a task taskEnd = false -- [não tem função no modo Level] se estiver como true, quando o jogador terminar a última task disponível, ele não poderá repeti-la. Se estiver false, ele poderá repetir a última task infinitamente. taskmonsters = { [1] = {'rotworm', killstotal = 250}, -- aqui você deve mudar [2] = {'cyclop','cyclops','cyclops smith','cyclops drone', killstotal = 500} } taskreward = -- em gps { [1] = {money = 10000,xp = 20000, points = 3}, [2] = {money = 15000,xp = 50000, item = 2160}, [3] = {money = 40000,xp = 75000,item = 2160,amount = 2, points = 1} } function canDoTask(cid) local stage = getPlayerStorageValue(cid, taskstg.stage) if stage + 1 > #taskmonsters then return false elseif getPlayerStorageValue(cid,taskstg.permission) <= 0 then return true elseif getPlayerStorageValue(cid,taskstg.permission) == 1 then return false elseif getPlayerStorageValue(cid,taskstg.permission) >= os.time(t) then return false end return true end function doResetTask(cid) setPlayerStorageValue(cid,taskstg.kills,-1) setPlayerStorageValue(cid,taskstg.permission,os.time(t) + timeBetweenTasks) setPlayerStorageValue(cid,taskstg.killstotal,-1) setPlayerStorageValue(cid,taskstg.monster,-1) return true end function doRewardTask(cid) local monster = getPlayerStorageValue(cid,taskstg.monster) local reward = taskreward[monster] if reward.item then doPlayerAddItem(cid,reward.item,(reward.amount and reward.amount or 1)) end if reward.points then local points = getPlayerStorageValue(cid, taskstg.points) if points == -1 then setPlayerStorageValue(cid, taskstg.points, 0) end setPlayerStorageValue(cid, taskstg.points, reward.points + points) end if monster and reward then doPlayerAddMoney(cid,reward.money) doPlayerAddExperience(cid, reward.xp) end return true end function isSummon(cid) -- baseada na função do Vodkart if getCreatureMaster(cid) ~= nil or getCreatureMaster(cid) == true then return true end return false end function doCompleteTask(cid) doRewardTask(cid) doResetTask(cid) return true end function doStartTask(cid) if not taskLevel then local stage = getPlayerStorageValue(cid, taskstg.stage) if stage <= 0 then setPlayerStorageValue(cid, taskstg.monster, 1) setPlayerStorageValue(cid, taskstg.killstotal, taskmonsters[1].killstotal) setPlayerStorageValue(cid, taskstg.stage, 1) else setPlayerStorageValue(cid, taskstg.monster, stage+1) setPlayerStorageValue(cid, taskstg.killstotal, taskmonsters[stage+1].killstotal) if taskEnd or stage < #taskmonsters then setPlayerStorageValue(cid, taskstg.stage, stage+1) end end setPlayerStorageValue(cid, taskstg.permission, 1) setPlayerStorageValue(cid, taskstg.kills, 0) return true end local lvl = getPlayerLevel(cid) if lvl < 20 then local killstotal = taskmonsters[1].killstotal setPlayerStorageValue(cid,taskstg.monster,1) setPlayerStorageValue(cid,taskstg.killstotal,killstotal) setPlayerStorageValue(cid,taskstg.permission,1) elseif lvl < 50 then local killstotal = taskmonsters[2].killstotal setPlayerStorageValue(cid,taskstg.monster,2) setPlayerStorageValue(cid,taskstg.killstotal,killstotal) setPlayerStorageValue(cid,taskstg.permission,1) else local killstotal = taskmonsters[3].killstotal setPlayerStorageValue(cid,taskstg.monster,3) setPlayerStorageValue(cid,taskstg.killstotal,killstotal) setPlayerStorageValue(cid,taskstg.permission,1) end setPlayerStorageValue(cid,taskstg.kills,0) return true end Data/Npc - Annd.xml <?xml version="1.0" encoding="UTF-8"?> <npc name="Annd" script="data/npc/scripts/taskss.lua" walkinterval="3000" floorchange="0"> <health now="100" max="100"/> <look type="153" head="115" body="95" legs="113" feet="0" addons="3"/> <parameters> <parameter key="message_greet" value="Ei, |PLAYERNAME|, quer uma {nova task}, {informacoes} ou {cancelar} uma task? Ou sera que quer {completar} sua task? Huum... talvez ver quantos {pontos} voce tem?"/> <parameter key="message_farewell" value="Boa sorte em suas aventuras, |PLAYERNAME|."/> <parameter key="message_walkaway" value="Tchau..."/> </parameters> </npc> Data/Npc/Scripts/ - taskss.lua 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 monster, permission = getPlayerStorageValue(cid,taskstg.monster), getPlayerStorageValue(cid,taskstg.permission) local kills, killstotal = getPlayerStorageValue(cid,taskstg.kills), getPlayerStorageValue(cid,taskstg.killstotal) if msgcontains(msg,'nova task') then if monster ~= -1 then selfSay('Você já tem uma task em andamento. Termine-a antes de começar outra.',cid) elseif getPlayerStorageValue(cid, taskstg.stage) + 1 > #taskmonsters then selfSay('Eu não tenho mais tasks para você.',cid) elseif not canDoTask(cid) then selfSay('Você deve esperar '..math.ceil((permission - os.time(t))/60)..' minutos até poder começar outra task.',cid) else doStartTask(cid) selfSay('Muito bem, utilize {!countkills} para acompanhar o andamento de sua task.',cid) end talkState[talkUser] = 0 elseif msgcontains(msg,'completar') then if canDoTask(cid) then selfSay('Você não tem uma task iniciada ainda... diga {nova task} para começar uma.',cid) elseif permission > 1 then selfSay('Você não tem uma task ativa... e só poderá começar outra mais tarde.',cid) elseif killstotal > 1 and kills >= killstotal then selfSay('Parabéns por completar sua task!',cid) doCompleteTask(cid) else selfSay('Você ainda não completou sua task.',cid) end talkState[talkUser] = 0 elseif msgcontains(msg,'info') then if canDoTask(cid) and (monster == 0 or monster == -1) then selfSay('Você pode começar uma task dizendo {nova task}. Assim que disser, uma nova task será atribuída a você dependendo do seu level e você poderá acompanhar seu andamento dizendo {!countkills}.',cid) else selfSay('Você pode acompanhar sua task pelo comando {!countkills}. Assim que terminar, me avise e você receberá seu prêmio em dinheiro e experiência.',cid) end talkState[talkUser] = 0 elseif msgcontains(msg, 'pontos') then local pontos = getPlayerStorageValue(cid, taskstg.points) > 0 and getPlayerStorageValue(cid, taskstg.points) or 0 selfSay('Você tem '.. pontos ..' pontos de task.',cid) elseif msgcontains(msg,'cancelar') then if monster == 0 or monster == -1 then selfSay('Você não tem uma task ativa para cancelar.',cid) talkState[talkUser] = 0 else selfSay('Você tem certeza que quer cancelar sua task?',cid) talkState[talkUser] = 1 end elseif (msgcontains(msg,'yes') or msgcontains(msg,'sim')) and talkState[talkUser] == 1 then selfSay('Muito bem, sua task foi cancelada.',cid) doResetTask(cid) setPlayerStorageValue(cid,taskstg.permission,-1) setPlayerStorageValue(cid, taskstg.stage, getPlayerStorageValue(cid, taskstg.stage)-1) talkState[talkUser] = 0 elseif (msgcontains(msg,'no') or msgcontains(msg,'não')) and talkState[talkUser] == 1 then selfSay('Você que sabe, né...',cid) end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) olha o comando informacoes ou !countkills n estar fucionando
Postado Maio 22, 2014 11 anos Esqueci de mencionar: Data/Talkactions/Scripts/ - Cria um com nome de countkills.lua Adicione: function onSay(cid, words, param, channel) local monster, permission = getPlayerStorageValue(cid,taskstg.monster), getPlayerStorageValue(cid,taskstg.permission) local kills, killstotal = getPlayerStorageValue(cid,taskstg.kills), getPlayerStorageValue(cid,taskstg.killstotal) if monster == -1 or monster == 0 then doPlayerSendTextMessage(cid,27,'Voce nao tem nenhuma task ativa.') else local left = killstotal - kills if left <= 0 then doPlayerSendTextMessage(cid,27,'Voce ja matou monstros suficientes para terminar sua task.') else doPlayerSendTextMessage(cid,27,'Andamento da sua task de '..taskmonsters[monster][1]..'s -> ['..kills..'/'..killstotal..']') end end return true end Data/Talkactions/Talkactions.xml Adicione: <talkaction words="!countkills" event="script" value="countkills.lua"/>
Postado Maio 22, 2014 11 anos Autor Esqueci de mencionar: Data/Talkactions/Scripts/ - Cria um com nome de countkills.lua Adicione: function onSay(cid, words, param, channel) local monster, permission = getPlayerStorageValue(cid,taskstg.monster), getPlayerStorageValue(cid,taskstg.permission) local kills, killstotal = getPlayerStorageValue(cid,taskstg.kills), getPlayerStorageValue(cid,taskstg.killstotal) if monster == -1 or monster == 0 then doPlayerSendTextMessage(cid,27,'Voce nao tem nenhuma task ativa.') else local left = killstotal - kills if left <= 0 then doPlayerSendTextMessage(cid,27,'Voce ja matou monstros suficientes para terminar sua task.') else doPlayerSendTextMessage(cid,27,'Andamento da sua task de '..taskmonsters[monster][1]..'s -> ['..kills..'/'..killstotal..']') end end return true end Data/Talkactions/Talkactions.xml Adicione: <talkaction words="!countkills" event="script" value="countkills.lua"/> ou esse id no meu servidor ja existe kills = 3451, permission = 3452, killstotal = 3453, monster = 3454, stage = 3455, points = 3456, posso mudar pra qualquer um né?
Postado Maio 22, 2014 11 anos Isso são Storages e não IDs... Caso saiba o que é storage e tenha certeza que tem no seu servidor, pode altera-las !
Postado Maio 22, 2014 11 anos Autor Isso são Storages e não IDs... Caso saiba o que é storage e tenha certeza que tem no seu servidor, pode altera-las ! eu botei o numero 10000002 que n existe esse numero em nenhum intem e nem quests
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.