Ir para conteúdo

Posts Recomendados

Olá pessoal.

Assim, fiz um novo chat-channel no meu ot. está funcionando normal.

 

<channel id="10" name="Death-Chat" muted="10" logged="yes"/>

 

O que eu quero é o seguinte.

 

Eu uso esse script, que mostra no chat quando algum player morre.

 

function onDeath(cid, corpse, deathList)

if isPlayer(deathList[1]) then

return true,doBroadcastMessage("[DeathCast] Informs:\n".. getCreatureName(cid) .. "[" .. getPlayerLevel(cid) .. "] was Killed by player: " .. getCreatureName(deathList[1]) .. "[" .. getPlayerLevel(deathList[1]) .. "]",22)

end

return doBroadcastMessage("[DeathCast] Informs:\nThe player ".. getCreatureName(cid) .. "[" .. getPlayerLevel(cid) .. "] was Killed by " .. getCreatureName(deathList[1]) .. ".",22)

end

 

Aparece no channel Server Log, eu gostaria que aparecesse no novo channel que eu criei, como fazer isso?!?

Da uma ajudinha ae por favor!!

 

Valew!!

Link para o comentário
https://xtibia.com/forum/topic/166457-novo-chat/
Compartilhar em outros sites

Eu achei um aqui parecido , não testei mais vê ai.

 

Va em data/creatureEvent/Scripts e crie um arquivo lua chamado playerdeath e dentro cole isso.

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)

if(config.deathListEnabled ~= TRUE) then

return

end

 

local hitKillerName = "field item"

local damageKillerName = ""

if(lastHitKiller ~= FALSE) then

if(isPlayer(lastHitKiller) == TRUE) then

hitKillerName = getCreatureName(lastHitKiller)

else

hitKillerName = getCreatureName(lastHitKiller)

end

 

doBroadcastMessage(""..getPlayerName(cid).." Foi Morto Pelo(a) "..hitKillerName..".")

 

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.executeQuery(" 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.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")

end

else

db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")

end

end

end

end

A parte em Negrito vc pode editar ou seja vc pode escrever Morreu para entre outros o que vc quiser escrever.

 

 

Depois em CreatureEvent.xml cole essa tag.

 

<event type="death" name="PlayerDeath" script="playerdeath.lua"/>

 

 

Agora um exemplo vamos supor que Kasperian foi morto por Kasper então no server todo ira aparecer a mensagem.

 

Kasperian Foi Morto Pelo(a) Kasper.

 

Isso tbm funciona em monsters.

 

Kasperian Foi Morto Pelo(a)Dragon Lord.

Se ajudei REP +

Editado por pikemo
Link para o comentário
https://xtibia.com/forum/topic/166457-novo-chat/#findComment-1094102
Compartilhar em outros sites

me manda o script desse chat q tu crio

 

 

<?xml version="1.0" encoding="UTF-8"?>

<channels>

<!-- README:

0 - dynamic, reserved for guilds

1 - always acts as Party channel, only "name" tag available

3 - always acts as Rule Violations channel

9 - acts as Help channel- clientsided message

65535 - DO NOT CHANGE THE ID- only "name", "enabled", "active" and "logged" tags available

-->

<channel id="1" name="Party"/>

<channel id="2" name="Staff" access="3"/>

<channel id="3" name="Rule Violations" logged="yes"/>

<channel id="4" name="Counselor" access="1"/>

<channel id="5" name="CHAT-Bate-Papo" level="2"/>

<channel id="6" name="Trade" level="8" muted="120" conditionId="2" conditionMessage="You may only place one offer in two minutes.">

<vocation id="1-8"/>

</channel>

<channel id="9" name="HELP-AJUDA" muted="10" logged="yes"/>

<channel id="10" name="Death-Chat" muted="10" logged="yes"/>

<channel id="65535" name="Private Chat Channel"/>

</channels>

Link para o comentário
https://xtibia.com/forum/topic/166457-novo-chat/#findComment-1094129
Compartilhar em outros sites

No teu tenta bota assim

function onDeath(cid, corpse, deathList)

if isPlayer(deathList[10]) then

return true,doBroadcastMessage("[DeathCast] Informs:\n".. getCreatureName(cid) .. "[" .. getPlayerLevel(cid) .. "] was Killed by player: " .. getCreatureName(deathList[10]) .. "[" .. getPlayerLevel(deathList[1]) .. "]",22)

end

return doBroadcastMessage("[DeathCast] Informs:\nThe player ".. getCreatureName(cid) .. "[" .. getPlayerLevel(cid) .. "] was Killed by " .. getCreatureName(deathList[10]) .. ".",22)

end

 

E no q eu te mandei tenta faze assim

 

local config = 10{

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)

if(config.deathListEnabled ~= TRUE) then

return

end

 

local hitKillerName = "field item"

local damageKillerName = ""

if(lastHitKiller ~= FALSE) then

if(isPlayer(lastHitKiller) == TRUE) then

hitKillerName = getCreatureName(lastHitKiller)

else

hitKillerName = getCreatureName(lastHitKiller)

end

 

doBroadcastMessage(""..getPlayerName(cid- 10).." Foi Morto Pelo(a) "..hitKillerName..".")

 

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.executeQuery(" 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.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")

end

else

db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")

end

end

end

end

 

Nao entendo mto de chat so estou tentando ajudar voçe :D mas tenta que talvez funcione

Se funciona me da um rep +

Editado por pikemo
Link para o comentário
https://xtibia.com/forum/topic/166457-novo-chat/#findComment-1094151
Compartilhar em outros sites

@pikemo - não funcionou não man =/ tipo tentei usar o script diferente que você me passou, mas agora não aparece nada e não sei porque o corpo de quem morre agora, some na hora em que morrer...

 

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)

if(config.deathListEnabled ~= TRUE) then

return

end

 

local hitKillerName = "field item"

local damageKillerName = ""

if(lastHitKiller ~= FALSE) then

if(isPlayer(lastHitKiller) == TRUE) then

hitKillerName = getCreatureName(lastHitKiller)

else

hitKillerName = getCreatureName(lastHitKiller)

end

 

doBroadcastMessage(""..getPlayerName(cid).." Foi Morto Pelo(a)

 

"..hitKillerName..".")

 

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.executeQuery(" 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.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT

 

`rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID

 

(cid) .. " ORDER BY `time` LIMIT 1);")

end

else

db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " ..

 

getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")

end

end

end

end

 

 

@Beeki - porque eu acho esta função intereçante, tipo fica legal, ali na hora em que alguém matar alguém aparecer para o server todo, fica bacana...

Link para o comentário
https://xtibia.com/forum/topic/166457-novo-chat/#findComment-1094357
Compartilhar em outros sites

×
×
  • Criar Novo...