function onPlayerKill(player, creature, lastHit)
if not creature:isPlayer() then
return true
end
for cid, damage in pairs(creature:getDamageMap()) do
local fragid = 20000000 + creature:getId()
local timefrag = 30000000 + creature:getId()
local participant = Player(cid)
if participant and participant:isPlayer() then
local difer = creature:getLevel() - player:getLevel()
local difer2 = player:getLevel() - creature:getLevel()
local ExpLow = math.ceil(creature:getExperience() * 0.05 / (difer2 + 1))
local ExpHigh = math.ceil(creature:getExperience() * 0.01 * ((difer * 0.5) + 1))
if creature:getLevel() <= participant:getLevel() and participant:getStorageValue(fragid) <= 3 then
participant:addItem(2152, 10)
--participant:addExperience(ExpLow, true)
participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpLow .. ' experience points.')
participant:setStorageValue(fragid, participant:getStorageValue(fragid) + 1)
participant:setStorageValue(timefrag, os.time() + 60)
elseif participant:getStorageValue(fragid) >= 3 then
participant:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cannot give experience to you.')
end
if difer >= 1 and participant:getStorageValue(fragid) <= 3 then
participant:addItem(2152, (difer * 5) + 10)
--participant:addExperience(ExpHigh, true)
participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpHigh .. ' experience points.')
participant:setStorageValue(fragid, participant:getStorageValue(fragid))
participant:setStorageValue(timefrag, participant:getStorageValue(timefrag))
elseif participant:getStorageValue(fragid) >= 3 then
player:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cannot give experience to you.')
end
end
end
return true
end
function registerPlayerOnKill()
addEvent(onPlayerKill)
end
registerPlayerOnKill()
testa ai e me fala aqui se deu erro no console