Postado Março 3, 2020 5 anos ola galera boa tarde, entao eu preciso de algo simplpes gostaria de um npc que desse uma task que poderia fazer 1x por dia que daria 2 opçoes de pokemons ( configuraveis e para cada player uma task diferente tipo a daily da pxg ) eu colocaria os pokemons com a possibilidade de cair na task e etc.. eu n manjo muito , mas creio que pra vcs que sao bruxo aki é moleza , desde ja agradeço vlw glr
Postado Março 16, 2020 5 anos Solução @usoparagames Veja se é isso que você quer. 1 - INSTALANDO O SCRIPT NA LIB DO SERVIDOR Spoiler 1 - Vá em data/lib e crie um arquivo chamado dailyTaskSystem.lua e cole isso dentro: ---------- [[ Configurações ]] --------- task_time = 24 -- quantas horas o player ira aguardar para começar a quest novamente listaPokemons = { [1] = {PokemonName = "Blastoise", Count = 5, Experience=1200, Storage=11111}, [2] = {PokemonName = "Charizard", Count = 5, Experience=1200, Storage=11112}, [3] = {PokemonName = "Charmander", Count = 5, Experience=1200, Storage=11113}, [4] = {PokemonName = "Kakuna", Count = 5, Experience=1200, Storage=11114}, [5] = {PokemonName = "Rattata", Count = 5, Experience=1200, Storage=11115}, [6] = {PokemonName = "Caterpie", Count = 5, Experience=1200, Storage=11116}, [7] = {PokemonName = "Mew", Count = 5, Experience=1200, Storage=11117}, } -------------------------------------- task_start = 555118 task_finish = 555119 task_storage_time = 444513 task_start_opcao1 = 554460 task_start_opcao2 = 554461 task_info_table_opcao1 = nil task_info_table_opcao2 = nil function GetTaskInfo(cid) if (getPlayerStorageValue(cid, task_start_opcao1) > 0) then return listaPokemons[getPlayerStorageValue(cid, task_start_opcao1)] or false end if (getPlayerStorageValue(cid, task_start_opcao2) > 0) then return listaPokemons[getPlayerStorageValue(cid, task_start_opcao2)] or false end end function PokemonOpcao1() task_info_table_opcao1 = math.random(1, #listaPokemons) return listaPokemons[task_info_table_opcao1] end function PokemonOpcao2() task_info_table_opcao2 = math.random(1, #listaPokemons) return listaPokemons[task_info_table_opcao2] end function ClearAllStoragePlayer(cid) for _, storage in ipairs(listaPokemons) do setPlayerStorageValue(cid, storage, 0) end end 2 - CRIANDO O NPC DAILY Spoiler 1 - Abra o data/npc e crie um arquivo XML com o nome Daily.xml e cole isso dentro: <?xml version="1.0" encoding="UTF-8"?> <npc name="Daily" script="data/npc/scripts/daily.lua" walkinterval="1000" floorchange="0"> <health now="100" max="100"/> <look type="128" head="96" body="99" legs="76" feet="115" addons="1"/> <parameters> <parameter key="message_greet" value="|PLAYERNAME|! Eu tenho uma tarefa para você, diga {daily} pra saber mais." /> </parameters> </npc> 2 - Vá em data/npc/scripts e crie um arquivo LUA chamado daily.lua e cole isso dentro: 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 opcao1 = nil local opcao2 = nil local pokemonNameOpcao1 = '' local pokemonNameOpcao2 = '' local opcaoSelecionada = nil function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'daily') then if (getPlayerStorageValue(cid, task_start) >= 1) then return selfSay("Voce ja escolheu uma task hoje, termine-a primeiro.") end if (getPlayerStorageValue(cid, task_storage_time) > os.time()) then return selfSay("Voce ja terminou a sua task hoje, volte amanha.") end setPlayerStorageValue(cid, task_storage_time, -1) selfSay("Diga 'pokemons' para saber quais pokemons estao disponiveis hoje.") talkState[cid] = 0 end if (getPlayerStorageValue(cid, task_storage_time) < os.time()) then if msgcontains(msg, 'pokemons') and talkState[cid] == 0 and pokemonNameOpcao1 == '' and pokemonNameOpcao2 == '' then opcao1 = PokemonOpcao1() opcao2 = PokemonOpcao2() pokemonNameOpcao1 = opcao1.PokemonName pokemonNameOpcao2 = opcao2.PokemonName selfSay("Opcao 1: Voce tera que derrotar "..opcao1.Count.." "..opcao1.PokemonName.."(s).") selfSay("Opcao 2: Voce tera que derrotar "..opcao2.Count.." "..opcao2.PokemonName.."(s).") talkState[cid] = 1 end if msgcontains(msg, 'pokemons') and talkState[cid] == 0 and pokemonNameOpcao1 ~= '' and pokemonNameOpcao2 ~= '' then selfSay("Essas sao as opcoes de pokemons para voce hoje.") selfSay("Opcao 1: Voce tera que derrotar "..opcao1.Count.." "..opcao1.PokemonName.."(s).") selfSay("Opcao 2: Voce tera que derrotar "..opcao2.Count.." "..opcao2.PokemonName.."(s).") talkState[cid] = 1 end end if msgcontains(string.lower(msg), string.lower(pokemonNameOpcao1)) and talkState[cid] == 1 then opcaoSelecionada = opcao1 GetOpcaoSelecionada(cid, msg, opcao1) StorageStartTaskOpcao1 = opcao1 setPlayerStorageValue(cid, task_start_opcao1, task_info_table_opcao1) talkState[cid] = 0 end if msgcontains(string.lower(msg), string.lower(pokemonNameOpcao2)) and talkState[cid] == 1 then opcaoSelecionada = opcao2 GetOpcaoSelecionada(cid, msg, opcao2) setPlayerStorageValue(cid, task_start_opcao2, task_info_table_opcao2) talkState[cid] = 0 end if (getPlayerStorageValue(cid, task_finish) >= 1) then if (msgcontains(msg, 'reward')) then if (opcaoSelecionada ~= nil) then selfSay("Parabens voce acabou a task diaria de hoje. Voce ganhou "..opcaoSelecionada.Experience.." de experiencia.") doPlayerAddExperience(cid, opcaoSelecionada.Experience) setPlayerStorageValue(cid, task_storage_time, os.time() + (60 * 60 * task_time)) setPlayerStorageValue(cid, task_start, -1) setPlayerStorageValue(cid, task_finish, -1) pokemonNameOpcao1 = '' pokemonNameOpcao2 = '' opcaoSelecionada = nil talkState[cid] = 0 end end end return TRUE end function GetOpcaoSelecionada(cid, msg, opcao) if (string.lower(msg) == string.lower(opcao.PokemonName)) then setPlayerStorageValue(cid, task_start, 1) selfSay("Voce comecou a task, voce precisa matar ["..opcao.Count.." "..opcao.PokemonName.."]. Boa Sorte!") npcHandler:releaseFocus(cid) talkState[cid] = 0 end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) 3 - CONFIGURANDO O CREATURESCRIPTS Spoiler 1 - Vá em data/creaturescripts e abra o creaturescripts.xml e cole isso dentro: <event type="kill" name="dailyKill" event="script" value="dailyKill.lua"/> 2 - Vá em data/creaturescripts/scripts e abra o login.lua e cole isso dentro: registerCreatureEvent(cid, "dailyKill") 3 - Ná mesma pasta data/creaturescripts/scripts crie um arquivo LUA chamado dailyKill.lua e cole isso dentro: local countKill = 0 function onKill(cid, target) local infoTask = GetTaskInfo(cid) if (infoTask) then if (string.lower(getCreatureName(target)) == string.lower(infoTask.PokemonName)) then if (getPlayerStorageValue(cid, task_storage_time) == 1) then return true end if (countKill == infoTask.Count-1) then countKill = 0 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Parabens, voce matou todos os "..infoTask.PokemonName.."s.") setPlayerStorageValue(cid, task_storage_time, 1) setPlayerStorageValue(cid, task_finish, 1) ClearAllStoragePlayer(cid) return true end countKill = (getPlayerStorageValue(cid, infoTask.Storage)+1) if (countKill == 0 or countKill >= infoTask.Count) then countKill = 1 end setPlayerStorageValue(cid, infoTask.Storage, countKill) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Voce ja matou ["..countKill.. "/"..infoTask.Count.."] "..infoTask.PokemonName.."(s).") end end return TRUE end 4 - CONFIGURANDO UM NOVO POKEMON Spoiler Para configurar um novo pokemon na daily basta voce abrir o data/lib/dailyTaskSystem.lua e copiar e colar uma nova linha alterando os seguintes valores. listaPokemons = { [1] = {PokemonName = "Blastoise", Count = 5, Experience=1200, Storage=11111}, [2] = {PokemonName = "Charizard", Count = 5, Experience=1200, Storage=11112}, [3] = {PokemonName = "Charmander", Count = 5, Experience=1200, Storage=11113}, [4] = {PokemonName = "Kakuna", Count = 5, Experience=1200, Storage=11114}, [5] = {PokemonName = "Rattata", Count = 5, Experience=1200, Storage=11115}, [6] = {PokemonName = "Caterpie", Count = 5, Experience=1200, Storage=11116}, [7] = {PokemonName = "Mew", Count = 5, Experience=1200, Storage=11117}, [8] = {PokemonName = "Celebi", Count = 5, Experience=1200, Storage=11118}, } 1 - Siga a ordem dos numeros no colchetes [] 2 - Nome do pokemon entre aspas "" 3 - Quantidade de pokemon que o jogador terá que matar 4 - A experiencia que o jogador ganhará quando acabar a task 5 - Siga a ordem dos numeros
Postado Março 16, 2020 5 anos 29 minutos atrás, MatteusDeli disse: @usoparagames Veja se é isso que você quer. 1 - INSTALANDO O SCRIPT NA LIB DO SERVIDOR Mostrar conteúdo oculto 1 - Vá em data/lib e crie um arquivo chamado dailyTaskSystem.lua e cole isso dentro: ---------- [[ Configurações ]] --------- task_time = 24 -- quantas horas o player ira aguardar para começar a quest novamente listaPokemons = { [1] = {PokemonName = "Blastoise", Count = 5, Experience=1200, Storage=11111}, [2] = {PokemonName = "Charizard", Count = 5, Experience=1200, Storage=11112}, [3] = {PokemonName = "Charmander", Count = 5, Experience=1200, Storage=11113}, [4] = {PokemonName = "Kakuna", Count = 5, Experience=1200, Storage=11114}, [5] = {PokemonName = "Rattata", Count = 5, Experience=1200, Storage=11115}, [6] = {PokemonName = "Caterpie", Count = 5, Experience=1200, Storage=11116}, [7] = {PokemonName = "Mew", Count = 5, Experience=1200, Storage=11117}, } -------------------------------------- task_start = 555118 task_finish = 555119 task_storage_time = 444513 task_start_opcao1 = 554460 task_start_opcao2 = 554461 task_info_table_opcao1 = nil task_info_table_opcao2 = nil function GetTaskInfo(cid) if (getPlayerStorageValue(cid, task_start_opcao1) > 0) then return listaPokemons[getPlayerStorageValue(cid, task_start_opcao1)] or false end if (getPlayerStorageValue(cid, task_start_opcao2) > 0) then return listaPokemons[getPlayerStorageValue(cid, task_start_opcao2)] or false end end function PokemonOpcao1() task_info_table_opcao1 = math.random(1, #listaPokemons) return listaPokemons[task_info_table_opcao1] end function PokemonOpcao2() task_info_table_opcao2 = math.random(1, #listaPokemons) return listaPokemons[task_info_table_opcao2] end function ClearAllStoragePlayer(cid) for _, storage in ipairs(listaPokemons) do setPlayerStorageValue(cid, storage, 0) end end 2 - CRIANDO O NPC DAILY Mostrar conteúdo oculto 1 - Abra o data/npc e crie um arquivo XML com o nome Daily.xml e cole isso dentro: <?xml version="1.0" encoding="UTF-8"?> <npc name="Daily" script="data/npc/scripts/daily.lua" walkinterval="1000" floorchange="0"> <health now="100" max="100"/> <look type="128" head="96" body="99" legs="76" feet="115" addons="1"/> <parameters> <parameter key="message_greet" value="|PLAYERNAME|! Eu tenho uma tarefa para você, diga {daily} pra saber mais." /> </parameters> </npc> 2 - Vá em data/npc/scripts e crie um arquivo LUA chamado daily.lua e cole isso dentro: 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 opcao1 = nil local opcao2 = nil local pokemonNameOpcao1 = '' local pokemonNameOpcao2 = '' local opcaoSelecionada = nil function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if msgcontains(msg, 'daily') then if (getPlayerStorageValue(cid, task_start) >= 1) then return selfSay("Voce ja escolheu uma task hoje, termine-a primeiro.") end if (getPlayerStorageValue(cid, task_storage_time) > os.time()) then return selfSay("Voce ja terminou a sua task hoje, volte amanha.") end setPlayerStorageValue(cid, task_storage_time, -1) selfSay("Diga 'pokemons' para saber quais pokemons estao disponiveis hoje.") talkState[cid] = 0 end if (getPlayerStorageValue(cid, task_storage_time) < os.time()) then if msgcontains(msg, 'pokemons') and talkState[cid] == 0 and pokemonNameOpcao1 == '' and pokemonNameOpcao2 == '' then opcao1 = PokemonOpcao1() opcao2 = PokemonOpcao2() pokemonNameOpcao1 = opcao1.PokemonName pokemonNameOpcao2 = opcao2.PokemonName selfSay("Opcao 1: Voce tera que derrotar "..opcao1.Count.." "..opcao1.PokemonName.."(s).") selfSay("Opcao 2: Voce tera que derrotar "..opcao2.Count.." "..opcao2.PokemonName.."(s).") talkState[cid] = 1 end if msgcontains(msg, 'pokemons') and talkState[cid] == 0 and pokemonNameOpcao1 ~= '' and pokemonNameOpcao2 ~= '' then selfSay("Essas sao as opcoes de pokemons para voce hoje.") selfSay("Opcao 1: Voce tera que derrotar "..opcao1.Count.." "..opcao1.PokemonName.."(s).") selfSay("Opcao 2: Voce tera que derrotar "..opcao2.Count.." "..opcao2.PokemonName.."(s).") talkState[cid] = 1 end end if msgcontains(string.lower(msg), string.lower(pokemonNameOpcao1)) and talkState[cid] == 1 then opcaoSelecionada = opcao1 GetOpcaoSelecionada(cid, msg, opcao1) StorageStartTaskOpcao1 = opcao1 setPlayerStorageValue(cid, task_start_opcao1, task_info_table_opcao1) talkState[cid] = 0 end if msgcontains(string.lower(msg), string.lower(pokemonNameOpcao2)) and talkState[cid] == 1 then opcaoSelecionada = opcao2 GetOpcaoSelecionada(cid, msg, opcao2) setPlayerStorageValue(cid, task_start_opcao2, task_info_table_opcao2) talkState[cid] = 0 end if (getPlayerStorageValue(cid, task_finish) >= 1) then if (msgcontains(msg, 'reward')) then if (opcaoSelecionada ~= nil) then selfSay("Parabens voce acabou a task diaria de hoje. Voce ganhou "..opcaoSelecionada.Experience.." de experiencia.") doPlayerAddExperience(cid, opcaoSelecionada.Experience) setPlayerStorageValue(cid, task_storage_time, os.time() + (60 * 60 * task_time)) setPlayerStorageValue(cid, task_start, -1) setPlayerStorageValue(cid, task_finish, -1) pokemonNameOpcao1 = '' pokemonNameOpcao2 = '' opcaoSelecionada = nil talkState[cid] = 0 end end end return TRUE end function GetOpcaoSelecionada(cid, msg, opcao) if (string.lower(msg) == string.lower(opcao.PokemonName)) then setPlayerStorageValue(cid, task_start, 1) selfSay("Voce comecou a task, voce precisa matar ["..opcao.Count.." "..opcao.PokemonName.."]. Boa Sorte!") npcHandler:releaseFocus(cid) talkState[cid] = 0 end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) 3 - CONFIGURANDO O CREATURESCRIPTS Mostrar conteúdo oculto 1 - Vá em data/creaturescripts e abra o creaturescripts.xml e cole isso dentro: <event type="kill" name="dailyKill" event="script" value="dailyKill.lua"/> 2 - Vá em data/creaturescripts/scripts e abra o login.lua e cole isso dentro: registerCreatureEvent(cid, "dailyKill") 3 - Ná mesma pasta data/creaturescripts/scripts crie um arquivo LUA chamado dailyKill.lua e cole isso dentro: local countKill = 0 function onKill(cid, target) local infoTask = GetTaskInfo(cid) if (infoTask) then if (string.lower(getCreatureName(target)) == string.lower(infoTask.PokemonName)) then if (getPlayerStorageValue(cid, task_storage_time) == 1) then return true end if (countKill == infoTask.Count-1) then countKill = 0 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Parabens, voce matou todos os "..infoTask.PokemonName.."s.") setPlayerStorageValue(cid, task_storage_time, 1) setPlayerStorageValue(cid, task_finish, 1) ClearAllStoragePlayer(cid) return true end countKill = (getPlayerStorageValue(cid, infoTask.Storage)+1) if (countKill == 0 or countKill >= infoTask.Count) then countKill = 1 end setPlayerStorageValue(cid, infoTask.Storage, countKill) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "Voce ja matou ["..countKill.. "/"..infoTask.Count.."] "..infoTask.PokemonName.."(s).") end end return TRUE end 4 - CONFIGURANDO UM NOVO POKEMON Mostrar conteúdo oculto Para configurar um novo pokemon na daily basta voce abrir o data/lib/dailyTaskSystem.lua e copiar e colar uma nova linha alterando os seguintes valores. listaPokemons = { [1] = {PokemonName = "Blastoise", Count = 5, Experience=1200, Storage=11111}, [2] = {PokemonName = "Charizard", Count = 5, Experience=1200, Storage=11112}, [3] = {PokemonName = "Charmander", Count = 5, Experience=1200, Storage=11113}, [4] = {PokemonName = "Kakuna", Count = 5, Experience=1200, Storage=11114}, [5] = {PokemonName = "Rattata", Count = 5, Experience=1200, Storage=11115}, [6] = {PokemonName = "Caterpie", Count = 5, Experience=1200, Storage=11116}, [7] = {PokemonName = "Mew", Count = 5, Experience=1200, Storage=11117}, [8] = {PokemonName = "Celebi", Count = 5, Experience=1200, Storage=11118}, } 1 - Siga a ordem dos numeros no colchetes [] 2 - Nome do pokemon entre aspas "" 3 - Quantidade de pokemon que o jogador terá que matar 4 - A experiencia que o jogador ganhará quando acabar a task 5 - Siga a ordem dos numeros server pra outro derivado, sem ser pokemon?
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.