-- player, date, value
-- 13 + 13 + 13 = 39 global storages.
-- 00 > 13 > 26
local storage = 45000 -- 45000 to 45039 used.
-- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13
local damage_types = {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 2014, 2048}
local damage_type_names = {"none", "physical", "energy", "earth", "fire", "undefined", "life drain", "mana drain", "healing", "drown", "ice", "holy", "death"}
function onStatsChange(cid, attacker, type, combat, value)
print(1)
if type ~= COMBAT_HEALING then
print(2)
-- make sure we are only counting player hits
if not isPlayer(attacker) then
return true
end
print(3)
-- find damage type
local temp_storage = storage - 1 -- so we start from the storage specified.
for i = 1, #damage_types do
if combat == damage_types[i] then
temp_storage = temp_storage + i
break
end
end
print(4)
-- verify if value is higher then maximum recorded for that damage type
if value <= getPlayerStorageValue(cid, temp_storage + 26) then
return true
end
print(5)
-- value is higher, set storages.
setPlayerStorageValue(cid, temp_storage, getPlayerGUID(attacker)) -- player
setPlayerStorageValue(cid, temp_storage + 13, os.time()) -- date
setPlayerStorageValue(cid, temp_storage + 26, value) -- damage_value
print(6)
-- test prints, when new record is set. (disable these after testing. xD)
print("New Record Set!")
temp_storage = storage - 1
for i = 1, 13 do
local text = ""
if getPlayerStorageValue(cid, temp_storage + i) <= 0 then
text = text .. "Nobody"
else
text = text .. getPlayerNameByGUID(getPlayerStorageValue(cid, temp_storage + i))
end
text = text .. " holds the record for " .. damage_type_names[i] .. " damage with " .. getPlayerStorageValue(cid, temp_storage + i + 26) .. " damage!\n"
text = text .. "Record created on " .. os.date("%x", getPlayerStorageValue(cid, temp_storage + i + 13))
print(text)
end
end
return true
end