Sistema de Aura

CaioValverde
em Scripts

CaioValverde

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 21/12/12Posts: 60

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

 

Bruno

Ousadia e Alegria
avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 01/05/08Posts: 2571Gênero: Masculino

@@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

Atenciosamente,
Bruno Minervino

 

Tibia Clients - Downloads Window

Furabio

Why be a king.. when you can be a god
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 08/04/15Posts: 962Gênero: Masculino


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

 

EQD4Qy4.gif

 

zipter98

avatar
Herói
Herói

INFOS

Grupo: HeróiRegistrado: 20/09/12Posts: 2553Gênero: Masculino

^ 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

Não respondo PMs solicitando suporte. Já existem seções no fórum para isto.

River

Kingdom Age TM
avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 05/08/06Posts: 71

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.

CaioValverde

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 21/12/12Posts: 60

@zipter, testei o seu primeiro, pois já te conhecia... Valeu manin, funcionou... E obrigado a todos !!!

Furabio

Why be a king.. when you can be a god
avatar
Conde
Conde

INFOS

Grupo: CondeRegistrado: 08/04/15Posts: 962Gênero: Masculino

Tópico movido para a seção de dúvidas e pedidos resolvidos.

EQD4Qy4.gif