Postado Abril 12, 2024 1 ano Diretor 1 hora atrás, Gabrielx17 disse: --ultimo edit-- obrigado mano funcionou perfeitamente vc é fera!!! uma pergunta eu consigo usar esse addevent para setar storage em etapas? tipo: storage 55512 = 1 por 20 segundos storage 55512 = 2 por 30 segundos storage 55512 = 3 por 40 segundos no caso seria quando o player usar a spell tipo usei spell susano(buff) ai no momento q eu usei daria 55512 = 1 por 20 segundos ai acabando os 20 segundos: ja iria pra storage 55512 = 2 por 30 segundos e acabando os 30 segundos: 55512 = 3 por 40 segundos function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {20, 30, 40} -- Tempos de espera para cada estágio em segundos if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end if not isCreature(cid) then return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 -- Função para avançar para o próximo estágio após o término do atual local function advanceStage() if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end end -- Iniciar o avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) -- Definir a exhaustion e aplicar os efeitos iniciais da spell local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage, waittime) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) -- Definir a storage de volta para -1 após o término do efeito da spell addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código. #OpenSource #Programação #Contribuição
Postado Abril 12, 2024 1 ano Autor 57 minutos atrás, L3K0T disse: function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {20, 30, 40} -- Tempos de espera para cada estágio em segundos if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end if not isCreature(cid) then return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 -- Função para avançar para o próximo estágio após o término do atual local function advanceStage() if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end end -- Iniciar o avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) -- Definir a exhaustion e aplicar os efeitos iniciais da spell local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage, waittime) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) -- Definir a storage de volta para -1 após o término do efeito da spell addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end Perfeito mano dei uma ajeitada aqui consegui! Obrigado voce é zika rep+ pra voce até eu n puder mais! Na verdade eu so não consegui uma coisa, quando o player desloga ou morre ele n consegue mais usar a spell pq fica setada em um numero e não volta qnd morre ou desloga se conseguir dar uma força ai agradeço ta me ajudando pra caramba kkkk so tenho a te agradecer! 57 minutos atrás, L3K0T disse: function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {20, 30, 40} -- Tempos de espera para cada estágio em segundos if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end if not isCreature(cid) then return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 -- Função para avançar para o próximo estágio após o término do atual local function advanceStage() if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end end -- Iniciar o avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) -- Definir a exhaustion e aplicar os efeitos iniciais da spell local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage, waittime) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) -- Definir a storage de volta para -1 após o término do efeito da spell addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end Spoiler function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {30, 30, 40, 50, 60} -- Tempos de espera para cada estágio em segundos local storage2 = 55513 local waittime3 = 310 if exhaustion.check(cid, storage2) then doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, storage2) .. " segundos para usar a spell novamente.") return false end if not isCreature(cid) then return false end if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 -- Função para avançar para o próximo estágio após o término do atual local function advanceStage() if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end end -- Iniciar o avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) -- Definir a exhaustion e aplicar os efeitos iniciais da spell local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage2, waittime3) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) -- Definir a storage de volta para -1 após o término do efeito da spell addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end eu deixei assim e ta funcionando perfeitamente aqui, os unicos problemas são o loggout, caso se o player morrer ou deslogar durante a spell(buff), ele fica impossibilitado de usar a spell(buff) tem como dar uma força? Editado Abril 13, 2024 1 ano por Gabrielx17 (veja o histórico de edições)
Postado Abril 13, 2024 1 ano Diretor 47 minutos atrás, Gabrielx17 disse: Perfeito mano dei uma ajeitada aqui consegui! Obrigado voce é zika rep+ pra voce até eu n puder mais! Na verdade eu so não consegui uma coisa, quando o player desloga ou morre ele n consegue mais usar a spell pq fica setada em um numero e não volta qnd morre ou desloga se conseguir dar uma força ai agradeço ta me ajudando pra caramba kkkk so tenho a te agradecer! Mostrar conteúdo oculto function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {30, 30, 40, 50, 60} -- Tempos de espera para cada estágio em segundos local storage2 = 55513 local waittime3 = 310 if exhaustion.check(cid, storage2) then doPlayerSendCancel(cid, "Aguarde " .. exhaustion.get(cid, storage2) .. " segundos para usar a spell novamente.") return false end if not isCreature(cid) then return false end if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 -- Função para avançar para o próximo estágio após o término do atual local function advanceStage() if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end end -- Iniciar o avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) -- Definir a exhaustion e aplicar os efeitos iniciais da spell local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage2, waittime3) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) -- Definir a storage de volta para -1 após o término do efeito da spell addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end eu deixei assim e ta funcionando perfeitamente aqui, os unicos problemas são o loggout, caso se o player morrer ou deslogar durante a spell(buff), ele fica impossibilitado de usar a spell(buff) tem como dar uma força? local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) if stage and stage > 0 then local waittimes = {20, 30, 40, 50} -- Tempos de espera para cada estágio em segundos local remainingTime = (waittimes[stage] - (os.time() - getPlayerStorageValue(cid, storage .. "time"))) -- Tempo restante em segundos if remainingTime > 0 then addEvent(function() doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você está sob o efeito do estágio " .. stage .. " da spell.") end, 1000) addEvent(function() setPlayerStorageValue(cid, storage, -1) end, remainingTime * 1000) -- Definir a storage de volta para -1 após o término do efeito da spell end end coloca no login.lua ^^^^^^^ function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {20, 30, 40, 50} -- Tempos de espera para cada estágio em segundos -- Verificar se o jogador já usou a spell if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end if not isCreature(cid) then return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 local function advanceStage() if isPlayerLoggedIn(cid) then -- Verificar se o jogador está logado antes de avançar de estágio if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você avançou para o estágio " .. stage .. " da spell.") else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end else -- O jogador desconectou, interromper o avanço de estágio setPlayerStorageValue(cid, storage, stage) -- Salvar o estágio atual end end addEvent(advanceStage, waittimes[stage] * 1000) local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage, waittime) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você está sob o efeito do estágio 1 da spell.") addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end spells.luaa Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código. #OpenSource #Programação #Contribuição
Postado Abril 13, 2024 1 ano Autor 45 minutos atrás, L3K0T disse: local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) if stage and stage > 0 then local waittimes = {20, 30, 40, 50} -- Tempos de espera para cada estágio em segundos local remainingTime = (waittimes[stage] - (os.time() - getPlayerStorageValue(cid, storage .. "time"))) -- Tempo restante em segundos if remainingTime > 0 then addEvent(function() doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você está sob o efeito do estágio " .. stage .. " da spell.") end, 1000) addEvent(function() setPlayerStorageValue(cid, storage, -1) end, remainingTime * 1000) -- Definir a storage de volta para -1 após o término do efeito da spell end end coloca no login.lua ^^^^^^^ function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {20, 30, 40, 50} -- Tempos de espera para cada estágio em segundos -- Verificar se o jogador já usou a spell if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end if not isCreature(cid) then return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 local function advanceStage() if isPlayerLoggedIn(cid) then -- Verificar se o jogador está logado antes de avançar de estágio if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você avançou para o estágio " .. stage .. " da spell.") else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end else -- O jogador desconectou, interromper o avanço de estágio setPlayerStorageValue(cid, storage, stage) -- Salvar o estágio atual end end addEvent(advanceStage, waittimes[stage] * 1000) local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage, waittime) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Você está sob o efeito do estágio 1 da spell.") addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end spells.luaa [12/04/2024 22:20:31] [Error - Spell Interface] [12/04/2024 22:20:31] In a timer event called from: [12/04/2024 22:20:31] data/spells/scripts/maito gai/hachimon_tonkou.lua:onCastSpell [12/04/2024 22:20:31] Description: [12/04/2024 22:20:31] data/spells/scripts/maito gai/hachimon_tonkou.lua:209: attempt to call global 'isPlayerLoggedIn' (a nil value) [12/04/2024 22:20:31] stack traceback: [12/04/2024 22:20:31] data/spells/scripts/maito gai/hachimon_tonkou.lua:209: in function <data/spells/scripts/maito gai/hachimon_tonkou.lua:208> da esse erro na distro e esta setando somente a primeira storage (1) o resto fica tudo -1 -1 -1 -1 Editado Abril 13, 2024 1 ano por Gabrielx17 (veja o histórico de edições)
Postado Abril 13, 2024 1 ano Diretor 7 horas atrás, Gabrielx17 disse: [12/04/2024 22:20:31] [Error - Spell Interface] [12/04/2024 22:20:31] In a timer event called from: [12/04/2024 22:20:31] data/spells/scripts/maito gai/hachimon_tonkou.lua:onCastSpell [12/04/2024 22:20:31] Description: [12/04/2024 22:20:31] data/spells/scripts/maito gai/hachimon_tonkou.lua:209: attempt to call global 'isPlayerLoggedIn' (a nil value) [12/04/2024 22:20:31] stack traceback: [12/04/2024 22:20:31] data/spells/scripts/maito gai/hachimon_tonkou.lua:209: in function <data/spells/scripts/maito gai/hachimon_tonkou.lua:208> da esse erro na distro e esta setando somente a primeira storage (1) o resto fica tudo -1 -1 -1 -1 logout: local storage = 55512 -- Storage para controlar a spell local stages = {20, 30, 40} -- Tempos de duração para cada estágio em segundos local remainingTime = exhaustion.get(cid, storage) -- Obtém o tempo restante da spell local stage = 1 for i, stageDuration in ipairs(stages) do if remainingTime <= stageDuration then stage = i break end remainingTime = remainingTime - stageDuration end -- Salva o estágio e o tempo restante da spell no storage do jogador setPlayerStorageValue(cid, storage, stage) exhaustion.set(cid, storage, remainingTime) login local storage = 55512 -- Storage para controlar a spell local stages = {20, 30, 40} -- Tempos de duração para cada estágio em segundos local remainingTime = getPlayerStorageValue(cid, storage) or 0 -- Obtém o tempo restante da spell do storage local stage = 1 -- Determina o estágio com base no tempo restante for i, stageDuration in ipairs(stages) do if remainingTime <= stageDuration then stage = i break end remainingTime = remainingTime - stageDuration end -- Restaura o estágio da spell para o jogador setPlayerStorageValue(cid, storage, stage) exhaustion.set(cid, storage, remainingTime) spells function onCastSpell(cid, var) local storage = 55512 -- Storage para controlar a spell local stage = getPlayerStorageValue(cid, storage) or 0 -- Obtém o estágio atual da spell, se não houver nenhum, assume 0 local waittimes = {20, 30, 40} -- Tempos de espera para cada estágio em segundos if stage > 0 then doPlayerSendCancel(cid, "Você já está sob o efeito da spell.") return false end if not isCreature(cid) then return false end -- Definir o estágio inicial da spell setPlayerStorageValue(cid, storage, 1) stage = 1 -- Função para avançar para o próximo estágio após o término do atual local function advanceStage() if stage < #waittimes then stage = stage + 1 setPlayerStorageValue(cid, storage, stage) -- Programar o próximo avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) else -- Resetar a storage quando todos os estágios terminarem setPlayerStorageValue(cid, storage, -1) end end -- Iniciar o avanço de estágio addEvent(advanceStage, waittimes[stage] * 1000) -- Definir a exhaustion e aplicar os efeitos iniciais da spell local waittime = waittimes[1] -- Definir o tempo de exhaustion baseado no primeiro estágio exhaustion.set(cid, storage, waittime) OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) -- Definir a storage de volta para -1 após o término do efeito da spell addEvent(function() setPlayerStorageValue(cid, storage, -1) end, waittime * 1000) -- Convertendo segundos para milissegundos return true end Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código. #OpenSource #Programação #Contribuição
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.