Ir para conteúdo
  • Cadastre-se

(Resolvido)Action Health


Ir para solução Resolvido por dirso,

Posts Recomendados

 

Alguém poderia me ajudar a fazer com que essa action cure meu summon invocado:

 

local summons = getCreatureSummons(cid)

if getPlayerStorageValue(cid, 8001) == 0 then
local hpAdd = math.random(10, 15)
if getCreatureSummons(cid) then
doCreatureAddHealth(summons, getCreatureMaxHealth(cid) * (hpAdd / 100))
doSendAnimatedText(getThingPos(summons), "+" .. hpAdd .. "%", TEXTCOLOR_RED)
doSendMagicEffect(getCreaturePosition(summons), CONST_ME_MAGIC_BLUE)
doRemoveItem(item.uid, 1)
setPlayerStorageValue(cid, 4789, tempo + os.time())
return true
end
end

Link para o post
Compartilhar em outros sites
Spoiler

local summons = getCreatureSummons(cid)

--if getPlayerStorageValue(cid, 8001) == 0 then
	local hpAdd = math.random(10, 15) / 100
	if getCreatureSummons(cid) then
		doCreatureAddHealth(summons, getCreatureMaxHealth(cid) * (hpAdd))
		doSendAnimatedText(getThingPos(summons), "+" .. hpAdd .. "%", TEXTCOLOR_RED)
		doSendMagicEffect(getCreaturePosition(summons), CONST_ME_MAGIC_BLUE)
		doRemoveItem(item.uid, 1)
		setPlayerStorageValue(cid, 4789, tempo + os.time())
	return true
	end
--end

 

 

Try this

