Il Knight
Veteran OT User
Hi otland, today im stucked with this script..
what i need?
if you kill this monsters (on the script) you get xxx exp and xxx gold.
and if you kill this monsters on (party) the exp and gold is divided.
all is working good.. But have one problem.
problem = rat (HP 20)
player 1 = deal 5 hp // < win money and exp. (this is not good) <
player 2 = deal 15 hp // < win money and exp. (its ok)
i dont know why this happen because im using this =
if not player == mostDamageKiller then
return true
end
so if you are not the most damage killer, why the script is giving exp to all the player who attack the monster?
help please..
maybe is better function on death?
what i need?
if you kill this monsters (on the script) you get xxx exp and xxx gold.
and if you kill this monsters on (party) the exp and gold is divided.
all is working good.. But have one problem.
problem = rat (HP 20)
player 1 = deal 5 hp // < win money and exp. (this is not good) <
player 2 = deal 15 hp // < win money and exp. (its ok)
i dont know why this happen because im using this =
if not player == mostDamageKiller then
return true
end
so if you are not the most damage killer, why the script is giving exp to all the player who attack the monster?
help please..
maybe is better function on death?
Code:
local monsters = {
{name = "rat", min_gold = 1, max_gold = 10, exp = 1000 },
{name = "cave rat", min_gold = 100, max_gold = 200, exp = 10000 },
{name = "rotworm", min_gold = 2000, max_gold = 3000, exp = 100000 }
}
function onKill(creature, target, mostDamageKiller)
local player = creature:getPlayer()
if not player then
return true
end
if not player == mostDamageKiller then
return true
end
if target:getMaster() then
return true
end
local party = player:getParty()
if not party then
for i = 1, #monsters do
if monsters[i].name == target:getName():lower() then
local value = math.random(monsters[i].min_gold, monsters[i].max_gold)
local exp = monsters[i].exp
local lev = player:getLevel()
player:addExperience(round(exp/lev))
player:setBankBalance(round(player:getBankBalance() + value))
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You have gained ".. round(value) .." coins in this battle.")
end
end
return true
end
if party and party:isSharedExperienceActive() then
local rate = (party:getMemberCount() + 1)
local members = party:getMembers()
for i = 1, #monsters do
if monsters[i].name == target:getName():lower() then
local value = math.random(monsters[i].min_gold, monsters[i].max_gold)
local gold = value/rate
local exp = monsters[i].exp
local div = exp/rate
local leader = party:getLeader()
local lev = leader:getLevel()
leader:addExperience(round(div/lev))
leader:setBankBalance(round(leader:getBankBalance() + gold))
leader:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You have gained ".. round(gold) .." coins in this battle.")
for i = 1, #members do
members[i]:addExperience(round(div/members[i]:getLevel()))
members[i]:setBankBalance(round(members[i]:getBankBalance() + gold))
members[i]:sendTextMessage(MESSAGE_STATUS_DEFAULT, "You have gained ".. round(gold) .." coins in this battle.")
end
end
end
end
return true
end