Testa desse jeito aqui:
local rewards = {
{id = 2160, count = 1},
{id = 2152, count = 20},
}
function isInGuild(cid)
return getPlayerGuildId(cid) > 0 and true or false
end
function getGuildMembers(cid)
local members = {}
for _, pid in ipairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == getPlayerGuildId(cid) then
table.insert(members, pid)
end
end
return members
end
function onDeath(cid, corpse, killers)
local guildDamageRatio, mostDamage, winners = {}, {0, 0, false}, {}
for _, player in pairs (killers) do
local percentDealt = getPlayerStorageValue(cid, getPlayerGUID(player))
if isInGuild(player) then
guildDamageRatio[getPlayerGuildId(player)] = (guildDamageRatio[getPlayerGuildId(player)] or 0) + percentDealt
elseif mostDamage[1] < percentDealt then
mostDamage = {percentDealt, player, false}
end
end
for guildId, damageRatio in pairs (guildDamageRatio) do
if damageRatio > mostDamage[1] then
mostDamage = {damageRatio, guildId, true}
end
end
if mostDamage[3] then
winners = getGuildMembers(mostDamage[2])
else
winners = {mostDamage[2]}
end
for _, winId in pairs (winners) do
for _, itemInfo in pairs (rewards) do
doPlayerAddItem(winId, itemInfo.id, itemInfo.count or 1)
end
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if not isCreature(attacker) or not isPlayer(attacker) or type ~= STATSCHANGE_HEALTHLOSS then return true end
local percentToAdd = math.abs(value) / getCreatureMaxHealth(cid) * 100
local currentPercent = math.max(getPlayerStorageValue(cid, getPlayerGUID(attacker)), 0)
setPlayerStorageValue(cid, getPlayerGUID(attacker), currentPercent + percentToAdd)
return true
end




info
Grupo: Campones
Registrado: 25/09/12
Posts: 33
Reputação: +8
Eu tenho esse script aqui:
local rewards = {
{id = 2160, count = 1},
{id = 2152, count = 20},
}
function onDeath(cid, corpse, killers)
local partiesDamageRatio, mostDamage, winners = {}, {0, 0, false}, {}
for _, player in pairs (killers) do
local percentDealt = getPlayerStorageValue(cid, getPlayerGUID(player))
if isInParty(player) then
partiesDamageRatio[getPlayerParty(player)] = (partiesDamageRatio[getPlayerParty(player)] or 0) + percentDealt
elseif mostDamage[1] < percentDealt then
mostDamage = {percentDealt, player, false}
end
end
for guildId, damageRatio in pairs (partiesDamageRatio) do
if damageRatio > mostDamage[1] then
mostDamage = {damageRatio, guildId, true}
end
end
if mostDamage[3] then
winners = getPartyMembers(mostDamage[2])
else
winners = {mostDamage[2]}
end
for _, winId in pairs (winners) do
for _, itemInfo in pairs (rewards) do
doPlayerAddItem(winId, itemInfo.id, itemInfo.count or 1)
end
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if not isCreature(attacker) or not isPlayer(attacker) or type ~= STATSCHANGE_HEALTHLOSS then return true end
local percentToAdd = math.abs(value) / getCreatureMaxHealth(cid) * 100
local currentPercent = math.max(getPlayerStorageValue(cid, getPlayerGUID(attacker)), 0)
setPlayerStorageValue(cid, getPlayerGUID(attacker), currentPercent + percentToAdd)
return true
end
Ele faz com que o monstro em questão quando ele morre, a party que tirar mais dano dele ganha itens e se o player não estiver na party que tirar mais dano ele não ganha o prêmio.
Eu gostaria que editasse esse script so para um detalhe, que no lugar de party fosse a guild que tirar mais dano e tal.
Alguém para me ajudar por favor??? Valendo 3 REP!
Esperando respostas!
Editado Setembro 10 por dearthpoenix