Lib:
cityMonsters = {
--["monster_name"] = recomendo número anterior + 1,
["Chanceler Carlin"] = 1,
["Chanceler Kazz"] = 2,
["Chanceler Ab"] = 3,
--etc
}
DEFAULT_STORAGE = 49198
function setGuildExperience(guildId, exp)
for _, pid in pairs(getPlayersOnline()) do
if getPlayerGuildId(pid) == guildId then
doPlayerSetExperienceRate(pid, exp)
end
end
end
function getGuildExpRate(guildId)
for _, pid in pairs(getPlayersOnline()) do
local playerRate = getPlayerRates(pid)[8]
if getPlayerGuildId(pid) == guildId and playerRate > 1 then
return playerRate
end
end
return 1.0
end
function getGuildName(guild_id) --Omega
local query = db.getResult("SELECT name FROM guilds WHERE id = "..guild_id)
local ret = query:getID() == -1 and false or query:getDataString("name")
query:free()
return ret
end
function onTarget(cid, target)
local m, playerGuild = cityMonsters[getCreatureName(target)], getPlayerGuildId(cid)
if isPlayer(cid) and isMonster(target) and m and playerGuild > 0 then
return getGlobalStorageValue(DEFAULT_STORAGE + m) ~= playerGuild
end
return true
end
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(attacker) and isMonster(cid) and type == STATSCHANGE_HEALTHLOSS then
local m, playerGuild = cityMonsters[getCreatureName(cid)], getPlayerGuildId(attacker)
if m and playerGuild > 0 then
return getGlobalStorageValue(DEFAULT_STORAGE + m) ~= playerGuild
end
end
return true
end
function onLogin(cid)
local guildId = getPlayerGuildId(cid)
if guildId > 0 and getGuildExpRate(guildId) > 1 then
doPlayerSetExperienceRate(cid, getGuildExpRate(guildId))
end
registerCreatureEvent(cid, "mTarget")
registerCreatureEvent(cid, "mStatsChange")
return true
end
function onDeath(cid, corpse, deathList)
local killer, m = deathList[1], cityMonsters[getCreatureName(cid)]
if killer and isPlayer(killer) and m then
local atualGuild, playerGuild = getPlayerStorageValue(cid, DEFAULT_STORAGE + m), getPlayerGuildId(killer)
if playerGuild > 0 and atualGuild ~= playerGuild then
if atualGuild > -1 then
setGuildExperience(atualGuild, getGuildExpRate(atualGuild) - 0.05)
end
setGuildExperience(playerGuild, getGuildExpRate(playerGuild) + 0.05)
setGlobalStorageValue(DEFAULT_STORAGE + m, playerGuild)
broadcastMessage("A guild "..getPlayerGuildName(killer).." acaba de dominar "..getCreatureName(cid):explode(" ")[2].."!")
end
end
return true
endlocal guilds = {
--[actionid] = número da cidade configurado em cityMonsters,
[2391] = 1,
[2392] = 2,
[2393] = 3,
}
function onStepIn(cid, item, position, fromPosition)
if not isPlayer(cid) then return true end
local guildId = getGlobalStorageValue(guilds[item.actionid] + DEFAULT_STORAGE)
if getPlayerGuildId(cid) ~= guildId then
doTeleportThing(cid, fromPosition)
end
return true
end<movevent type="StepIn" actionid="2391;2392;2393" event="script" value="nome_do_arquivo.lua"/>
function onSay(cid)
local str = ""
for name, count in pairs(cityMonsters) do
local guildName = getGuildName(getGlobalStorageValue(count + DEFAULT_STORAGE))
if guildName then
if str == "" then
str = "Cidade "..name:explode(" ")[2].." dominada por "..guildName.."."
else
str = str.."\nCidade "..name:explode(" ")[2].." dominada por "..guildName.."."
end
end
end
doPlayerPopupFYI(cid, str == "" and "Nenhuma cidade conquistada." or str)
return true
end










