Eldora
Banned User
- Joined
- Oct 19, 2009
- Messages
- 604
- Reaction score
- 26
I need this code to stop giving kill count for players if they have not been in combat the latest 5 minutes.
Right now, players get kill counts as long as they stay in the party.
They can even stand in the depot, getting kill counts from their friends monster kills, as long as they stay in the party.
Using TFS 1.2
Right now, players get kill counts as long as they stay in the party.
They can even stand in the depot, getting kill counts from their friends monster kills, as long as they stay in the party.
Using TFS 1.2
Lua:
local function getObjs(creature)
local objs = {}
local timeNow = os.mtime()
local inFightTicks = configManager.getNumber(configKeys.PZ_LOCKED)
for uid, cb in pairs(creature:getDamageMap()) do
local attacker = Player(uid)
if attacker and timeNow - cb.ticks <= inFightTicks then
local party = attacker:getParty()
if party then
local lid = party:getLeader():getId()
if not objs[lid] then
objs[lid] = party
end
else
objs[attacker:getId()] = attacker
end
end
end
return objs
end
local function applyStorages(player, info)
local storageValue = player:getStorageValue(info.storage)
local howMany = storageValue + 1
if player:getStorageValue(info.missionstorage) == 1 then
if storageValue >= info.count then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already killed " .. info.count .. " " .. info.plural .. ". Report back to Tusker.")
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed [" .. howMany .. "/" .. info.count .. "] " .. info.plural .. ".")
end
player:setStorageValue(info.storage, storageValue + 1)
end
end
function onKill(player, creature)
local info = config[creature:getName():lower()]
if not info or creature:getMaster() then
return true
end
for _, obj in pairs(getObjs(creature)) do
if getmetatable(obj) == Party then
for _, member in pairs({obj:getLeader(), unpack(obj:getMembers())}) do
applyStorages(member, info)
end
else
applyStorages(obj, info)
end
end
return true
end
Last edited: