em qual parte tu quer que fique random? Tu falar "yes" e ele dar uma task aleatória..?
Explique melhor...
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

em qual parte tu quer que fique random? Tu falar "yes" e ele dar uma task aleatória..?
Explique melhor...
Editado Agosto 26 por Bodak Reborn
Quando o player falar hi, task, ai o npc vai dar duas opção de task (aleatoria), ai o player escolhe uma das opcoes e fala yes e inicia a task.
Player: hi
Player: task
NPC: What task do you wat? Aleatoria 1 ou aleatoria 2?
Player: Aleatoria 1
NPC: Tem certeza?
Player: Yes
NPC: boa sorte
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

Perdão pela demora.
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 local tasks = { [1] = {name = "Blastoise"}, [2] = {name = "Electabuzz"}, [3] = {name = "Venusaur"}, [4] = {name = "Charizard"}, --[um número maior que o de cima] = {name = "nome do pokémon"}, } local function getRandomTaskMonster1 () local randomTask = math.random(1, #tasks) local taskPokemon = tasks[randomTask].name return taskPokemon end local function getRandomTaskMonster2 () local randomTask2 = math.random(1, #tasks) local taskPokemon2 = tasks[randomTask2].name return taskPokemon2 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 msg = msg:lower() --eh sempre bom por isso.. pra deixar a msg soh em letras minusculas if msgcontains(msg, "task") then if isMyTaskComplete(cid, getNpcCid()) then selfSay("Wow you have already complete my task! Ok then, take your reward!", cid) doPlayerAddExperience(cid, 1500000) --premio doPlayerAddItem(cid, 2160, 25) local sto = getMyTaskSto(cid, getNpcCid()) setPlayerStorageValue(cid, sto, -1) --nunca esqueça disso... setPlayerStorageValue(cid, 25566, os.time() + 24*60*60) setPlayerStorageValue(cid, 181601, 1) --storage da outfit setPlayerStorageValue(cid, 181602, 1) --storage da outfit talkState[talkUser] = 0 return true elseif getPlayerStorageValue(cid, 25588) > os.time() then selfSay("You have to wait 24h to do my task again!", cid) talkState[talkUser] = 0 return true elseif getMyTaskSto(cid, getNpcCid()) ~= -1 then selfSay("You are already doing my task! Go end it!", cid) talkState[talkUser] = 0 return true end randomName1 = getRandomTaskMonster1 () randomName2 = getRandomTaskMonster2 () while randomName1 == randomName2 do randomName1 = getRandomTaskMonster1 () randomName2 = getRandomTaskMonster2 () end selfSay("Choose one: "..randomName1.." or "..randomName2..".", cid) talkState[talkUser] = 1 return true end if (msg == randomName1:lower() or msg == randomName2:lower()) and talkState[talkUser] == 1 then selfSay("Are you sure?", cid) talkState[talkUser] = 2 return true elseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("You can't catch more tasks! You are already with the maximum of "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end selfSay("OK kill all, good luck!", cid) setStorageArray(cid, sto, task) talkState[talkUser] = 0 return true end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Obrigado.
Essa parte com o nome do NPC = Junko tem como adiconar?
Pq ele funcionar para a contagem da task no console, igual PDA
Faltou também a quantidade de pokemons para matar
["blastoise"] = {["Junko"] = {{"Blastoise", 3}}},
Editado Agosto 26 por deglorio
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

@deglorio, pode me mandar esse script para eu ver?
function onKill(cid, target)local continue = trueif ehMonstro(target) then for i = 91001, (91000+maxTasks) do local sto = getPlayerStorageValue(cid, i) if type(sto) == "string" then local array = getArrayFromStorage(cid, i) if arrayHasContent(array) then for e, f in pairs(array) do for a = 1, #f do if tostring(f[a][1]) == getCreatureName(target) and tonumber(f[a][2]) >= 1 then if (pokes[getPlayerStorageValue(cid, 854787)] and getCreatureName(getCreatureSummons(cid)[1]) ~= getPlayerStorageValue(cid, 854787)) then if npcsTask[tostring(e).."_1"] then continue = false --task clan end elseif e == "Agatha" and getCreatureName(target) == "Shiny Abra" and not isInRange(getThingPos(target), Agatha.fromPos, Agatha.toPos) then continue = false --alterado v1.9 agatha quest end if continue then f[a][2] = f[a][2]-1 if f[a][2] == 0 then doPlayerSendTextMessage(cid, 27, tostring(e)..": Quest Done!") else doPlayerSendTextMessage(cid, 27, tostring(e)..": You need to kill more "..f[a][2].." "..f[a][1]..(f[a][2] == 1 and "." or "s.")) end setStorageArray(cid, i, array) end continue = true end end end end end endend return trueend
creaturescripts que faz a contagem
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

@deglorio, pelo que eu li, esse script tá meio errado.
Dá /n .LeticiaTask, pega a task com ela, mata um Azumarill e um Tentacruel.
Provavelmente o Tentacruel não vai aparecer no chat, mas o Azumarill vai, certo?
Eu posso tentar arrumar esse script pra ti, mas tu vai ter que mudar todas as tabelas de task nos scripts.
Olha a lib, pelo menos aqui funciona perfeitamente, não tenho esse npc Letícia.
function getStingOfTask(cid, npc)if not isCreature(cid) then return "" endlocal str = {}local c = 0local nome = (npc and type(npc) == "string") and npc or (npc and isCreature(npc)) and getCreatureName(npc) or "" for i = 91001, (91000+maxTasks) do if getPlayerStorageValue(cid, i) ~= -1 and tostring(getPlayerStorageValue(cid, i)) then local array = getArrayFromStorage(cid, i) if arrayHasContent(array) then for e, f in pairs(array) do if (not npc) or (nome ~= "" and e == nome) then for a = 1, #f do local poke = f[a][1] local num = f[a][2] if tonumber(num) >= 1 then table.insert(str, ((a ~= 1 and c ~= 0) and ", " or "")..num.." "..poke..(num == 1 and "" or "s")) c = c+1 end end table.insert(str, ".\n") end end end endendreturn table.concat(str)endfunction arrayHasContent(array)if type(array) ~= "table" then return false endreturn next(array) and true or falseendfunction getMyTaskSto(cid, npc)if not isCreature(cid) or (type(npc) ~= "string" and not isCreature(npc)) then return -1 endfor i = 91001, (91000+maxTasks) do if getPlayerStorageValue(cid, i) ~= -1 and tostring(getPlayerStorageValue(cid, i)) then local t = string.explode(getPlayerStorageValue(cid, i), "/") if tostring(t[1]) and tostring(t[1]) == (type(npc) == "string" and npc or getCreatureName(npc)) then return i end endendreturn -1endfunction isMyTaskComplete(cid, npc)if not isCreature(cid) or (type(npc) ~= "string" and not isCreature(npc)) then return false endlocal storage = getMyTaskSto(cid, npc)local count = 0 if storage ~= -1 then local array = getArrayFromStorage(cid, storage) for e, f in pairs(array) do for i = 1, #f do count = count+f[i][2] end end else return false endif count == 0 then return true endend function getFreeTaskStorage(cid)if not isCreature(cid) then return -1 endfor i = 91001, (91000+maxTasks) do if type(getPlayerStorageValue(cid, i)) == "number" and getPlayerStorageValue(cid, i) <= -1 then return i endendreturn -1endfunction setStorageArray(cid, storage, array)if not isCreature(cid) or not storage or type(array) ~= "table" then return false endlocal str = ""for e, f in pairs(array) do for i = 1, #f do str = i == 1 and str..""..e.." / " or str.."" str = i == 1 and str..""..f[i][1] or str..";"..f[i][1] str = str..", "..f[i][2] endendsetPlayerStorageValue(cid, storage, str)return trueendfunction getArrayFromStorage(cid, storage)if not isCreature(cid) or not storage or type(getPlayerStorageValue(cid, storage)) ~= "string" then return {} endlocal array = {}local name = string.explode(getPlayerStorageValue(cid, storage), "/")if not name or type(name) ~= "table" then return {} endlocal t1 = string.explode(name[2], ";")array[name[1]] = {}for i = 1, #t1 do local t2 = string.explode(t1[i], ",") table.insert(array[name[1]], {t2[1], t2[2]})endreturn arrayend
Editado Agosto 26 por deglorio
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

Pra ser aleatório, tu tem que contar a quantidade de pokémon na tabela, então eu coloquei um índice numérico e fiz com FOR, ele da um math.random com o número do maior índice e pega o nome de um pokémon de um índice aleatório, só que nesse creaturescripts, o índice tem que ser o nome do NPC, porém, se eu colocar o nome de NPC como índice em várias linhas, ele só vai contar como uma, porque todos índices são iguais. Então, teria que modificar a função do creaturescripts pra pegar vários arrays com o mesmo índice e transformar a tabela "tasks" em uma sequência de arrays com o mesmo índice, só que pra dar math.random em uma sequência de arrays com o mesmo índice foge dos meus conhecimentos.
Resumo: não sei fazer, sorry.
Reputado mesmo assim, fez um ótimo trabalho, e se fizer um outrocreatureevent?
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

4 minutos atrás, deglorio disse:Reputado mesmo assim, fez um ótimo trabalho, e se fizer um outrocreatureevent?
Específico apenas para esse NPC?
SIM, farei mais 4 iguais, mudando apenas os pokes.
A mensagem pode ser
Daily: Faltam tantos monstros para matar
Daily: Quest done (caso conclua)
Ai não precisa por o nome do npc
info
Grupo: Campones
Registrado: 26/04/16
Posts: 90
Reputação: +28
Gênero: Masculino

6 minutos atrás, deglorio disse:SIM, farei mais 4 iguais, mudando apenas os pokes.
A mensagem pode ser
Daily: Faltam tantos monstros para matar
Daily: Quest done (caso conclua)
Ai não precisa por o nome do npc
Acho que fica mais simples, vou terminar um sistema que prometi pra um cara e já faço isso.
info
Grupo: Artesão
Registrado: 31/01/09
Posts: 108
Reputação: +44
local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)local talkState = {}function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) endfunction onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg)if(not npcHandler:isFocused(cid)) thenreturn falseend local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cidlocal tasks = {["blastoise"] = {["Junko"] = {{"Blastoise", 3}}}, --modifiquei aki, mas n sei se vai da certo kk["electabuzz"] = {["Junko"] = {{"Electabuzz", 3}}},["venusaur"] = {["Junko"] = {{"Venusaur", 3}}},["charizard"] = {["Junko"] = {{"Charizard", 3}}},}local msg = msg:lower() --eh sempre bom por isso.. pra deixar a msg soh em letras minusculas if msgcontains(msg, "task") then if isMyTaskComplete(cid, getNpcCid()) then selfSay("Wow you have already complete my task! Ok then, take your reward!", cid) doPlayerAddExperience(cid, 1500000) --premio doPlayerAddItem(cid, 2160, 25) local sto = getMyTaskSto(cid, getNpcCid()) setPlayerStorageValue(cid, sto, -1) --nunca esqueça disso... setPlayerStorageValue(cid, 25566, os.time() + 24*60*60) setPlayerStorageValue(cid, 181601, 1) --storage da outfit setPlayerStorageValue(cid, 181602, 1) --storage da outfit talkState[talkUser] = 0 return true elseif getPlayerStorageValue(cid, 25588) > os.time() then selfSay("You have to wait 24h to do my task again!", cid) talkState[talkUser] = 0 return true elseif getMyTaskSto(cid, getNpcCid()) ~= -1 then selfSay("You are already doing my task! Go end it!", cid) talkState[talkUser] = 0 return true end selfSay("What task do you want? {blastoise}, {electabuzz}, {venusaur}, {charizard}", cid) talkState[talkUser] = 1 return trueelseif isInArray({"blastoise", "electabuzz", "venusaur", "charizard"}, msg) and talkState[talkUser] == 1 then task = tasks[msg] --modifiquei aki tb selfSay("Are you sure?", cid) talkState[talkUser] = 2 return trueelseif msgcontains(msg, "yes") and talkState[talkUser] == 2 then local sto = getFreeTaskStorage(cid) if sto == -1 then selfSay("You can't catch more tasks! You are already with the maximum of "..(maxTasks).." tasks!", cid) talkState[talkUser] = 0 return true end selfSay("OK kill all, good luck!", cid) setStorageArray(cid, sto, task) talkState[talkUser] = 0 return trueend return trueendnpcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)npcHandler:addModule(FocusModule:new())Olá, achei esse script de um npc de task, ele funciona perfeitamente, porém tentei deixar os monstros da task random e não consegui, podem me ajudar?
Tentei de várias maneiras e não consegui
Desde já agradeço
Editado Agosto 27 por deglorio