TFS 1.3TFS version? Post your death channel script or you don't have 1 already?
function onDeath(cid, corpse, deathList)
local strings = {""}
local t, position = 1, 1
local deathType = "killed"
local toSlain, toCrushed, toEliminated = 3, 9, 15
if #deathList >= toSlain and #deathList < toCrushed then
deathType = "slain"
elseif #deathList >= toCrushed and #deathList < toEliminated then
deathType = "crushed"
elseif #deathList >= toEliminated then
deathType = "eliminated"
end
for _, pid in ipairs(deathList) do
if isCreature(pid) == true then
strings[position] = t == 1 and "" or strings[position] .. ", "
strings[position] = strings[position] .. getCreatureName(pid) .. ""
t = t + 1
else
strings[position] = t == 1 and "" or strings[position] .. ", "
strings[position] = strings[position] .."a field item"
t = t + 1
end
end
for i, str in ipairs(strings) do
if(str:sub(str:len()) ~= ",") then
str = str .. "."
end
msg = getCreatureName(cid) .. " was " .. deathType .. " at level " .. getPlayerLevel(cid) .. " by " .. str
end
for _, oid in ipairs(getPlayersOnline()) do
doPlayerSendChannelMessage(oid, "Death channel", msg, TALKTYPE_CHANNEL_O, CHANNEL_DEATH)
end
return true
end
death.lua
here data\chatchannels\scripts
and add this to itfunction canJoin()
return true
end
function onSpeak()
return false
end
data\chatchannels\chatchannels.xml
<channel id="yourchannelid" name="Deaths" script="death.lua" />
data\creaturescripts\scripts
create a script name it deathschannel.lua
and add this to itfunction onDeath(cid, corpse)
local creature = Creature(cid)
local damageMap = creature:getDamageMap()
for creatureId, damage in pairs(damageMap) do
local thing = Creature(creatureId)
end
i = 0
str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]"
for _, pid in pairs(damageMap) do
i = i + 1
if (i == 1) then
if(#damageMap <= 1) then
str = str.." was killed by "
elseif(#damageMap > 1 and #damageMap <= 4) then
str = str.." was slain by "
elseif(#damageMap > 4 and #damageMap <= 7) then
str = str.." was crushed by "
elseif(#damageMap > 7 and #damageMap <= 10) then
str = str.." was eliminated by "
elseif(#damageMap > 10) then
str = str.." was annihilated by "
end
elseif (i == #damageMap) then
str = str.." and "
else
str = str..", "
end
if not(isPlayer(pid) or isMonster(pid)) then
str = str.."a field item"
elseif isSummon(pid) then
str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid))
elseif isPlayer(pid) then
str = str..""..getCreatureName(pid)
elseif isMonster(pid) then
str = str.."a "..getCreatureName(pid):lower()
end
end
str = str.."."
if(#damageMap <= 1) and not (isMonster(pid)) then
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 1 and #damageMap <= 4) and not (isMonster(pid)) then
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 4 and #damageMap <= 7) and not (isMonster(pid)) then
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 7 and #damageMap <= 10) and not (isMonster(pid)) then
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 10) and not (isMonster(pid)) then
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
end
if (isMonster(pid)) then
str = str.."a "..getCreatureName(pid):lower()
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
end
return true
end
data\creaturescripts\creaturescripts.xml
add this<event type="death" name="DeathsChannel" script="deathschannel.lua" />
sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
TALKTYPE_CHANNEL_R1
is the color registerEnum(TALKTYPE_SAY)
registerEnum(TALKTYPE_WHISPER)
registerEnum(TALKTYPE_YELL)
registerEnum(TALKTYPE_PRIVATE_FROM)
registerEnum(TALKTYPE_PRIVATE_TO)
registerEnum(TALKTYPE_CHANNEL_Y)
registerEnum(TALKTYPE_CHANNEL_O)
registerEnum(TALKTYPE_PRIVATE_NP)
registerEnum(TALKTYPE_PRIVATE_PN)
registerEnum(TALKTYPE_BROADCAST)
registerEnum(TALKTYPE_CHANNEL_R1)
registerEnum(TALKTYPE_PRIVATE_RED_FROM)
registerEnum(TALKTYPE_PRIVATE_RED_TO)
registerEnum(TALKTYPE_MONSTER_SAY)
registerEnum(TALKTYPE_MONSTER_YELL)
I will test! Thanks bro!Create a script name itdeath.lua
heredata\chatchannels\scripts
and add this to it
and inLua:function canJoin() return true end function onSpeak() return false end
data\chatchannels\chatchannels.xml
then inXML:<channel id="yourchannelid" name="Deaths" script="death.lua" />
data\creaturescripts\scripts
create a script name itdeathschannel.lua
and add this to it
and inLua:function onDeath(cid, corpse) local creature = Creature(cid) local damageMap = creature:getDamageMap() for creatureId, damage in pairs(damageMap) do local thing = Creature(creatureId) end i = 0 str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]" for _, pid in pairs(damageMap) do i = i + 1 if (i == 1) then if(#damageMap <= 1) then str = str.." was killed by " elseif(#damageMap > 1 and #damageMap <= 4) then str = str.." was slain by " elseif(#damageMap > 4 and #damageMap <= 7) then str = str.." was crushed by " elseif(#damageMap > 7 and #damageMap <= 10) then str = str.." was eliminated by " elseif(#damageMap > 10) then str = str.." was annihilated by " end elseif (i == #damageMap) then str = str.." and " else str = str..", " end if not(isPlayer(pid) or isMonster(pid)) then str = str.."a field item" elseif isSummon(pid) then str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid)) elseif isPlayer(pid) then str = str..""..getCreatureName(pid) elseif isMonster(pid) then str = str.."a "..getCreatureName(pid):lower() end end str = str.."." if(#damageMap <= 1) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 1 and #damageMap <= 4) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 4 and #damageMap <= 7) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 7 and #damageMap <= 10) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 10) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if (isMonster(pid)) then str = str.."a "..getCreatureName(pid):lower() sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end return true end
data\creaturescripts\creaturescripts.xml
add this
You'll have to edit the script and change those linesXML:<event type="death" name="DeathsChannel" script="deathschannel.lua" />
9 is your channel id andLua:sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
TALKTYPE_CHANNEL_R1
is the color
Not testedC++:registerEnum(TALKTYPE_SAY) registerEnum(TALKTYPE_WHISPER) registerEnum(TALKTYPE_YELL) registerEnum(TALKTYPE_PRIVATE_FROM) registerEnum(TALKTYPE_PRIVATE_TO) registerEnum(TALKTYPE_CHANNEL_Y) registerEnum(TALKTYPE_CHANNEL_O) registerEnum(TALKTYPE_PRIVATE_NP) registerEnum(TALKTYPE_PRIVATE_PN) registerEnum(TALKTYPE_BROADCAST) registerEnum(TALKTYPE_CHANNEL_R1) registerEnum(TALKTYPE_PRIVATE_RED_FROM) registerEnum(TALKTYPE_PRIVATE_RED_TO) registerEnum(TALKTYPE_MONSTER_SAY) registerEnum(TALKTYPE_MONSTER_YELL)
Create a script name itdeath.lua
heredata\chatchannels\scripts
and add this to it
and inLua:function canJoin() return true end function onSpeak() return false end
data\chatchannels\chatchannels.xml
then inXML:<channel id="yourchannelid" name="Deaths" script="death.lua" />
data\creaturescripts\scripts
create a script name itdeathschannel.lua
and add this to it
and inLua:function onDeath(cid, corpse) local creature = Creature(cid) local damageMap = creature:getDamageMap() for creatureId, damage in pairs(damageMap) do local thing = Creature(creatureId) end i = 0 str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]" for _, pid in pairs(damageMap) do i = i + 1 if (i == 1) then if(#damageMap <= 1) then str = str.." was killed by " elseif(#damageMap > 1 and #damageMap <= 4) then str = str.." was slain by " elseif(#damageMap > 4 and #damageMap <= 7) then str = str.." was crushed by " elseif(#damageMap > 7 and #damageMap <= 10) then str = str.." was eliminated by " elseif(#damageMap > 10) then str = str.." was annihilated by " end elseif (i == #damageMap) then str = str.." and " else str = str..", " end if not(isPlayer(pid) or isMonster(pid)) then str = str.."a field item" elseif isSummon(pid) then str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid)) elseif isPlayer(pid) then str = str..""..getCreatureName(pid) elseif isMonster(pid) then str = str.."a "..getCreatureName(pid):lower() end end str = str.."." if(#damageMap <= 1) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 1 and #damageMap <= 4) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 4 and #damageMap <= 7) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 7 and #damageMap <= 10) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if(#damageMap > 10) and not (isMonster(pid)) then sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end if (isMonster(pid)) then str = str.."a "..getCreatureName(pid):lower() sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str) end return true end
data\creaturescripts\creaturescripts.xml
add this
You'll have to edit the script and change those linesXML:<event type="death" name="DeathsChannel" script="deathschannel.lua" />
9 is your channel id andLua:sendChannelMessage(9, TALKTYPE_CHANNEL_R1, str)
TALKTYPE_CHANNEL_R1
is the color
Not testedC++:registerEnum(TALKTYPE_SAY) registerEnum(TALKTYPE_WHISPER) registerEnum(TALKTYPE_YELL) registerEnum(TALKTYPE_PRIVATE_FROM) registerEnum(TALKTYPE_PRIVATE_TO) registerEnum(TALKTYPE_CHANNEL_Y) registerEnum(TALKTYPE_CHANNEL_O) registerEnum(TALKTYPE_PRIVATE_NP) registerEnum(TALKTYPE_PRIVATE_PN) registerEnum(TALKTYPE_BROADCAST) registerEnum(TALKTYPE_CHANNEL_R1) registerEnum(TALKTYPE_PRIVATE_RED_FROM) registerEnum(TALKTYPE_PRIVATE_RED_TO) registerEnum(TALKTYPE_MONSTER_SAY) registerEnum(TALKTYPE_MONSTER_YELL)
Channels.xml
? and on the scripts? Any errors on console? Looks like you just copied help-channel or you have duplicate id between Help-channel and Death-channel.Did you change the channel-id? inChannels.xml
? and on the scripts? Any errors on console? Looks like you just copied help-channel or you have duplicate id between Help-channel and Death-channel.
I make that changes before, but nothing happening.change all
toLua:sendChannelMessage(9, ....... )
Lua:sendChannelMessage(10, ..... )
chatchannels.xmlshow us your current channels.xml and the lua script, or we can't help you.
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel id="2" name="Tutor" script="tutor.lua" />
<channel id="3" name="World Chat" public="1" script="worldchat.lua" />
<channel id="4" name="English Chat" public="1" script="englishchat.lua" />
<channel id="5" name="Trade" public="1" script="advertising.lua" />
<channel id="6" name="Trade-Rookgaard" public="1" script="advertising-rook.lua" />
<channel id="7" name="Help" public="1" script="help.lua" />
<channel id="8" name="Gamemaster" script="gamemaster.lua" />
<channel id="10" name="Death Channel" script="death.lua" />
</channels>
creaturescripts.xmlfunction onDeath(cid, corpse)
local creature = Creature(cid)
local damageMap = creature:getDamageMap()
for creatureId, damage in pairs(damageMap) do
local thing = Creature(creatureId)
end
i = 0
str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]"
for _, pid in pairs(damageMap) do
i = i + 1
if (i == 1) then
if(#damageMap <= 1) then
str = str.." was killed by "
elseif(#damageMap > 1 and #damageMap <= 3) then
str = str.." was slain by "
elseif(#damageMap > 3 and #damageMap <= 7) then
str = str.." was crushed by "
elseif(#damageMap > 7 and #damageMap <= 10) then
str = str.." was eliminated by "
elseif(#damageMap > 10) then
str = str.." was annihilated by "
end
elseif (i == #damageMap) then
str = str.." and "
else
str = str..", "
end
if not(isPlayer(pid) or isMonster(pid)) then
str = str.."a field"
elseif isSummon(pid) then
str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid))
elseif isPlayer(pid) then
str = str..""..getCreatureName(pid)
elseif isMonster(pid) then
str = str.."a "..getCreatureName(pid):lower()
end
end
str = str.."."
if(#damageMap <= 1) and not (isMonster(pid)) then
sendChannelMessage(10, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 1 and #damageMap <= 3) and not (isMonster(pid)) then
sendChannelMessage(10, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 3 and #damageMap <= 9) and not (isMonster(pid)) then
sendChannelMessage(10, TALKTYPE_CHANNEL_R1, str)
end
if(#damageMap > 9) and not (isMonster(pid)) then
sendChannelMessage(10, TALKTYPE_CHANNEL_R1, str)
end
if (isMonster(pid)) then
str = str.."a "..getCreatureName(pid):lower()
sendChannelMessage(10, TALKTYPE_CHANNEL_R1 str)
end
return true
end
I am using TFS 1.3<!-- Death Channel -->
<event type="death" name="DeathsChannel" script="deathschannel.lua" />
No.Was this solved?
Try a super simple version of the script for testing.
function onDeath(cid, corpse)
print("Someone has died. -- Server Console.")
for i = 1, 10 do
if i ~= 9 then
sendChannelMessage(i, TALKTYPE_CHANNEL_R1, "Someone has died. " .. i)
end
end
return true
end