Ir para conteúdo

MatheusMkalo

Membro
  • Registro em

  • Última visita

Tudo que MatheusMkalo postou

  1. Bem o sistema é basicamente isso: Fazer com que so um player possa equipar determinado item. Eu fiquei em duvida se botava ou nao botava para aparecer o nome do owner no item, por isso fiz uma enquete para esse topico, a que vencer eu faço. O script esta em mod, voce nao precisa nem mexer no mod. Crie um arquivo.xml na pasta mods do seu ot e nomeie-o de ownersystem (é extremamente importante que o nome seja esse.) e bote esse script: <?xml version="1.0" encoding="UTF-8"?> <mod name="OwnerSystem" enabled="yes" author="MatheusMkalo" credits="Cezar (Patterns)"> <config name="OwnerLib"><![CDATA[ function getSlotIds(tag) local file = "mods/ownersystem.xml" local input = assert(io.open(file)) local content = assert(input:read("*a")) local tag = content:match("(<movevent[^>]*slot=[\"']".. tag .."[\"'][^>]*>)") local itemid = tag:match("itemid=[\"'](.-)[\"']") input:close() return itemid:explode(";") end function writeId(tag, id) local file = "mods/ownersystem.xml" local input = assert(io.open(file)) local content = assert(input:read("*a")) local tag = content:match("(<movevent[^>]*slot=[\"']".. tag .."[\"'][^>]*>)") local itemid = tag:match("itemid=[\"'](.-)[\"']") input:close() if(itemid:match(tostring(id))) then return true end if(itemid == "") then itemid = id else itemid = itemid .. ";" .. id end local ntag = tag:gsub("itemid=[\"'](.-)[\"']", "itemid=\"" .. itemid .. "\"") local content = content:gsub(tag, ntag) local output = assert(io.open(file, "w")) output:write(content) output:close() addEvent(doReloadInfo, 1000, 22) end function getItemType(itemid) local slottypes = {"head", "body", "legs", "feet"} local arq = io.open("data/items/items.xml", "r"):read("*all") local attributes = arq:match('<item id="' .. itemid .. '".+name="' .. getItemNameById(itemid) ..'">(.-)</item>') local slot = "" for i,x in pairs(slottypes) do if attributes:find(x) then slot = x break end end if slot == "body" then slot = "armor" end return slot end function isHandedWeapon(itemuid) local typee = getItemWeaponType(itemuid) or 0 if typee >= 1 and typee <= 6 then return TRUE end end function isPlayerOwnerItem(cid, itemuid) return not getItemAttribute(itemuid, "ownerguid") or getItemAttribute(itemuid, "ownerguid") == getPlayerGUID(cid) end function setItemOwner(itemuid, cid) if isHandedWeapon(itemuid) then local equips = getSlotIds("hand") if not table.find(equips, getItemIdByName(getItemName(itemuid))) then writeId("hand", getItemIdByName(getItemName(itemuid))) end doItemSetAttribute(itemuid, "ownerguid", getPlayerGUID(cid)) elseif getItemType(getItemIdByName(getItemName(itemuid))) then local equips = getSlotIds(getItemType(getItemIdByName(getItemName(itemuid)))) if not table.find(equips, getItemIdByName(getItemName(itemuid))) then writeId(getItemType(getItemIdByName(getItemName(itemuid))), getItemIdByName(getItemName(itemuid))) end doItemSetAttribute(itemuid, "ownerguid", getPlayerGUID(cid)) end end ]]></config> <movevent type="Equip" itemid="" slot="head" event="script"><![CDATA[ domodlib("OwnerLib") if not isPlayerOwnerItem(cid, item.uid) then addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.") else return TRUE end ]]></movevent> <movevent type="Equip" itemid="" slot="hand" event="script"><![CDATA[ domodlib("OwnerLib") if not isPlayerOwnerItem(cid, item.uid) then addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.") else return TRUE end ]]></movevent> <movevent type="Equip" itemid="" slot="legs" event="script"><![CDATA[ domodlib("OwnerLib") if not isPlayerOwnerItem(cid, item.uid) then addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.") else return TRUE end ]]></movevent> <movevent type="Equip" itemid="" slot="armor" event="script"><![CDATA[ domodlib("OwnerLib") if not isPlayerOwnerItem(cid, item.uid) then addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.") else return TRUE end ]]></movevent> <movevent type="Equip" itemid="" slot="feet" event="script"><![CDATA[ domodlib("OwnerLib") if not isPlayerOwnerItem(cid, item.uid) then addEvent(doPlayerSendCancel, 1, cid, "You are not the owner of this item.") else return TRUE end ]]></movevent> </mod> Agora vá na pasta libs e abra o arquivo.lua que tem o nome de functions ou 050-functions (pode variar de ot pra ot) e adicione essa funçao: function setItemOwner(itemuid, cid) domodlib("OwnerLib") return setItemOwner(itemuid, cid) end Agora vá em data/talkactions/scripts e abra o arquivo createitem.lua e mude o script para esse: function onSay(cid, words, param, channel) if(param == '') then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.") return true end local t = string.explode(param, ",") local ret = RETURNVALUE_NOERROR local pos = getCreaturePosition(cid) local id = tonumber(t[1]) if(not id) then id = getItemIdByName(t[1], false) if(not id) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item wich such name does not exists.") return true end end local amount = 100 if(t[2]) then amount = t[2] end local item = doCreateItemEx(id, amount) if(t[3] and getBooleanFromString(t[3])) then if(t[4] and getBooleanFromString(t[4])) then pos = getCreatureLookPosition(cid) end ret = doTileAddItemEx(pos, item) else doPlayerAddItem(cid, id, amount) ret = RETURNVALUE_NOERROR end if(ret ~= RETURNVALUE_NOERROR) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Couldn't add item: " .. t[1]) return true end doDecayItem(item) if(not isPlayerGhost(cid)) then doSendMagicEffect(pos, CONST_ME_MAGIC_RED) end return true end É de extrema importancia que voce mude o script do /i, pois o i que vem nos ots contem um bug que arruina com o sistema de owner. Pronto agora você so precisa juntar a minha funçao setItemOwner(itemuid, cid) com qualquer outro script de quest whatever. Lembre-se se voce quizer algum script que use esse meu sistema, peça-o na sessao de pedidos de scripts, não aqui.
  2. Bem, como todos sabem, não da pra criar 2 items com o mesmo sprite, somente editando a source e o dat etc... Usando esse sistema que eu fiz voce nao precisara editar nada somente adicionar os scripts. Primeiramente vá na pasta lib e crie um arquivo ItemsEditedLib.lua e adicione isso dentro: function doPlayerAddEditedItem(cid, itemid) local newxml = io.open("data/items/newitems.xml", "r") local configs = {} for i in newxml:read("*a"):gmatch("<item (.-)</item>") do local itemid = i:match('id="(.-)"') local itemconfig = { ["spriteid"] = tonumber(i:match('spriteid.-=.-"(.-)"')), ["article"] = i:match('article.-=.-"(.-)"'), ["name"] = i:match('name.-=.-"(.-)"'), ["description"] = i:match('key.-=.-"description".-value.-=.-"(.-)"'), ["defense"] = tonumber(i:match('key.-=.-"defense".-value.-=.-"(.-)"')), ["attack"] = tonumber(i:match('key.-=.-"attack".-value.-=.-"(.-)"')), ["extradefense"] = tonumber(i:match('key.-=.-"extradef".-value.-=.-"(.-)"')), ["armor"] = tonumber(i:match('key.-=.-"armor".-value.-=.-"(.-)"')), ["extraattack"] = tonumber(i:match('key.-=.-"extraatk".-value.-=.-"(.-)"')), } configs[tonumber(itemid)] = itemconfig end if configs[itemid] then local item = doPlayerAddItem(cid, configs[itemid].spriteid) for i,x in pairs(configs[itemid]) do doItemSetAttribute(item, i, x) end end end Depois vá na pasta items e adicione um arquivo newitems.XML (XML NAO LUA!!!) e adicione isso dentro: <?xml version="1.0" encoding="UTF-8"?> <items> <item id="100" spriteid="2400" article="a" name="magic edited sword"> <attribute key="description" value="Arma editada." /> <attribute key="defense" value="45" /> <attribute key="attack" value="100" /> <attribute key="elementIce" value="34"/> <attribute key="extradef" value="10" /> <attribute key="extraatk" value="10" /> </item> <item id="101" spriteid="2472" article="a" name="master plate armor"> <attribute key="description" value="Armor editada." /> <attribute key="armor" value="19" /> </item> </items> Bem como voces podem ver, o xml guarda os novos items, o xml funciona praticamente como o items.xml so que tem um novo campo o "spriteid", nele fica o itemid original. Eu sei que ainda faltam atributos, com o tempo e com os pedidos eu vou adicionando. Atributos: "description" "defense" "attack" "extradefense" "armor" "extraattack" Para adicionar os novos itemids aos players use doPlayerAddEditedItem(cid, ITEMID) em vez de doPlayerAddItem... Não tinha onde postar entao foi aki mesmo.
  3. Bem vou citar alguns erros: Você nao precisa falar com o npc, basta matar um monk e ir pegar a recompensa. Você nao precisa matar o monk que o npc sumonou, pode matar qualquer outro. E nao precisa bota registerCreatureEvent(cid, "NPC") no login.lua. O script ta bom mas se nao tivesse esses erros seria muito melhor.
  4. Ele vai ser teleportado pra essa posiçao: local firstpos = {x=56,y=67,z=7}
  5. Bem, existem varios scripts por ai de pontes que aparecem e desaparecem que sao bugadas e pequenas entao eu fiz esse script para que voce pudesse fazer uma ponte grande e decorada: ScreenShot: Vá em data/actions/scripts e bote um arquivo.lua com o nome de pontealavanca com esse script: function removeAll(configs, leverpos, tp, water, leveroff, leveron) local player = nil for i,x in pairs(configs) do for s, t in pairs(x) do for l = 0,255 do if isPlayer(getThingFromPos({x=t.x, y=t.y, z=t.z, stackpos = l}).uid) then player = {x=t.x, y=t.y, z=t.z, stackpos = l} break end end end end if player then doTeleportThing(getThingFromPos(player).uid, tp) end for i,x in pairs(configs) do for s, t in pairs(x) do for l = 0,255 do t.stackpos = l if getThingFromPos(t).itemid == i then if l == 0 then doTransformItem(getThingFromPos(t).uid, water) else doRemoveItem(getThingFromPos(t).uid) end end end end end for l = 0,255 do leverpos.stackpos = l if getThingFromPos(leverpos).itemid == leveron then doTransformItem(getThingFromPos(leverpos).uid, leveroff) break end end end function onUse(cid, item, fromPosition, itemEx, toPosition) local configs = { [1284] = {{x=56, y=60, z=7},{x=56, y=61, z=7},{x=56, y=62, z=7},{x=56, y=63, z=7},{x=56, y=64, z=7},{x=56, y=65, z=7},{x=56, y=66, z=7},{x=55, y=60, z=7},{x=55, y=61, z=7},{x=55, y=62, z=7},{x=55, y=63, z=7},{x=55, y=64, z=7},{x=55, y=65, z=7},{x=55, y=66, z=7},{x=54, y=60, z=7},{x=54, y=61, z=7},{x=54, y=62, z=7},{x=54, y=63, z=7},{x=54, y=64, z=7},{x=54, y=65, z=7},{x=54, y=66, z=7}}, [2742] = {{x=55, y=62, z=7}}, [1543] = {{x=54, y=60, z=7},{x=54, y=61, z=7},{x=54, y=62, z=7},{x=54, y=63, z=7},{x=54, y=64, z=7},{x=54, y=65, z=7},{x=54, y=66, z=7},{x=56, y=60, z=7},{x=56, y=61, z=7},{x=56, y=62, z=7},{x=56, y=63, z=7},{x=56, y=64, z=7},{x=56, y=65, z=7},{x=56, y=66, z=7}}, } local firstpos = {x=56,y=67,z=7} -- Posiçao do lado inicial da ponte local waterid = 4612 -- Item ID da agua. local time = 5 -- Em segundos local leveroff, leveron = 1945, 1946 -- Ids da alavanca puxada e nao puxada, respectivamente. if item.itemid == leveroff then for i,x in pairs(configs) do for s, t in pairs(x) do doCreateItem(i, t) doTransformItem(item.uid, leveron) end end addEvent(removeAll, time*1000, configs, getThingPos(item.uid), firstpos, waterid, leveroff, leveron) end return TRUE end Agora vá em actions.xml e bote essa linha: <action actionid="45666" event="script" value="pontealavanca.lua"/> Bote o actionid 45666 na alavanca e divirta-se '-' Para configurar a ponte basta voce fazer isso: Va no local configs = { ...... Apague tudo e deixe assim: local configs = { } Agora bote o itemid que sera criado ao puxar alavanca entre [] .. assim: local configs = { [1284] } Agora bote um = {}, ... local configs = { [1284] = {}, } Agora bote as posiçoes aonde vao ser criados os items 1284 separados por virgulas. local configs = { [1284] = {{x=1,y=2,z=3},{x=7,y=4,z=3}}, } By MatheusMkalo
  6. Adicionado /rank guilds, que mostra as guilds que mais mataram no ot. Agora com layout e frases exatamente iguais ao /rank padrao.
  7. Bem, a talkaction é a mesma coisa que o !rank que conhecemos, porem voce pode adicionar outros ranks e ela atualiza exatamente na hora que alguem upa. Exemplos de novos ranks: Rank para ver quem morreu mais. Rank para level de players vip. Rank para ver quem matou mais monstros no ot. E varios outros... Bem se alguem quizer implementar um novo rank, peça no topico e mande PM para mim (Nao adianta so pedir no topico porque eu nao irei lembrar de entrar nele). O script está em mod, bem mais facil de instalar. Va na pasta mods do seu ot e adicione o arquivo: RankSystem em formato XML e adicione isso: <?xml version="1.0" encoding="UTF-8"?> <mod name="RankSystem" enabled="yes" author="MatheusMkalo" forum="Tibiaking.com"> <config name="RankLib"><![CDATA[ ranks = { ["fist"] = 74666, ["club"] = 74667, ["sword"] = 74668, ["axe"] = 74669, ["distance"] = 74670, ["shielding"] = 74671, ["fishing"] = 74672, ["magic"] = 74673, ["level"] = 74674, ["monsters"] = 74675, ["guilds"] = 74676 } function havePlayerInRank(rank, playername) -- Checa se o player ja esta no rank. local rankstr = getGlobalStorageValue(ranks[rank]) local players = string.explode(rankstr, "; ") for i,x in pairs(players) do local a, b = string.find(x, "%[") if b ~= nil then if x:sub(1, b-1):lower() == playername:lower() then return TRUE end end end end function getPlayerLevelInRank(rank, playername) -- Pega o level de algum player no rank (Importante para novos tipos de rank.) local rankstr = getGlobalStorageValue(ranks[rank]) local players = string.explode(rankstr, "; ") for i,x in pairs(players) do local a, b = string.find(x, "%[") local t = string.match(x, "%[(.+)]") if b ~= nil and x:sub(1, b-1):lower() == playername:lower() then return t end end return 0 end function addRankPlayer(rank, playername, rankvalue) -- Adiciona um player ao rank ou muda o valor dele no rank. if not havePlayerInRank(rank, playername) then setGlobalStorageValue(ranks[rank], getGlobalStorageValue(ranks[rank]) .. (playername .. "[" .. rankvalue .. "]; ")) else local a,b = string.find(getGlobalStorageValue(ranks[rank]), playername) local c,d = string.find(getGlobalStorageValue(ranks[rank]), playername .. "%[%d+]") setGlobalStorageValue(ranks[rank], getGlobalStorageValue(ranks[rank]):sub(1, b+1) .. rankvalue .. "]; " .. getGlobalStorageValue(ranks[rank]):sub(d+2)) end end function tablelen(tab) -- By MatheusMkalo local result = 0 for i,x in pairs(tab) do result = result+1 end return result end function getRank(rank, maxplayers) -- Pega a lista de players com maior level do rank local rankstr = getGlobalStorageValue(ranks[rank]) local playerstatus = string.explode(rankstr, "; ") local tab = {} local rankTab = {} local rankStr = "Highscore for " .. rank .. "\n\n" .. (isInArray({"monsters", "guilds"}, rank) and "Number of Kills" or "Rank Level") .. " - " .. (rank == "guilds" and "Guild Name" or "Player Name") .. "\n" table.remove(playerstatus, #playerstatus) for i,x in pairs(playerstatus) do local a, b = string.find(x, "%[") local t = string.match(x, "%[(.+)]") tab[x:sub(1, b-1)] = tonumber(t) end local lastname = "" local lastvalue = 0 for i = 1, maxplayers do if tablelen(tab) <= 0 then break end for s,x in pairs(tab) do if x > lastvalue then lastvalue = x lastname = s end end table.insert(rankTab, lastvalue .. " - " .. lastname) tab[lastname] = nil lastname = "" lastvalue = 0 end for i,x in ipairs(rankTab) do rankStr = rankStr .. (i .. ". ") .. x .. "\n" end return rankStr end ]]></config> <talkaction words="!rank;/rank" event="script"><![CDATA[ domodlib('RankLib') if ranks[param:lower()] then setGlobalStorageValue(ranks[param:lower()], getGlobalStorageValue(ranks[param:lower()]) == -1 and "" or getGlobalStorageValue(ranks[param:lower()])) doShowTextDialog(cid, 6500, getRank(param:lower(), 10)) else return doPlayerSendCancel(cid, "Esse rank nao existe ou voce nao digitou corretamente.") end return TRUE ]]></talkaction> <creaturescript type="advance" name="RankSystem" event="script"><![CDATA[ domodlib('RankLib') if skill == 0 then setGlobalStorageValue(74666, getGlobalStorageValue(74666) == -1 and "" or getGlobalStorageValue(74666)) addRankPlayer("fist", getCreatureName(cid), newLevel) elseif skill == 1 then setGlobalStorageValue(74667, getGlobalStorageValue(74667) == -1 and "" or getGlobalStorageValue(74667)) addRankPlayer("club", getCreatureName(cid), newLevel) elseif skill == 2 then setGlobalStorageValue(74668, getGlobalStorageValue(74668) == -1 and "" or getGlobalStorageValue(74668)) addRankPlayer("sword", getCreatureName(cid), newLevel) elseif skill == 3 then setGlobalStorageValue(74669, getGlobalStorageValue(74669) == -1 and "" or getGlobalStorageValue(74669)) addRankPlayer("axe", getCreatureName(cid), newLevel) elseif skill == 4 then setGlobalStorageValue(74670, getGlobalStorageValue(74670) == -1 and "" or getGlobalStorageValue(74670)) addRankPlayer("distance", getCreatureName(cid), newLevel) elseif skill == 5 then setGlobalStorageValue(74671, getGlobalStorageValue(74671) == -1 and "" or getGlobalStorageValue(74671)) addRankPlayer("shielding", getCreatureName(cid), newLevel) elseif skill == 6 then setGlobalStorageValue(74672, getGlobalStorageValue(74672) == -1 and "" or getGlobalStorageValue(74672)) addRankPlayer("fishing", getCreatureName(cid), newLevel) elseif skill == 7 then setGlobalStorageValue(74673, getGlobalStorageValue(74673) == -1 and "" or getGlobalStorageValue(74673)) addRankPlayer("magic", getCreatureName(cid), newLevel) elseif skill == 8 then setGlobalStorageValue(74674, getGlobalStorageValue(74674) == -1 and "" or getGlobalStorageValue(74674)) addRankPlayer("level", getCreatureName(cid), newLevel) end return TRUE ]]></creaturescript> <creaturescript type="kill" name="KillRank" event="script"><![CDATA[ domodlib('RankLib') setGlobalStorageValue(74675, getGlobalStorageValue(74675) == -1 and "" or getGlobalStorageValue(74675)) if isMonster(target) then addRankPlayer("monsters", getCreatureName(cid), getPlayerLevelInRank("monsters", getCreatureName(cid))+1) end if isPlayer(target) then if getPlayerGuildId(cid) > 0 then if lastHit then if getPlayerGuildId(target) <= 0 or getPlayerGuildId(target) ~= getPlayerGuildId(cid) then addRankPlayer("guilds", getPlayerGuildName(cid), getPlayerLevelInRank("guilds", getPlayerGuildName(cid))+1) end end end end return TRUE ]]></creaturescript> <creaturescript type="login" name="RankEvents" event="script"><![CDATA[ registerCreatureEvent(cid, "KillRank") registerCreatureEvent(cid, "RankSystem") return TRUE ]]></creaturescript> </mod> Alem dos ranks normais, eu inclui um rank para os maiores matadores de monstros, para voces poderem ter uma ideia de como incluir novos ranks. PARA QUE O SCRIPT FUNCIONE RETIRE ESSA LINHA DO TALKACTIONS.XML: <talkaction words="!rank;/rank" event="script" value="ranks.lua"/> OBS: Para usar o rank novo use /rank ou !rank e o nome dos skills que se encontram nessa table: ranks = { ["fist"] = 74666, ["club"] = 74667, ["sword"] = 74668, ["axe"] = 74669, ["distance"] = 74670, ["shielding"] = 74671, ["fishing"] = 74672, ["magic"] = 74673, ["level"] = 74674, ["monsters"] = 74675 } No caso do novo rank seria /rank monsters. Para mudar o numero de players mostrados no rank mude essa linha no mod: doShowTextDialog(cid, 2160, getRank(param:lower(), 10)) 10 eh o numero de players que vai mostrar. Adicionado /rank guilds, que mostra as guilds que mais mataram no ot. Agora com layout e frases exatamente iguais ao /rank padrao. È Isso ai comentem!
  8. Todos os scripts foram testados em um ot 8.6 Bem o script é auto-explicativo, e ainda tem um video do sistema, acho que nao preciso explicar o que faz ne? AGORA EM MOD, MUITO MAIS PRATICO DE INSTALAR. SE FOR USAR O MOD VA ATE O FINAL DO POST, É EXATAMENTE IGUAL A VERSAO NORMAL, SO QUE MAIS PRATICO. FUNCIONA DO MESMO JEITO. Video: obs: Veja em fullscreen para ver melhor as msgs que retornam. Vá em data/lib e adicione esse script.lua com o nome de WarArenaLib: -- [[ Area and Positions Infos ]] -- areaplayersteam = { {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1}, {1,1,1,1} } areateam1ext = {x=80, y=305, z=7} -- Ponta superior esquerda da area do time um areateam2ext = {x=87, y=305, z=7} -- Ponta superior esquerda da area do time dois leaderteam1pos = {x=83, y=307, z=7, stackpos=255} -- Posição do lider do time um (que puxara a alavanca) leaderteam2pos = {x=87, y=307, z=7, stackpos=255} -- Posição do lider do time dois (que puxara a alavanca) newplayersposteam1 = {x=67, y=300, z=7} -- Posição para onde os players do time um serao teleportados newplayersposteam2 = {x=67, y=330, z=7} -- Posição para onde os players do time dois serao teleportados team1leverpos = {x=84, y=307, z=7, stackpos=1} -- Posição da alavanca que o lider do time um puxara team2leverpos = {x=86, y=307, z=7, stackpos=1} -- Posição da alavanca que o lider do time dois puxara leverafter, leverbefore = 9825, 9826 -- Ids das alavancas antes de puxadas e depois, consecutivamente (9825 = antes; 9826 = depois) posbenterteam1 = {x=78, y=307, z=7} -- Posiçao do sqm antes de entrar na arena do time 1 posbenterteam2 = {x=92, y=307, z=7} -- Posiçao do sqm antes de entrar na arena do time 2 backteampos = {x=77, y=307, z=7} -- [[ Storage Infos ]] -- team1leverstorage = 123497 -- Storage que sera usado quando puxarem a alavanca do time 1 team2leverstorage = 123498 -- Storage que sera usado quando puxarem a alavanca do time 2 haveteaminarena = 123499 -- Storage que sera usado para ve se tem algum time lutando na arena storageteam1death = 123500 -- Storage usado para ver quantos morreram do time 1 storageteam2death = 123501 -- Storage usado para ver quantos morreram do time 2 storageteam1 = 123502 -- Storage usado para ver quantas pessoas entraram na arena no time 1 storageteam2 = 123503 -- Storage usado para ver quantas pessoas entraram na arena no time 2 storageleader1 = 123504 -- Storage onde ficara guardado o uid do lider do time 1 storageleader2 = 123505 -- Storage onde ficara guardado o uid do lider do time 2 storageplayersteam1 = 123506 -- Storage que todos os players do team 1 iram ter. storageplatersteam2 = 123507 -- Storage que todos os players do team 2 iram ter. -- [[ Player Infos ]] -- needlevelarena = 20 -- Level que os outros jogadores sem ser o lider teram que ter. leaderlevel = 4000 -- Level que o lider tera que ter. onlyguildwars = true -- Se os membros de um time tem que ser da mesma guild do lider. (Nesse caso somente o lider da guild podera puxar a alavanca.) needplayers = 2 -- Quantidade de players que cada time tem que ter. -- [[ Functions ]] -- function getUidsFromArea(firstpos, area) local result = {} for i,x in pairs(area) do for s,z in pairs(x) do if isPlayer(getThingFromPos({x=firstpos.x+s-1, y=firstpos.y+i-1, z=firstpos.z, stackpos=255}).uid) then table.insert(result, getThingFromPos({x=firstpos.x+s-1, y=firstpos.y+i-1, z=firstpos.z, stackpos=255}).uid) end end end return result end function teleportUidsToPos(uids, pos) for i,x in pairs(uids) do doTeleportThing(x, pos) end end function isAllUidsSameGuild(uids, guildid) for i,x in pairs(uids) do if not (getPlayerGuildId(x) == guildid) then return false end end return true end function isAllUidsLevel(uids, level) for i,x in pairs(uids) do if not (getPlayerLevel(x) >= level) then return false end end return true end function haveQuantPlayersInArea(firstpos, area, quant) local result = 0 for i,x in pairs(area) do for s,z in pairs(x) do if isPlayer(getThingFromPos({x=firstpos.x+s-1, y=firstpos.y+i-1, z=firstpos.z, stackpos=255}).uid) then result = result+1 end end end return result >= quant end function addStorageToUids(uids, storage, value) for i,x in pairs(uids) do setPlayerStorageValue(x, storage, value) end end function checkPoses(pos1, pos2) if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then return true end return false end function startArena() setGlobalStorageValue(storageleader1, getThingFromPos(leaderteam1pos).uid) setGlobalStorageValue(storageleader2, getThingFromPos(leaderteam2pos).uid) addStorageToUids(team1uids, storageplayersteam1, 1) addStorageToUids(team2uids, storageplayersteam2, 1) teleportUidsToPos(team1uids, newplayersposteam1) teleportUidsToPos(team2uids, newplayersposteam2) setGlobalStorageValue(storageteam1, #team1uids) registerCreatureEventUids(team1uids, "DeathTeam1") registerCreatureEventUids(team2uids, "DeathTeam2") setGlobalStorageValue(storageteam2, #team2uids) setGlobalStorageValue(haveteaminarena, 1) setGlobalStorageValue(team1leverstorage, 0) setGlobalStorageValue(team2leverstorage, 0) doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end function haveTeamInArena() return getGlobalStorageValue(haveteaminarena) == 1 and true or false end function isSqmFromArea(firstpos, area, sqmpos) for i,x in pairs(area) do for s,z in pairs(x) do if sqmpos.x == firstpos.x+s-1 and sqmpos.y == firstpos.y+i-1 and sqmpos.z == firstpos.z then return true end end end return false end function registerCreatureEventUids(uids, event) for i,x in pairs(uids) do registerCreatureEvent(x, event) end end Agora vá em data/actions/scripts e adicione um script.lua com o nome de WarArenaLever: function onUse(cid, item, fromPosition, itemEx, toPosition) team1uids = getUidsFromArea(areateam1ext, areaplayersteam) team2uids = getUidsFromArea(areateam2ext, areaplayersteam) if haveTeamInArena() then return doPlayerSendCancel(cid, "Already have a team in arena.") end if checkPoses(toPosition, team1leverpos) then if checkPoses(getCreaturePosition(cid), leaderteam1pos) then if getGlobalStorageValue(team1leverstorage) == 1 then setGlobalStorageValue(team1leverstorage, 0) return doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) end if onlyguildwars and getPlayerGuildLevel(cid) < 3 then return doPlayerSendCancel(cid, "You need to be the leader of your guild.") end if onlyguildwars and not isAllUidsSameGuild(team1uids, getPlayerGuildId(cid)) then return doPlayerSendCancel(cid, "All of your team need to be in your guild.") end if not isAllUidsLevel(team1uids, needlevelarena) then return doPlayerSendCancel(cid, "All of your team need to be level " .. needlevelarena .. " or more.") end if getPlayerLevel(cid) < leaderlevel then return doPlayerSendCancel(cid, "You, the leader of the team, need to be level " .. leaderlevel .. " or more.") end if not haveQuantPlayersInArea(areateam1ext, areaplayersteam, needplayers) then return doPlayerSendCancel(cid, "Your team need " .. tostring(needplayers) .. " players.") end setGlobalStorageValue(team1leverstorage, 1) doTransformItem(getThingFromPos(team1leverpos).uid, leverbefore) if getGlobalStorageValue(team2leverstorage) >= 1 then startArena() end else doPlayerSendCancel(cid, "You must be the leader of the team to pull the lever.") end elseif checkPoses(toPosition, team2leverpos) then if checkPoses(getCreaturePosition(cid), leaderteam2pos) then if getGlobalStorageValue(team2leverstorage) == 1 then setGlobalStorageValue(team2leverstorage, 0) return doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end if onlyguildwars and getPlayerGuildLevel(cid) < 3 then return doPlayerSendCancel(cid, "You need to be the leader of your guild.") end if onlyguildwars and not isAllUidsSameGuild(team2uids, getPlayerGuildId(cid)) then return doPlayerSendCancel(cid, "All of your team need to be in your guild.") end if not isAllUidsLevel(team2uids, needlevelarena) then return doPlayerSendCancel(cid, "All of your team need to be level " .. needlevelarena .. " or more.") end if getPlayerLevel(cid) < leaderlevel then return doPlayerSendCancel(cid, "You, the leader of the team, need to be level " .. leaderlevel .. " or more.") end if not haveQuantPlayersInArea(areateam2ext, areaplayersteam, needplayers) then return doPlayerSendCancel(cid, "Your team need " .. tostring(needplayers) .. " players.") end setGlobalStorageValue(team2leverstorage, 1) doTransformItem(getThingFromPos(team2leverpos).uid, leverbefore) if getGlobalStorageValue(team1leverstorage) >= 1 then startArena() end else doPlayerSendCancel(cid, "You must be the leader of the team to pull the lever.") end end return TRUE end E em actions.xml bote essa linha: <action actionid="12349" event="script" value="WarArenaLever.lua"/> Agora vá em data/creaturescripts/scripts e adicione dois scripts.lua com esses nomes: WarArenaDeathTeam1: function onDeath(cid) setPlayerStorageValue(cid, storageplayersteam1, 0) setGlobalStorageValue(storageteam1death, getGlobalStorageValue(storageteam1death) >= 0 and getGlobalStorageValue(storageteam1death)+1 or 1) if getGlobalStorageValue(storageteam1death) >= getGlobalStorageValue(storageteam1) then if onlyguildwars then doBroadcastMessage("The Team 2 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader2)) .. ".") else doBroadcastMessage("The Team 2 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader2)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end return TRUE end WarArenaDeathTeam2: function onDeath(cid) setPlayerStorageValue(cid, storageplayersteam2, 0) setGlobalStorageValue(storageteam2death, getGlobalStorageValue(storageteam2death) >= 0 and getGlobalStorageValue(storageteam2death)+1 or 1) if getGlobalStorageValue(storageteam2death) >= getGlobalStorageValue(storageteam2) then if onlyguildwars then doBroadcastMessage("The Team 1 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader1)) .. ".") else doBroadcastMessage("The Team 1 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader1)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end return TRUE end Agora abra o creaturescripts.xml e adicione essas linhas: <event type="death" name="DeathTeam1" event="script" value="WarArenaDeathTeam1.lua"/> <event type="death" name="DeathTeam2" event="script" value="WarArenaDeathTeam2.lua"/> Agora vá em data/movements/scripts e adicione tres scripts.lua com esses nomes: WarArenaMovement1: function onStepOut(cid, item, position, fromPosition) local team = (fromPosition.x == leaderteam1pos.x and fromPosition.y == leaderteam1pos.y and fromPosition.z == leaderteam1pos.z) and "team1" or (fromPosition.x == leaderteam2pos.x and fromPosition.y == leaderteam2pos.y and fromPosition.z == leaderteam2pos.z) and "team2" if team == "team1" then if getGlobalStorageValue(team1leverstorage) == 1 then setGlobalStorageValue(team1leverstorage, 0) doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) end elseif team == "team2" then if getGlobalStorageValue(team2leverstorage) == 1 then setGlobalStorageValue(team2leverstorage, 0) doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end end end WarArenaMovement2: function onStepIn(cid, item, position, fromPosition) local team = isSqmFromArea(areateam1ext, areaplayersteam, fromPosition) and "team1" or isSqmFromArea(areateam2ext, areaplayersteam, fromPosition) and "team2" if team == "team1" then if getGlobalStorageValue(team1leverstorage) == 1 then if not haveQuantPlayersInArea(areateam1ext, areaplayersteam, needplayers) then setGlobalStorageValue(team1leverstorage, 0) doTransformItem(getThingFromPos(team1leverpos).uid, leverafter) end end elseif team == "team2" then if getGlobalStorageValue(team2leverstorage) == 1 then if not haveQuantPlayersInArea(areateam2ext, areaplayersteam, needplayers) then setGlobalStorageValue(team2leverstorage, 0) doTransformItem(getThingFromPos(team2leverpos).uid, leverafter) end end end if getGlobalStorageValue(team1leverstorage) == 1 then if checkPoses(fromPosition, posbenterteam1) then doTeleportThing(cid, fromPosition) return doPlayerSendCancel(cid, "You can't enter now.") end elseif getGlobalStorageValue(team2leverstorage) == 1 then if checkPoses(fromPosition, posbenterteam2) then doTeleportThing(cid, fromPosition) return doPlayerSendCancel(cid, "You can't enter now.") end end end WarArenaMovement3: function onStepIn(cid, item, position, fromPosition) if getPlayerStorageValue(cid, storageplayersteam1) >= 1 then setPlayerStorageValue(cid, storageplayersteam1, 0) doTeleportThing(cid, posbenterteam1) setGlobalStorageValue(storageteam1death, getGlobalStorageValue(storageteam1death) >= 0 and getGlobalStorageValue(storageteam1death)+1 or 1) if getGlobalStorageValue(haveteaminarena) >= 1 then if getGlobalStorageValue(storageteam1death) >= getGlobalStorageValue(storageteam1) then if onlyguildwars then doBroadcastMessage("The Team 2 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader2)) .. ".") else doBroadcastMessage("The Team 2 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader2)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end end elseif getPlayerStorageValue(cid, storageplayersteam2) >= 1 then setPlayerStorageValue(cid, storageplayersteam2, 0) doTeleportThing(cid, posbenterteam2) setGlobalStorageValue(storageteam2death, getGlobalStorageValue(storageteam2death) >= 0 and getGlobalStorageValue(storageteam2death)+1 or 1) if getGlobalStorageValue(haveteaminarena) >= 1 then if getGlobalStorageValue(storageteam2death) >= getGlobalStorageValue(storageteam2) then if onlyguildwars then doBroadcastMessage("The Team 1 won the war, guild " .. getPlayerGuildName(getGlobalStorageValue(storageleader1)) .. ".") else doBroadcastMessage("The Team 1 won the war, team leader name is " .. getCreatureName(getGlobalStorageValue(storageleader1)) .. ".") end setGlobalStorageValue(storageteam1death, 0) setGlobalStorageValue(storageteam2death, 0) setGlobalStorageValue(haveteaminarena, 0) end end end return TRUE end E adicione essas linhas em movements.xml: <movevent type="StepOut" actionid="12350" event="script" value="WarArenaMovement1.lua"/> <movevent type="StepIn" actionid="12351" event="script" value="WarArenaMovement2.lua"/> <movevent type="StepIn" actionid="12352" event="script" value="WarArenaMovement3.lua"/> Pronto acabou rairiaria. Adicionando os Actions IDS: Nas 2 alavancas, adicione o actionid 12349. Nos 2 sqms que os players vao estar antes de entrar na arena adicione o actionid 12351. Nos 2 quadrados aonde os lideres irao ficar (na frente da alavanca) bote o actionid 12350. No sqm de sair da arena bote o actionid 12352. NA AREA DOS TIMES E NA ARENA, BOTE PELO MAP EDITOR PARA NAO PODER LOGAR. (Se voce nao fizer isso pode haver bugs.) Bem, se voce souber ler o script da lib, vai saber configura-lo para seu otserver. Versão MOD: (Abra o spoiler) O modo de configurar é exatamente igual ao normal. Flws. By MatheusMkalo

Informação Importante

Confirmação de Termo