Ir para conteúdo
  • 0

[Resolvido] Effect após morrer.


diarmaint

Pergunta

Ao morrer o player fique com um effect.

preciso editar o tempo de duração, posição xyz, effect diferente por classe e o tempo entre os effects.

TFS 0.4

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

11 respostass a esta questão

Posts Recomendados

  • 1
  • Diretor
57 minutos atrás, diarmaint disse:

Funcionou perfeitamente mas tem como editar o xyz? pois algumas vocações tem sprites maiores.

Aonde mudo pra deixar o mesmo effect para todas as classes? preciso do mesmo para outro servidor.

Pra tu ajeitar a posição você poderia por isso:

local pos = getPlayerPosition(cid)
local position = {x = pos.x, y = pos.y - 1, z = pos.z}

Só por o valor -1 ou +1 ... Dai o doSendMagicEffect tu poderia deixar assim:

doSendMagicEffect(position, config[getPlayerVocation(cid)])

Ou você poderia ajusta isso na sprite mesmo, deixar ela de acordo com o personagem...

E para funcionar o mesmo efeito em todos deixe o script assim:

Spoiler

local repetir = 2 --  Tempo para repetir o efeito
local tempo = 1 * 60 -- Tempo em minutos que ficará com o efeito
local str = 037668 -- storage, não mexa!
local effect = 29 -- Efeito

function onDeath(cid, corpse, deathList)
	setPlayerStorageValue(cid, str, os.time() + tempo)
	return true
end
function onLogin(cid)
	registerCreatureEvent(cid, "deathEffect")
	if getPlayerStorageValue(cid, str) > os.time() then
		effects(cid, getPlayerStorageValue(cid, str) - os.time())
	end
	return true
end

function effects(cid, tempo)
	if isPlayer(cid) then
		if tempo > 0 then
			doSendMagicEffect(getPlayerPosition(cid), effect) -- or getThingPos(cid)
			addEvent(effects, repetir * 1000, cid, tempo-repetir)
		else
			setPlayerStorageValue(cid, str, 0)
			return true
		end
	end
end
-- Créditos: Yan Liima(Xtibia)

 

 

Link para o comentário
Compartilhar em outros sites

  • 0
9 minutos atrás, Thalles Vitor disse:

Só ir no script de death do player e colar lá

Posso deixar aqui ?

Citar

local config = {
    deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
    sqlType = getConfigInfo('sqlType'),
    maxDeathRecords = getConfigInfo('maxDeathRecords')
}

config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL

