creatserver
New Member
- Joined
- Feb 7, 2015
- Messages
- 25
- Reaction score
- 0
For when a guild kills the boss only wins the members who are online. Offline will not win.
Lua:
function onDeath(cid, corpse, lastHitKiller, mostDamageKiller)
local killer = lastHitKiller[1]
if isPlayer(killer) and (getCreatureName(cid) == "Gran Tower") then
if (getGlobalStorageValue(GRANTOWER.FINALWINNER) ~= getCreatureName(killer)) then
if getPlayerGuildId(killer) >= 1 then
for index, creature in ipairs(getGranTowerPlayers()) do
if getPlayerGuildId(creature) ~= getPlayerGuildId(killer) then
doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), true)
end
end
else
for index, creature in ipairs(getGranTowerPlayers()) do
if getPlayerStorageValue(creature, GRANTOWER.AURA) ~= -1 then
doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), true)
end
end
end
if (getPlayerGuildId(killer) >= 1) then
setGlobalStorageValue(GRANTOWER.SAVEWINNERGUILDID, getPlayerGuildId(killer))
for index, creature in ipairs(getGranTowerGuild(getPlayerGuildId(killer))) do
setPlayerStorageValue(creature, GRANTOWER.AURA, 1)
end
else
setGlobalStorageValue(GRANTOWER.SAVEWINNERGUILDID, -1)
end
setPlayerStorageValue(killer, GRANTOWER.AURA, 1)
addEvent(changeOutfit, 0, killer)
setGlobalStorageValue(GRANTOWER.SAVELASTWINNER, getCreatureName(killer))
addEvent(doCreateMonster, 2 * 1000, "Gran Tower", GRANTOWER.TOWERPOSITION)
setGlobalStorageValue(GRANTOWER.FINALWINNER, getCreatureName(killer))
setGlobalStorageValue(GRANTOWER.DESTROYCOUNT, (getGlobalStorageValue(GRANTOWER.DESTROYCOUNT) + 1))
if getPlayerGuildId(killer) >= 1 and getPlayerGuildName(killer) then
doBroadcastMessage(""..getCreatureName(killer).." acaba de conquistar o Gran Castle em nome da guild ".. getPlayerGuildName(killer) ..". Todos membros da guild que estão online acabam de receber a Gran Aura!")
else
doBroadcastMessage(""..getCreatureName(killer).." acaba de conquistar o Gran Castle e absorver a Gran Aura!")
end
end
end
return true
end
function onTarget(cid, target)
if isPlayer(cid) and isMonster(target) and (getCreatureName(target) == "Gran Tower") then
if getGlobalStorageValue(GRANTOWER.FINALWINNER) == getCreatureName(cid) or getGlobalStorageValue(GRANTOWER.SAVEWINNERGUILDID) == getPlayerGuildId(cid) then
doPlayerSendCancel(cid, "Você não pode atacar o Gran Tower, proteja ele!")
return false
end
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if (type == STATSCHANGE_HEALTHLOSS) and isMonster(cid) and isPlayer(attacker) and (getCreatureName(cid) == "Gran Tower") then
if (getGlobalStorageValue(GRANTOWER.FINALWINNER) == getCreatureName(attacker)) then
return false
end
end
return true
end
Last edited by a moderator: