Ir para conteúdo
  • 0

Sistema de Aura


CaioValverde

Pergunta

Coloquei um sistema de aura pelo Creaturescripts, mas quando o player desloga tá dando um erro no distro, segue em anexo as fotos e meu aura.lua:

 

 

 

local tab = {
[6] = {effect = 70},
[7] = {effect = 70},
[8] = {effect = 70},
[9] = {effect = 70},
[10] = {effect = 70},
[11] = {effect = 70},-- [vocationID] = {effect = Number}
[12] = {effect = 70}
}
local delay = 2 -- tempo do efeito da aura em segundos
function onLogin(cid)
if tab[getPlayerVocation(cid)] then
ariseAura(cid)
end
return true
end
function ariseAura(cid)
doSendMagicEffect(getThingPos(cid), tab[getPlayerVocation(cid)].effect)
if isPlayer(cid) then
if not isCreature(cid) then return LUA_ERROR end
addEvent(ariseAura, delay * 1000, cid)
end
return true
end

 

 

 

Imagem do erro na distro:

GyPClW8.png

 

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0

^ como os códigos são interpretados na ordem que estão, haverá erro caso o jogador deslogue.

 

local tab = {
    [6] = {effect = 70},
    [7] = {effect = 70},
    [8] = {effect = 70},
    [9] = {effect = 70},
    [10] = {effect = 70},
    [11] = {effect = 70},-- [vocationID] = {effect = Number}
    [12] = {effect = 70}
}
local delay = 2 -- tempo do efeito da aura em segundos
function ariseAura(cid)
    if isPlayer(cid) then
        doSendMagicEffect(getThingPos(cid), tab[getPlayerVocation(cid)].effect)
        addEvent(ariseAura, delay * 1000, cid)
    end
end
function onLogin(cid)
    if tab[getPlayerVocation(cid)] then
        ariseAura(cid)
    end
    return true
end
Link para o comentário
Compartilhar em outros sites

  • 0

@@CaioValverde,

Tenta assim:

local tab = {
    [6] = {effect = 70},
	[7] = {effect = 70},
	[8] = {effect = 70},
	[9] = {effect = 70},
	[10] = {effect = 70},
	[11] = {effect = 70},-- [vocationID] = {effect = Number}
    [12] = {effect = 70}
}
 
local delay = 2 -- tempo do efeito da aura em segundos
 
function onLogin(cid)
    if tab[getPlayerVocation(cid)] then
		ariseAura(cid, tab[getPlayerVocation(cid)].effect)
    end
    return true
end
 
function ariseAura(cid, effect)
    if isPlayer(cid) then
		doSendMagicEffect(getPlayerPosition(cid), effect)
		addEvent(ariseAura, delay * 1000, cid)
    end
    return true
end
Editado por Bruno Minervino
Link para o comentário
Compartilhar em outros sites

  • 0


local voc = {6,7,8,9,10,11,12} -- Vocations

local dalay = 2 -- Segundos

local effect = 70 -- Efeito

 

function ariseAura(cid)

 

if isInArray(voc, getPlayerVocation(cid)) and isPlayer(cid) then

doSendMagicEffect(getThingPos(cid), effect)

addEvent(ariseAura, delay * 1000, cid)

end

 

return true

end

 

function onLogin(cid)

 

ariseAura(cid)

 

return true

end

 

Editado por ScreaM
Link para o comentário
Compartilhar em outros sites

  • 0

Olá, CaioValverde!

local storage_id = 44200
local effect = 70
local delay = 2 -- in seconds (you can also type like 0.5)
local vocations = {6, 7, 8, 9, 10, 11, 12}

-- If is player and storage == 1, add a new event and send effect
-- If is not player or storage ~= 1 or could not send effect, change storage to -1
function doAura(cid)
	if not isPlayer(cid) then
		return false
	end
	--[[
		-- Você pode criar uma condição. É só colocar nessa parte, por exemplo:
		-- Assim a aura só vai aparecer se o player tiver, no mínimo, 50% do HP
		local low_health = getCreatureHealth(cid) < getCreatureMaxHealth(cid) * (50 / 100)
		if low_health then
			setPlayerStorageValue(cid, storage_id, -1)
			return false
		end
	]]
	return getPlayerStorageValue(cid, storage_id) == 1 and addEvent(doAura, delay * 1000, cid) and doSendMagicEffect(getThingPos(cid), effect) or setPlayerStorageValue(cid, storage_id, -1) and false
end

function doPlayerSendAura(cid)
	if not isPlayer(cid) or not isInArray(vocations, getPlayerVocation(cid)) then
		return
	end
	setPlayerStorageValue(cid, storage_id, 1)
	doAura(cid)
end

function onLogin(cid)
	if getPlayerStorageValue(cid, storage_id) == 1 then
		doPlayerSendAura(cid)
	end
end

OBS:

Você controla a aura pela storage (1 = ativado, qualquer outro valor = desativado).

Você ativa pelo doPlayerSendAura(cid).

Para desativar a aura, é só usar setPlayerStorageValue(cid, storage_id, -1)

Do modo que está, todos os players sempre terão aura o tempo inteiro durante a storage == 1. Se alterar o valor da storage, a aura pára.

 

 

Atenciosamente,
River.

Editado por River
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...