function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
doSendMagicEffect(getThingPos(cid), 530)
    if(config.deathListEnabled ~= TRUE) then
        return
    end

    local hitKillerName = "field item"
    local damageKillerName = ""
    if(lastHitKiller ~= FALSE) then
        if(isPlayer(lastHitKiller) == TRUE) then
            hitKillerName = getPlayerGUID(lastHitKiller)
        else
            hitKillerName = getCreatureName(lastHitKiller)
        end

        if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
            if(isPlayer(mostDamageKiller) == TRUE) then
                damageKillerName = getPlayerGUID(mostDamageKiller)
            else
                damageKillerName = getCreatureName(mostDamageKiller)
            end
        end
    end

    db.query("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
    local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
    if(rows:getID() ~= -1) then
        local amount = rows:getRows(true) - config.maxDeathRecords
        if(amount > 0) then
            if(config.sqlType == DATABASE_ENGINE_SQLITE) then
                for i = 1, amount do
                    db.query("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
                end
            else
                db.query("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
            end
        end
    end
end
 

Alí não aconteceu nada

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

  • 0
  • Diretor

Me explique direito como quer que faço para você sem gambiarras. Ao morrer ele recebe um effect por X tempo? o efeito vai ficar nele ou acima da cabeça dele? quer para todos a mesma coisa ou cada um com um efeito?

Link para o comentário
Compartilhar em outros sites

  • 0
Agora, Yan Liima disse:

Me explique direito como quer que faço para você sem gambiarras. Ao morrer ele recebe um effect por X tempo? o efeito vai ficar nele ou acima da cabeça dele? quer para todos a mesma coisa ou cada um com um efeito?

Isso, após morrer aparece o efeito por 1 minuto., seria um effect para cada classe.

queria editar o xyz pq algumas classes tem sprites maiores.

Link para o comentário
Compartilhar em outros sites

  • 0
  • Diretor

@diarmaint boom, tente assim. Crie um arquivo em creaturescripts chamado deatheffect.lua e cole isso:

local repetir = 2 --  Tempo para repetir o efeito
local tempo = 1 * 60 -- Tempo em minutos que ficará com o efeito
local str = 037668 -- storage, não mexa!
local config = {
    [1] = 10, -- [Vocation] = 10(effect)
    [2] = 20,
    [3] = 30
  }

function onDeath(cid, corpse, deathList)
	setPlayerStorageValue(cid, str, os.time() + tempo)
	return true
end
function onLogin(cid)
	registerCreatureEvent(cid, "deathEffect")
	if getPlayerStorageValue(cid, str) > os.time() then
		effects(cid, getPlayerStorageValue(cid, str) - os.time())
	end
	return true
end

function effects(cid, tempo)
	if (config[getPlayerVocation(cid)]) and isPlayer(cid) then
		if tempo > 0 then
			doSendMagicEffect(getPlayerPosition(cid), config[getPlayerVocation(cid)]) -- or getThingPos(cid)
			addEvent(effects, repetir * 1000, cid, tempo-repetir)
		else
			setPlayerStorageValue(cid, str, 0)
			return true
		end
	end
end
-- Créditos: Yan Liima(Xtibia)

XML:

<event type="login" name="loginEffect" event="script" value="deatheffect.lua"/>
<event type="death" name="deathEffect" event="script" value="deatheffect.lua"/>

Tome cuidado com caractere invalido ao copiar. xD

Link para o comentário
Compartilhar em outros sites

  • 0
15 horas atrás, Yan Liima disse:

local config = { [1] = 10, -- [Vocation] = 10(effect) [2] = 20, [3] = 30 }

Funcionou perfeitamente mas tem como editar o xyz? pois algumas vocações tem sprites maiores.

Aonde mudo pra deixar o mesmo effect para todas as classes? preciso do mesmo para outro servidor.

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

  • 0
36 minutos atrás, Yan Liima disse:

local pos = getPlayerPosition(cid) local position = {x = pos.x, y = pos.y - 1, z = pos.z}

Me auxilia aonde inserir essas linhas no script, tentei nas primeiras junto com os outros "local" e deu erro.

Citar

[16:24:37.470] [Error - LuaInterface::loadFile] data/creaturescripts/scripts/diarmaint/efeitomorte.lua:4: unexpected symbol near '´'
[16:24:37.471] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/diarmaint/efeitomorte.lua)
[16:24:37.471] data/creaturescripts/scripts/diarmaint/efeitomorte.lua:4: unexpected symbol near '´'
[16:24:37.472] [Error - LuaInterface::loadFile] data/creaturescripts/scripts/diarmaint/efeitomorte.lua:4: unexpected symbol near '´'
[16:24:37.472] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/diarmaint/efeitomorte.lua)
[16:24:37.473] data/creaturescripts/scripts/diarmaint/efeitomorte.lua:4: unexpected symbol near '´'

 

Spoiler

local repetir = 1 --  Tempo para repetir o efeito
local tempo = 1 * 60 -- Tempo em minutos que ficará com o efeito
local str = 037668 -- storage, não mexa!
local pos = getPlayerPosition(cid)
local position = {x = pos.x, y = pos.y - 1, z = pos.z}
local config = {
    [1] = 530, -- [Vocation] = 10(effect)
    [2] = 530,
    [3] = 530,
    [4] = 530,
    [5] = 530,
    [6] = 530,
    [7] = 530,
    [8] = 530,
    [9] = 530,
    [10] = 530,
    [11] = 530,
    [12] = 530,
    [13] = 530,
    [14] = 530,
    [15] = 530,
    [16] = 530,
    [473] = 530,
    [909] = 530
    
  }

function onDeath(cid, corpse, deathList)
    setPlayerStorageValue(cid, str, os.time() + tempo)
    return true
end
function onLogin(cid)
    registerCreatureEvent(cid, "deathEffect")
    if getPlayerStorageValue(cid, str) > os.time() then
        effects(cid, getPlayerStorageValue(cid, str) - os.time())
    end
    return true
end

function effects(cid, tempo)
    if (config[getPlayerVocation(cid)]) and isPlayer(cid) then
        if tempo > 0 then
            doSendMagicEffect(position, config[getPlayerVocation(cid)]) -- or getThingPos(cid)
            
            addEvent(effects, repetir * 1000, cid, tempo-repetir)
        else
            setPlayerStorageValue(cid, str, 0)
            return true
        end
    end
end

 

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

  • 0
  • Diretor
4 minutos atrás, diarmaint disse:

Me auxilia aonde inserir essas linhas no script, tentei nas primeiras junto com os outros "local" e deu erro.

 

  Mostrar conteúdo oculto

 

Tenta assim:

Spoiler

local repetir = 1 --  Tempo para repetir o efeito
local tempo = 1 * 60 -- Tempo em minutos que ficará com o efeito
local str = 037668 -- storage, não mexa!
local config = {
    [1] = 530, -- [Vocation] = 10(effect)
    [2] = 530,
    [3] = 530,
    [4] = 530,
    [5] = 530,
    [6] = 530,
    [7] = 530,
    [8] = 530,
    [9] = 530,
    [10] = 530,
    [11] = 530,
    [12] = 530,
    [13] = 530,
    [14] = 530,
    [15] = 530,
    [16] = 530,
    [473] = 530,
    [909] = 530
    
  }

function onDeath(cid, corpse, deathList)
    setPlayerStorageValue(cid, str, os.time() + tempo)
    return true
end
function onLogin(cid)
    registerCreatureEvent(cid, "deathEffect")
    if getPlayerStorageValue(cid, str) > os.time() then
        effects(cid, getPlayerStorageValue(cid, str) - os.time())
    end
    return true
end

function effects(cid, tempo)
  local pos = getPlayerPosition(cid)
  local position = {x = pos.x, y = pos.y - 1, z = pos.z}
    if (config[getPlayerVocation(cid)]) and isPlayer(cid) then
        if tempo > 0 then
            doSendMagicEffect(position, config[getPlayerVocation(cid)]) -- or getThingPos(cid)
            
            addEvent(effects, repetir * 1000, cid, tempo-repetir)
        else
            setPlayerStorageValue(cid, str, 0)
            return true
        end
    end
end

 

 

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...