info
Grupo: Artesão
Registrado: 21/05/13
Posts: 110
Reputação: +3
Tava precisando de um suporte nesse script de dominar cidades do @zipter98...
Funciona assim: Você mata o monstro e soma 5% de bonus de exp extra pra todos os membros da sua guild e tem um monstro desse em cada city fazendo assim as guilds lutarem pra dominar as cidades, pq cada cidade 5% né, 8 cidades = 40%
Mas não sei se ta funcionando, alguem poderia me ajudar com algumas coisas?
1- Quando matar o monstro mandar uma MSG pra geral dizendo tipo
A guild XTIBIA acaba de dominar AB!
2- Um piso que só possa passar membros da guild que domina a cidade
3- E por ultimo e menos importante (se não souberem não precisa) um comando
/cidades
Diz tipo cidade AB dominada por Xtibia
Cidade Kazz dominada por Ziptester Guild Boladona
Cidade Carlin dominada por Ninguem
Scripts:
creaturescript:
<event type="death" name="mDeath" event="script" value="expbonuspordominarcityguild.lua"/> <event type="statschange" name="mStatsChange" event="script" value="expbonuspordominarcityguild.lua"/> <event type="target" name="mTarget" event="script" value="expbonuspordominarcityguild.lua"/> <event type="login" name="mLogin" event="script" value="expbonuspordominarcityguild.lua"/>function onTarget(cid, target) local m, playerGuild = cityMonsters[getCreatureName(target)], getPlayerGuildId(cid) if isPlayer(cid) and isMonster(target) and m and playerGuild > 0 then return getGlobalStorageValue(DEFAULT_STORAGE + m) ~= playerGuild end return true end function onStatsChange(cid, attacker, type, combat, value) if isPlayer(attacker) and isMonster(cid) and type == STATSCHANGE_HEALTHLOSS then local m, playerGuild = cityMonsters[getCreatureName(cid)], getPlayerGuildId(attacker) if m and playerGuild > 0 then return getGlobalStorageValue(DEFAULT_STORAGE + m) ~= playerGuild end end return true end function onLogin(cid) local guildId = getPlayerGuildId(cid) if guildId > 0 and getGuildExpRate(guildId) > 1 then doPlayerSetExperienceRate(cid, getGuildExpRate(guildId)) end registerCreatureEvent(cid, "mTarget") registerCreatureEvent(cid, "mStatsChange") return true end function onDeath(cid, corpse, deathList) local killer, m = deathList[1], cityMonsters[getCreatureName(cid)] if killer and isPlayer(killer) and m then local atualGuild, playerGuild = getPlayerStorageValue(cid, 98471), getPlayerGuildId(killer) if atualGuild > 0 and playerGuild > 0 and atualGuild ~= playerGuild then setGuildExperience(atualGuild, getGuildExpRate(atualGuild) - 0.05) setGuildExperience(playerGuild, getGuildExpRate(playerGuild) + 0.05) setGlobalStorageValue(DEFAULT_STORAGE + m, playerGuild) end end return true endlib
cityMonsters = { --["monster_name"] = recomendo número anterior + 1, ["Chanceler Carlin"] = 1, ["Chanceler Kazz"] = 2, ["Chanceler Ab"] = 3, --etc } DEFAULT_STORAGE = 49198 function setGuildExperience(guildId, exp) for _, pid in pairs(getPlayersOnline()) do if getPlayerGuildId(pid) == guildId then doPlayerSetExperienceRate(cid, exp) end end end function getGuildExpRate(guildId) for _, pid in pairs(getPlayersOnline()) do local playerRate = getPlayerRates(pid)[8] if getPlayerGuildId(pid) == guildId and playerRate > 1 then return playerRate end end return 1.0 endExemplo de um dos monstros
<?xml version="1.0" encoding="UTF-8"?> <monster name="Chanceler Ab" nameDescription="Chanceler Ab" race="blood" experience="0" speed="0" manacost="0"> <health now="60000" max="60000"/> <look type="140" head="0" body="0" legs="0" feet="0" addons="3" corpse="6080"/> <flags> <flag summonable="0"/> <flag attackable="1"/> <flag hostile="1"/> <flag illusionable="0"/> <flag convinceable="0"/> <flag pushable="0"/> <flag canpushitems="1"/> <flag canpushcreatures="1"/> <flag targetdistance="1"/> </flags> <attacks> <attack name="melee" interval="2000" skill="90" attack="40"/> </attacks> <defenses armor="9" defense="11"> <defense name="healing" interval="1000" chance="9" min="750" max="1250"> <attribute key="areaEffect" value="blueshimmer"/> </defense> <defense name="healing" interval="1000" chance="17" min="300" max="500"> <attribute key="areaEffect" value="blueshimmer"/> </defense> </defenses> <immunities> <immunity lifedrain="1"/> <immunity paralyze="1"/> <immunity invisible="1"/> </immunities> <voices interval="5000" chance="10"> <voice sentence="Guards!" yell="1"/> </voices> <script> <event name="mDeath"/> </script> </monster>Editado Agosto 8 por warriorfrog