function onStatsChange(cid, attacker, type, combat, value)
string = string.explode(toString(getGlobalStorageValue(cid)), ",")
if(type == STATSCHANGE_HEALTHLOSS and isMonster(cid) and value > toNumber(string[2])) then
setGlobalStorageValue(cid, attacker .. "," .. value)
print("Combat Value: " .. string[2] .. " and Attacker: " .. getCreatureName(toNumber(string[1])) .. " have been stored in " .. cid .. " storage.")
end
return true
end
function onKill(cid, target)
string = string.explode(toString(getGlobalStorageValue(target)), ",")
if(cid == toNumber(string[1])) then
doPlayerSendCancel(cid, "Congratulations, you've hit the monster with the biggest power.")
doPlayerAddExp(cid, toNumber(string[2]))
end
return true
end
I corrected some errors, check the next page.
Code:function onStatsChange(cid, attacker, type, combat, value) local storage = 1234 local monsterName = "Demon" if(type == STATSCHANGE_HEALTHLOSS and isMonster(cid) getCreatureName(cid) == monsterName and isPlayer(attacker)) then doCreatureSetStorage(attacker, storage, getCreatureStorage(cid, attacker)+value) end return true end
This will store the damage in the storage '1234', after u just need a PHP or talkaction to rank it.
If u do not know how to create, just take a look at reset system.
Your code will store the whole damage done on the creature with no owner of the damage.
function onStatsChange(cid, attacker, type, combat, value)
local storage = 1234
local monsterName = "Demon"
if type == STATSCHANGE_HEALTHLOSS and isMonster(cid) and getCreatureName(cid) == monsterName and isPlayer(attacker) then
doCreatureSetStorage(attacker, storage, getCreatureStorage(cid, storage)+value)
end
return true
end