Editado por dirso (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

deu esses erros @dirso

 

Spoiler


[13/9/2018 11:17:13] [Error - Action Interface]
[13/9/2018 11:17:13] data/actions/scripts/healthangels.lua:onUse
[13/9/2018 11:17:13] Description:
[13/9/2018 11:17:13] (LuaInterface::luaDoCreatureAddHealth) Creature not found

[13/9/2018 11:17:14] [Error - Action Interface]
[13/9/2018 11:17:14] data/actions/scripts/healthangels.lua:onUse
[13/9/2018 11:17:14] Description:
[13/9/2018 11:17:14] (LuaInterface::luaGetThingPosition) Thing not found

[13/9/2018 11:17:14] [Error - Action Interface]
[13/9/2018 11:17:14] data/actions/scripts/healthangels.lua:onUse
[13/9/2018 11:17:14] Description:
[13/9/2018 11:17:14] (LuaInterface::luaGetThingPosition) Thing not found

 

Link para o post
Compartilhar em outros sites
  • Solução
Spoiler

function onUse(cid)
	local summons = getCreatureSummons(cid)
	
	if summons then
		local hpAdd = math.random(10, 15) / 100

		for i=1, #summons do 
			doCreatureAddHealth(summons[i], getCreatureMaxHealth(cid) * hpAdd)
			doSendAnimatedText(getThingPos(summons[i]), "+" .. hpAdd .. "%", TEXTCOLOR_RED)
			doSendMagicEffect(getCreaturePosition(summons[i]), CONST_ME_MAGIC_BLUE)
			doRemoveItem(item.uid, 1)
			setPlayerStorageValue(cid, 4789, tempo + os.time())
		end
		return true
	end
	return false
end

 

 

Editado por dirso
Redefinição da função com Loop (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@dirso Aqui funcionou quase perfeitamente, esta healando o summon e talz, mas ele não tem exhaust e também o item não esta sumindo, ele tem cargas infinitas. O que eu tenho que arrumar???

 

aqui esta o erro

 

[18/9/2018 11:26:49] [Error - Action Interface] 
[18/9/2018 11:26:49] data/actions/scripts/heal summon.lua:onUse
[18/9/2018 11:26:49] Description: 
[18/9/2018 11:26:49] data/actions/scripts/heal summon.lua:14: attempt to index global 'item' (a nil value)
[18/9/2018 11:26:49] stack traceback:
[18/9/2018 11:26:49]     data/actions/scripts/heal summon.lua:14: in function <data/actions/scripts/heal summon.lua:1>

Editado por Zazeros
Informações imcompletas (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@Zazeros troca por esse script:

 

Spoiler

local tempo = 2 --  tempo do exaust em segundos.

function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerStorageValue(cid, 4789) > os.time() then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde 2 segundos para usar novamente.")
end

 

local summons = getCreatureSummons(cid)
    if summons then
        local hpAdd = math.random(0.5) / 100

        for i=1, #summons do
            doCreatureAddHealth(summons, getCreatureMaxHealth(summons) * hpAdd)
            doSendMagicEffect(getCreaturePosition(summons), CONST_ME_MAGIC_BLUE)
            doRemoveItem(item.uid, 1)
            setPlayerStorageValue(cid, 4789, tempo + os.time())
        end
        return true
end

end

 

Editado por Tchuka (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@Tchuka Cara, agora esta dando esse esse aqui: 

 

[18/9/2018 15:26:41] [Error - Action Interface] 
[18/9/2018 15:26:41] data/actions/scripts/heal summon.lua:onUse
[18/9/2018 15:26:41] Description: 
[18/9/2018 15:26:41] data/actions/scripts/heal summon.lua:9: bad argument #1 to 'random' (interval is empty)
[18/9/2018 15:26:41] stack traceback:
[18/9/2018 15:26:41]     [C]: in function 'random'
[18/9/2018 15:26:41]     data/actions/scripts/heal summon.lua:9: in function <data/actions/scripts/heal summon.lua:2>

Link para o post
Compartilhar em outros sites

tenta assim

 

Spoiler

local tempo = 2 --  tempo do exaust em segundos.

function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerStorageValue(cid, 4789) > os.time() then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde 2 segundos para usar novamente.")
end

 

local summons = getCreatureSummons(cid)
    if summons then
        local hpAdd = 0.5 / 100

        for i=1, #summons do
            doCreatureAddHealth(summons, getCreatureMaxHealth(summons) * hpAdd)
            doSendMagicEffect(getCreaturePosition(summons), CONST_ME_MAGIC_BLUE)
            doRemoveItem(item.uid, 1)
            setPlayerStorageValue(cid, 4789, tempo + os.time())
        end
        return true
end

end

 

Link para o post
Compartilhar em outros sites

@Tchuka Continua dando erro...: 

 

[18/9/2018 18:21:14] [Error - Action Interface] 
[18/9/2018 18:21:14] data/actions/scripts/heal summon.lua:onUse
[18/9/2018 18:21:14] Description: 
[18/9/2018 18:21:14] data/actions/scripts/heal summon.lua:11: attempt to perform arithmetic on a boolean value
[18/9/2018 18:21:14] stack traceback:
[18/9/2018 18:21:14]     data/actions/scripts/heal summon.lua:11: in function <data/actions/scripts/heal summon.lua:2>

Link para o post
Compartilhar em outros sites

Caraca vei kkkk

 

vai este

 

Spoiler

local tempo = 2
function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerStorageValue(cid, 4789) > os.time() then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde 2 segundos para usar novamente.")
end

 

    local summons = getCreatureSummons(cid)
    if getPlayerStorageValue(cid, 8001) == 0 then
    if summons then
        local hpAdd = math.random(0.5) / 100

        for i=1, #summons do
            doCreatureAddHealth(summons, getCreatureMaxHealth(summons) * hpAdd)
            doSendMagicEffect(getCreaturePosition(summons), CONST_ME_MAGIC_BLUE)
            doRemoveItem(item.uid, 1)
            setPlayerStorageValue(cid, 4789, tempo + os.time())
        end
        return true
    end
end

end

 

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo