local killStorage = 3000
local deathStorage = 3001
local toMostDamage = true
local toKiller = true
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
if not creature:isPlayer() then return true end
if creature then
if killer and killer:isPlayer() and toKiller then
local killAmount = killer:getStorageValue(killStorage)
if killAmount == -1 then killAmount = 0 end
killer:setStorageValue(killStorage, killAmount + 1)
end
if mostDamageKiller and mostDamageKiller:isPlayer() and toMostDamageKiller then
local killAmount =...
local killStorage = 3000
local deathStorage = 3001
local toMostDamage = true
local toKiller = true
function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
if not creature:isPlayer() then return true end
if creature then
if killer and killer:isPlayer() and toKiller then
local killAmount = killer:getStorageValue(killStorage)
if killAmount == -1 then killAmount = 0 end
killer:setStorageValue(killStorage, killAmount + 1)
end
if mostDamageKiller and mostDamageKiller:isPlayer() and toMostDamageKiller then
local killAmount = mostDamageKiller:getStorageValue(killStorage)
if killAmount == -1 then killAmount = 0 end
mostDamageKiller:setStorageValue(killStorage, killAmount + 1)
end
local deathAmount = creature:getStorageValue(deathStorage)
if deathAmount == -1 then deathAmount = 0 end
creature:setStorageValue(deathStorage, deathAmount + 1)
end
return true
end
<event type="death" name="KillDeathCount" script="killdeathcount.lua"/>
player:registerEvent('KillDeathCount')
Player:onLook
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
if thing:isCreature() and thing:isPlayer() then
local killStorage = 3000
local deathStorage = 3001
local killAmount, deathAmount = thing:getStorageValue(killStorage), thing:getStorageValue(deathStorage)
if killAmount == -1 then killAmount = 0 end
if deathAmount == -1 then deathAmount = 0 end
description = description .. '\nHe has killed: [' ..killAmount..'] Player' .. '\nHe has died: ['..deathAmount..'] Times.'
end
Create a file in data/creaturescripts/scripts named killdeathcount.lua:
In creaturescripts.xml:Lua:local killStorage = 3000 local deathStorage = 3001 local toMostDamage = true local toKiller = true function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified) if not creature:isPlayer() then return true end if creature then if killer and killer:isPlayer() and toKiller then local killAmount = killer:getStorageValue(killStorage) if killAmount == -1 then killAmount = 0 end killer:setStorageValue(killStorage, killAmount + 1) end if mostDamageKiller and mostDamageKiller:isPlayer() and toMostDamageKiller then local killAmount = mostDamageKiller:getStorageValue(killStorage) if killAmount == -1 then killAmount = 0 end mostDamageKiller:setStorageValue(killStorage, killAmount + 1) end local deathAmount = creature:getStorageValue(deathStorage) if deathAmount == -1 then deathAmount = 0 end creature:setStorageValue(deathStorage, deathAmount + 1) end return true end
Register the event in login.luaXML:<event type="death" name="KillDeathCount" script="killdeathcount.lua"/>
In events/scripts/player.lua in:Code:player:registerEvent('KillDeathCount')
Before:Lua:Player:onLook
Insert:Lua:self:sendTextMessage(MESSAGE_INFO_DESCR, description)
Lua:if thing:isCreature() and thing:isPlayer() then local killStorage = 3000 local deathStorage = 3001 local killAmount, deathAmount = thing:getStorageValue(killStorage), thing:getStorageValue(deathStorage) if killAmount == -1 then killAmount = 0 end if deathAmount == -1 then deathAmount = 0 end description = description .. '\nHe has killed: [' ..killAmount..'] Player' .. '\nHe has died: ['..deathAmount..'] Times.' end
I havent tested it, but it should work.
Do you changed the Player: onLook function?
I am using that same system and it works for me, what steps did you do?I tested in TFS 1.5, I didn't get any errors, but I wasn't successful either. ;w
local killStorage = 884734
local deathStorage = 884735
local toMostDamage = true
local toKiller = true
local event = CreatureEvent("KillandCount")
function event.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
if not creature:isPlayer() then return true end
if creature then
if killer and killer:isPlayer() and toKiller then
local killAmount = killer:getStorageValue(killStorage)
if killAmount == -1 then killAmount = 0 end
killer:setStorageValue(killStorage, killAmount + 1)
end
if mostDamageKiller and mostDamageKiller:isPlayer() and toMostDamageKiller then
local killAmount = mostDamageKiller:getStorageValue(killStorage)
if killAmount == -1 then killAmount = 0 end
mostDamageKiller:setStorageValue(killStorage, killAmount + 1)
end
local deathAmount = creature:getStorageValue(deathStorage)
if deathAmount == -1 then deathAmount = 0 end
creature:setStorageValue(deathStorage, deathAmount + 1)
end
return true
end
event:register()
local eventLogin = CreatureEvent("KillandCountLogin")
function eventLogin.onLogin(player)
player:registerEvent("KillandCount")
return true
end
eventLogin:register()
-- Look KILL AND DEATH --
if thing:isPlayer() and not thing:getGroup():getAccess() then
local killStorage = 884734
local deathStorage = 884735
local killAmount, deathAmount = thing:getStorageValue(killStorage), thing:getStorageValue(deathStorage)
if killAmount == -1 then killAmount = 0 end
if deathAmount == -1 then deathAmount = 0 end
description = description .. '\nKilleds: [' ..killAmount..'] and ' .. 'Deaths: ['..deathAmount..']'
end