- Joined
- Nov 15, 2007
- Messages
- 854
- Solutions
- 10
- Reaction score
- 389
- Location
- Santiago, Chile (Australian)
Hi guys,
I want to count the number of players in the damagemap of a creature (in this case, a player)
What would be the best way of achieving this?
Kind regards,
Michael
EDIT:
To be more specific please see the below code.
I wish to count the number of players in the damage map so that I can divide the EXP between the killers, rather than apply the full exp formula to each killer.
I want to count the number of players in the damagemap of a creature (in this case, a player)
What would be the best way of achieving this?
Kind regards,
Michael
EDIT:
To be more specific please see the below code.
I wish to count the number of players in the damage map so that I can divide the EXP between the killers, rather than apply the full exp formula to each killer.
Code:
dofile("war_config.lua")
-- CREDIT TO NINJA @ OTLAND FOR THE BASE SCRIPT
-- REF: https://otland.net/threads/tfs-1-0-experience-from-killing-higher-level-players.212691/#post-2039964
function onKill(cid, target, lastHit)
local attackPlayer = Player(target)
local reward = {
item = rewardItem,
count = rewardCount
}
if not attackPlayer then
return true
end
for id, damage in pairs(attackPlayer:getDamageMap()) do
local player = Player(id)
if player then
if player:getIp() ~= target:getIp() then
local experience = attackPlayer:getExperience()
local expFormula = (experience * expMultiplier)
local bonusExpFormula = (experience * bonusExpMultiplier)
--standard reward
player:addExperience(math.floor(expFormula), true)
player:addItem(reward.item, reward.count)
player:setStorageValue(fragStor, player:getStorageValue(fragStor) + 1)
--bonus GOLD
if player:getStorageValue(doubleFragRewardStor) >= 1 then
player:addItem(reward.item, reward.count)
player:setStorageValue(doubleFragRewardStor, player:getStorageValue(doubleFragRewardStor) -1)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Bonus frag reward added! " .. player:getStorageValue(doubleFragRewardStor) .. " bonus frags remaining!")
end
--bonus EXP
if player:getLevel() <= maximumLevel and player:getStorageValue(extraExpStor) >= 1 then
player:addExperience(math.floor(bonusExpFormula), true)
player:setStorageValue(extraExpStor, player:getStorageValue(extraExpStor) - 1)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Bonus frag EXP added! " .. player:getStorageValue(extraExpStor) .. " bonus frags remaining!")
end
end
end
end
end
Last edited: