Tenho esse script de dominar cidades feito pelo zipster98, algo assim, alias muito obrigado...
Mas queria mudar 2 coisas q me faltam conhecimento, alguem mais experiente poderia me ajudar?
Scripts:
/lib/GOTlib.lua
cityMonsters = { --["monster_name"] = recomendo número anterior + 1, ["Chanceler Carlin"] = 1, ["Chanceler Venore"] = 2, ["Chanceler Thais"] = 3, ["Chanceler Darashia"] = 4, ["Chanceler Ankrahmun"] = 5, ["Chanceler Edron"] = 6, ["Chanceler Rookgaard"] = 7, ["Chanceler Svargrond"] = 8, --etc}DEFAULT_STORAGE = 49198function setGuildExperience(guildId, exp) for _, pid in pairs(getPlayersOnline()) do if getPlayerGuildId(pid) == guildId then doPlayerSetExperienceRate(pid, exp) end endendfunction 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.0endfunction 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") print(query:getDataString("name")) query:free() return retend
Monster exemple:
<monster name="Chanceler Carlin" file="GOT/chanceler carlin.xml"/>
<?xml version="1.0" encoding="UTF-8"?><monster name="Chanceler Carlin" nameDescription="Chanceler Carlin" race="blood" experience="0" speed="0" manacost="0"> <health now="6" max="6"/> <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="45" attack="20"/> </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>
<movevent type="StepIn" actionid="12000-12100" event="script" value="GOT/throne_capturing.lua"/> <movevent type="StepIn" actionid="2391-2398" event="script" value="GOT/tile_acess_members_of_throne.lua"/>
/movemments/throne_capturing.lua
local config = { level = 50, count = 5, messages = { [12000] = "[GOT]The guild %s is entering the castle.", [12001] = "[GOT]The guild %s is already inside the castle.", [12002] = "[GOT]The guild %s is close to conquer the castle." }, actionId = {12000, 4819}}function tableInsert(table, value) -- technically this doesn't need to be #table + 1, it can just be #table table[#table + 1] = valueendfunction onStepIn(cid, item, position, fromPosition) local pid, ip = {}, {} -- now they will hold the values generated by get getGuildOnlineMembers local function getGuildOnlineMembers(guildId) for _, cid in pairs(getPlayersOnline()) do if getPlayerGuildId(cid) == guildId and getPlayerLevel(cid) >= config.level and not isInArray(ip, getPlayerIp(cid)) then tableInsert(pid, cid) tableInsert(ip, getPlayerIp(cid)) end end return pid end if not isPlayer(cid) then return true end if item.actionid == config.actionId[1] then if getPlayerGuildId(cid) < 1 or #getGuildOnlineMembers(getPlayerGuildId(cid)) < config.count then doPlayerSendCancel(cid, "You need to be on guild or your guild must have at least "..config.count.." players level "..config.level.." or more.") doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doTeleportThing(cid, fromPosition, true) return true end end if getGlobalStorageValue(item.actionid + config.actionId[2]) < os.time() then broadcastMessage(config.messages[item.actionid]:format(getPlayerGuildName(cid))) setGlobalStorageValue(item.actionid + config.actionId[2], os.time() + 10) end doCreatureSetSkullType(cid, 3) return trueend
/movemments/tile_acess_members_of_throne.lua
local guilds = { --[actionid] = número da cidade configurado em cityMonsters, [2391] = 1, [2392] = 2, [2393] = 3, [2394] = 4, [2395] = 5, [2396] = 6, [2397] = 7, [2398] = 8,} 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) doPlayerSendCancel(cid, 'This territory is not of your Guild') end return trueend
CreatureScripts
<!-- Guild own throne +25%de exp --> <event type="death" name="mDeath" event="script" value="GOT/expbonus_got.lua"/> <event type="statschange" name="mStatsChange" event="script" value="GOT/expbonus_got.lua"/> <event type="target" name="mTarget" event="script" value="GOT/expbonus_got.lua"/> <event type="login" name="mLogin" event="script" value="GOT/expbonus_got.lua"/>
/creaturescripts/scripts/expbonus_got.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 trueendfunction 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 trueendfunction 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 trueend 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.25) end setGuildExperience(playerGuild, getGuildExpRate(playerGuild) + 0.25) setGlobalStorageValue(DEFAULT_STORAGE + m, playerGuild) broadcastMessage("The guild "..getPlayerGuildName(killer).."just dominate the throne of"..getCreatureName(cid):explode(" ")[2].."!") end end return trueend
Preciso de ajuda com duas coisas:
1- Como fazer pra fazer cancelamentos se já tiver um territorio
Como por exemplo:
function onTarget(cid, target) if SUAGUILDA TEM ALGUM TERRITORIO CANCELA O ATK DIZENDO QUE SUA GUILDA JA TEM UM TERRITORIO end 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 trueend
if SUAGUILDA TEM ALGUM TERRITORIO doPlayerSendCancel(cid, "Your guild already has a throne dominated! Only one per guild.") doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) doTeleportThing(cid, fromPosition, true) return true end
2- Como fazer uma placa pra eu colocar em frente de cada castelo, que quando os caras derem look aparecesse o nome da guilda dominante?
Sei la algo como esse pseudo codigo
onlook item sing value = NAOSEI local guildName = getGuildName(getGlobalStorageValue(value)) if guildName then "City owned by guild"..guildName.."!" else "No one guild own this city!" end