Postado Abril 21, 2024 1 ano .Qual servidor ou website você utiliza como base? tfs 0.3.6 Qual o motivo deste tópico? spell(buff) com storage temporaria, não estou conseguindo setar a storage 55512 = -1 quando o player desloga no meio das stages Está surgindo algum erro? Se sim coloque-o aqui. Citar o player desloga no meio das stages da spell por exemplo: storage 55512 = 5, que é o stage 5, despois de um tempo o player loga e esta com essa storage ainda, sendo que a spell ja acabou quando ele deslogou porque é um "buff". eu queria uma solução fora da spell, porem não sei como, mas acredito que em creaturescript um codigo talvez consiga fazer algo quando todos players do servidor logar tivesse essa storage 55512 = -1, pra mim seria a melhor opção os dois codigos que estou deixando abaixo são funcionais, porem o primeiro eu entendo melhor, porem não sei qual é o melhor. 1º 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 2º function onCastSpell(cid, var) local waittime = 310 -- Tempo de exaustão local storage = 55512 -- Storage para controlar a spell local storage2 = 55513 -- Storage para controlar a spell local stages = { {time = 0, value = 1}, -- 0 segundos, storage = 1 {time = 30, value = 2}, -- 30 segundos adicionais, storage = 2 {time = 30, value = 3}, -- 30 segundos adicionais, storage = 3 {time = 40, value = 4}, -- 40 segundos adicionais, storage = 4 {time = 50, value = 5} -- 50 segundos adicionais, storage = 5 } 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 -- Verificar se o jogador já usou a spell if getPlayerStorageValue(cid, storage) > 5 then return false end -- Definir a exaustão e a storage inicial exhaustion.set(cid, storage2, waittime) setPlayerStorageValue(cid, storage, 1) -- Função para alterar a storage e verificar se o jogador está online local function changeStorage(cidGUID, newValue) local creature = getPlayerByGUID(cidGUID) if creature and isCreature(creature) then setPlayerStorageValue(creature, storage, newValue) if newValue == -1 then end end end -- Obter o GUID do jogador local cidGUID = getPlayerGUID(cid) -- Agendar as mudanças de storage local accumulatedTime = 0 for i, stage in ipairs(stages) do accumulatedTime = accumulatedTime + stage.time addEvent(changeStorage, accumulatedTime * 1000, cidGUID, stage.value) end -- Agendar o reset da storage para o valor -1 após o último estágio accumulatedTime = accumulatedTime + stages[#stages].time addEvent(changeStorage, accumulatedTime * 1000, cidGUID, -1) -- Verificar se o jogador já está transformado if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 50) == false and getCreatureCondition(cid, CONDITION_HASTE, 51) == false and getCreatureCondition(cid, CONDITION_REGENERATION, 52) == false then OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) return true else doPlayerSendCancel(cid, "Você já está transformado.") return true end end Editado Abril 21, 2024 1 ano por Gabrielx17 (veja o histórico de edições)
Postado Abril 29, 2024 1 ano Autor Em 21/04/2024 em 16:54, Gabrielx17 disse: .Qual servidor ou website você utiliza como base? tfs 0.3.6 Qual o motivo deste tópico? spell(buff) com storage temporaria, não estou conseguindo setar a storage 55512 = -1 quando o player desloga no meio das stages Está surgindo algum erro? Se sim coloque-o aqui. os dois codigos que estou deixando abaixo são funcionais, porem o primeiro eu entendo melhor, porem não sei qual é o melhor. 1º 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 2º function onCastSpell(cid, var) local waittime = 310 -- Tempo de exaustão local storage = 55512 -- Storage para controlar a spell local storage2 = 55513 -- Storage para controlar a spell local stages = { {time = 0, value = 1}, -- 0 segundos, storage = 1 {time = 30, value = 2}, -- 30 segundos adicionais, storage = 2 {time = 30, value = 3}, -- 30 segundos adicionais, storage = 3 {time = 40, value = 4}, -- 40 segundos adicionais, storage = 4 {time = 50, value = 5} -- 50 segundos adicionais, storage = 5 } 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 -- Verificar se o jogador já usou a spell if getPlayerStorageValue(cid, storage) > 5 then return false end -- Definir a exaustão e a storage inicial exhaustion.set(cid, storage2, waittime) setPlayerStorageValue(cid, storage, 1) -- Função para alterar a storage e verificar se o jogador está online local function changeStorage(cidGUID, newValue) local creature = getPlayerByGUID(cidGUID) if creature and isCreature(creature) then setPlayerStorageValue(creature, storage, newValue) if newValue == -1 then end end end -- Obter o GUID do jogador local cidGUID = getPlayerGUID(cid) -- Agendar as mudanças de storage local accumulatedTime = 0 for i, stage in ipairs(stages) do accumulatedTime = accumulatedTime + stage.time addEvent(changeStorage, accumulatedTime * 1000, cidGUID, stage.value) end -- Agendar o reset da storage para o valor -1 após o último estágio accumulatedTime = accumulatedTime + stages[#stages].time addEvent(changeStorage, accumulatedTime * 1000, cidGUID, -1) -- Verificar se o jogador já está transformado if getCreatureCondition(cid, CONDITION_ATTRIBUTES, 50) == false and getCreatureCondition(cid, CONDITION_HASTE, 51) == false and getCreatureCondition(cid, CONDITION_REGENERATION, 52) == false then OpenGate(cid, Select_Stages(getCreatureOutfit(cid).lookType), 1) return true else doPlayerSendCancel(cid, "Você já está transformado.") return true end end eu descobri e vou deixar aqui pra quem estiver com a mesma duvida ou problema: em creaturescript vai em login.lua e coloca esse codigo em cima dos registerCreature. if getPlayerStorageValue(cid, 55512) == 1 then setPlayerStorageValue(cid, 55512, -1) end toda vez que o player logar vai setar -1 na storage 55512. Editado Abril 29, 2024 1 ano por Gabrielx17 (veja o histórico de edições)
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.