granitowyx
New Member
Hello. I need some help. I use tfs 1.5 downgrade 8.6 by Nekiro. I have creaturescript that count killed monsters. It works fine but this is only counted for players who deal most dmg and last hit. I want to count monsters for every player who deal dmg. Script:
Lua:
local monstersToCount = {
-- amazons
["amazon"] = {storage = 1000, groupStorage = 5000},
["valkyrie"] = {storage = 1001, groupStorage = 5000}
function onKill(creature, target)
if not Player(creature) then --check if killer is a Player
return true
end
if not Monster(target) then --check if killed is a Monster
return true
end
local monsterIndex = monstersToCount[string.lower(target:getName())] --get monster info from table using string.lower() to change target name to low-case
if monsterIndex then --if exist monster info
--update individual count
local monsterKilledCount = creature:getStorageValue(monsterIndex.storage)
if monsterKilledCount < 0 then--check if individual count is lower than 0 (default storage value = -1) and set to 0
creature:setStorageValue(monsterIndex.storage, 0)
monsterKilledCount = 0
end
creature:setStorageValue(monsterIndex.storage, monsterKilledCount + 1)
--update group count
local monsterGroupKilledCount = creature:getStorageValue(monsterIndex.groupStorage)
if monsterGroupKilledCount < 0 then--check if group count is lower than 0 (default storage value = -1) and set to 0
creature:setStorageValue(monsterIndex.groupStorage, 0)
monsterGroupKilledCount = 0
end
creature:setStorageValue(monsterIndex.groupStorage, monsterGroupKilledCount + 1)
if monsterKilledCount % 10 == 0
then
creature:sendTextMessage(MESSAGE_EVENT_ORANGE, "You killed "..(monsterKilledCount + 1).." "..target:getName().." and "..(monsterGroupKilledCount + 1).." monsters of this group.")
end
end
return true
end