Postado Maio 11, 2020 5 anos Boa noite, no meu otserv tem um item que ao da use você ganha 2 horas de heal e mana, porém se o player morrer ou relogar ele perde o buff ( mas a storage fica até as duas horas terminar). o meu problema é que quando o player relogar ou morrer continue curando pelo tempo restante. local l = { storage = 789159, -- storage do check mp = 2, -- porcentagem que vai ganhar de mana por segundo hp = 2, -- porcentagem que vai ganhar em hp por segundo secs = 1, -- em quanto em quanto segundos que vai healar hours = 2 -- quantas horas irá ficar healando } local function LoopRegen(uid) if isPlayer(uid) then if getPlayerStorageValue(uid, l.storage) > os.time() then doCreatureAddMana(uid, getCreatureMaxMana(uid)/100*l.mp) doCreatureAddHealth(uid, getCreatureMaxHealth(uid)/100*l.hp) addEvent(function() LoopRegen(uid) end, l.secs*1000) end end end function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, l.storage) < os.time() then doCreatureSetStorage(cid, l.storage, os.time()+l.hours*60*60) doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você agora está com heal de 2% de Mana e Life por "..l.hours.." hora"..(l.hours == 1 and "." or "s." )) LoopRegen(cid) doSendAnimatedText(getPlayerPosition(cid), "Amethyst", TEXTCOLOR_PURPLE) doSendMagicEffect(getCreaturePosition(cid), math.random(27,27)) doRemoveItem(item.uid, 1) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Desculpe, mas você já está com buff.") end return true end function onLogin(cid) return LoopRegen(l.storage, os.time()+l.hours*60*60, cid) end
Postado Maio 11, 2020 5 anos Solução @eunaosei123 Bom dia, tente assim: Eu alterei o seu script e centralizei toda a configuração dele no arquivo 066-heal para facilitar. 1 - Vá em data/lib e crie um arquivo chamado 066-heal e cole isto dentro: Spoiler config_heal = { storage = 789160, -- storage do check storage_save = 789911, mp = 2, -- porcentagem que vai ganhar de mana por segundo hp = 2, -- porcentagem que vai ganhar em hp por segundo secs = 1, -- em quanto em quanto segundos que vai healar hours = 2 -- quantas horas irá ficar healando } function LoopRegen(uid) if isPlayer(uid) then if getPlayerStorageValue(uid, config_heal.storage) > os.time() then doCreatureAddMana(uid, getCreatureMaxMana(uid)/100*config_heal.mp) doCreatureAddHealth(uid, getCreatureMaxHealth(uid)/100*config_heal.hp) addEvent(function() LoopRegen(uid) end, config_heal.secs*1000) end end end 2 - Vá em data/actions/scripts e abra o seu script atual e altere para este: Spoiler function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, config_heal.storage) < os.time() then doCreatureSetStorage(cid, config_heal.storage, os.time()+config_heal.hours*60*60) doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você agora está com heal de 2% de Mana e Life por "..config_heal.hours.." hora"..(config_heal.hours == 1 and "." or "s." )) LoopRegen(cid) doSendAnimatedText(getPlayerPosition(cid), "Amethyst", TEXTCOLOR_PURPLE) doSendMagicEffect(getCreaturePosition(cid), math.random(27,27)) doRemoveItem(item.uid, 1) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Desculpe, mas você já está com buff.") end return true end 3- Vá em data/creatureevents/scripts e crie um arquivo chamado healLogout.lua e cole isto dentro: Spoiler function onLogin(cid) if (getPlayerStorageValue(cid, config_heal.storage_save) ~= -1) then LoopRegen(cid) return true end return true end function onLogout(cid) if (getPlayerStorageValue(cid, config_heal.storage) ~= -1) then local time = os.time() - getPlayerStorageValue(cid, config_heal.storage) if (time < 0) then local time_positivo = time * 1 setPlayerStorageValue(cid, config_heal.storage_save, time_positivo) return true end setPlayerStorageValue(cid, config_heal.storage_save, time_positivo) end return true end - Por último abra o creatureevents.XML e cole estas duas tags dentro: Spoiler <event type="logout" name="HealLogout" event="script" value="healLogout.lua"/> <event type="login" name="HealLogin" event="script" value="healLogout.lua"/> Editado Maio 11, 2020 5 anos por MatteusDeli (veja o histórico de edições)
Postado Maio 11, 2020 5 anos Autor 2 horas atrás, MatteusDeli disse: @eunaosei123 Bom dia, tente assim: Eu alterei o seu script e centralizei toda a configuração dele no arquivo 066-heal para facilitar. 1 - Vá em data/lib e crie um arquivo chamado 066-heal e cole isto dentro: Mostrar conteúdo oculto config_heal = { storage = 789160, -- storage do check storage_save = 789911, mp = 2, -- porcentagem que vai ganhar de mana por segundo hp = 2, -- porcentagem que vai ganhar em hp por segundo secs = 1, -- em quanto em quanto segundos que vai healar hours = 2 -- quantas horas irá ficar healando } function LoopRegen(uid) if isPlayer(uid) then if getPlayerStorageValue(uid, config_heal.storage) > os.time() then doCreatureAddMana(uid, getCreatureMaxMana(uid)/100*config_heal.mp) doCreatureAddHealth(uid, getCreatureMaxHealth(uid)/100*config_heal.hp) addEvent(function() LoopRegen(uid) end, config_heal.secs*1000) end end end 2 - Vá em data/actions/scripts e abra o seu script atual e altere para este: Mostrar conteúdo oculto function onUse(cid, item, fromPosition, itemEx, toPosition) if getPlayerStorageValue(cid, config_heal.storage) < os.time() then doCreatureSetStorage(cid, config_heal.storage, os.time()+config_heal.hours*60*60) doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você agora está com heal de 2% de Mana e Life por "..config_heal.hours.." hora"..(config_heal.hours == 1 and "." or "s." )) LoopRegen(cid) doSendAnimatedText(getPlayerPosition(cid), "Amethyst", TEXTCOLOR_PURPLE) doSendMagicEffect(getCreaturePosition(cid), math.random(27,27)) doRemoveItem(item.uid, 1) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Desculpe, mas você já está com buff.") end return true end 3- Vá em data/creatureevents/scripts e crie um arquivo chamado healLogout.lua e cole isto dentro: Mostrar conteúdo oculto function onLogin(cid) if (getPlayerStorageValue(cid, config_heal.storage_save) ~= -1) then LoopRegen(cid) return true end return true end function onLogout(cid) if (getPlayerStorageValue(cid, config_heal.storage) ~= -1) then local time = os.time() - getPlayerStorageValue(cid, config_heal.storage) if (time < 0) then local time_positivo = time * 1 setPlayerStorageValue(cid, config_heal.storage_save, time_positivo) return true end setPlayerStorageValue(cid, config_heal.storage_save, time_positivo) end return true end - Por último abra o creatureevents.XML e cole estas duas tags dentro: Mostrar conteúdo oculto <event type="logout" name="HealLogout" event="script" value="healLogout.lua"/> <event type="login" name="HealLogin" event="script" value="healLogout.lua"/> Tá funcionando muito obrigado, mas me tire uma dúvida, teria como colocar para mostrar quanto ganha de hp e mana? tá mostrando só de life.
Postado Maio 12, 2020 5 anos @eunaosei123 Voce quer que apareça a mensagem de cura da mana e do life toda fez que ocorrer a regeneração?
Postado Maio 12, 2020 5 anos Autor 53 minutos atrás, MatteusDeli disse: @eunaosei123 Voce quer que apareça a mensagem de cura da mana e do life toda fez que ocorrer a regeneração? É porque tá mostrando somente o do healingh, o da mana não aparece. Editado Maio 12, 2020 5 anos por eunaosei123 (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.