• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Frags/kills onlook tfs 1.3 8.6

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, im looking for script, who show kills/deaths on look character
 
Solution
Create a file in data/creaturescripts/scripts named killdeathcount.lua:
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 =...
Create a file in data/creaturescripts/scripts named killdeathcount.lua:
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
In creaturescripts.xml:
XML:
    <event type="death" name="KillDeathCount" script="killdeathcount.lua"/>
Register the event in login.lua
Code:
player:registerEvent('KillDeathCount')
In events/scripts/player.lua in:
Lua:
Player:onLook
Before:
Lua:
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
Insert:
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.
 
Solution
Create a file in data/creaturescripts/scripts named killdeathcount.lua:
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
In creaturescripts.xml:
XML:
    <event type="death" name="KillDeathCount" script="killdeathcount.lua"/>
Register the event in login.lua
Code:
player:registerEvent('KillDeathCount')
In events/scripts/player.lua in:
Lua:
Player:onLook
Before:
Lua:
self:sendTextMessage(MESSAGE_INFO_DESCR, description)
Insert:
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.

Not work :( I dont see anything
0 errors
1615225220647.png
 
I tested in TFS 1.5, I didn't get any errors, but I wasn't successful either. ;w
I am using that same system and it works for me, what steps did you do?

In any case, place it as revscripts

Lua:
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()

And in onLook

Code:
-- 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
 
Back
Top