
Tudo que MaXwEllDeN postou
-
Spell Info ao avançar o level
2º O string explode separa uma string com base em um padrão. Como por exemplo nesse script. Caso em vez de uma ocorrência como "1;2;3;4;5", ele encontre algo assim "1", ele vai retornar a própria string. E não, o ; não serve como quebra de linha. Na verdade ele funciona assim: O primeiro for pega todo o conteúdo de uma tag de Spell usando esse padrão: <instant name="(.-)</instant> No caso, se eu tiver um arquivo spells.xml com alguma spell assim: <instant name="KAMUI" words="kamui in" lvl="120" mana="200" prem="1" blockwalls="1" exhaustion="1000" needlearn="0" event="script" value="especiais/kamui.lua"> <vocation id="5"/> <vocation id="6"/> <vocation id="7"/> <vocation id="8"/> </instant> Como primeira ocorrência o string.gmatch ia me retornar isso: Para pegar o nome da spell eu uso um string.match com esse padrão: "(.-)\"" Em seguida, com a string que sobrou(no quote acima) eu rodo mais um for usando string.gmatch, mas com o padrão: "<vocation id=\"(.-)\"" Usando o padrão acima, o for vai me retornar os seguintes valores em cada execução: 5 6 7 8 Eu não interpreto as quebras de linhas, não é necessário. Pois o padrão "<vocation id=\"(.-)\"" vai me retornar exatamente o que preciso. Segue uma aula sobre patterns, feita pelo Lwkass: http://www.tibiaking.com/forum/topic/25675-patterns/ Abraços (=
-
(Resolvido)Funçao doPlayerSendChannelMessage
[+] Eu vi essa um script parecido com esse em um ot Server que funciona como [Death Channel] ai eu estou querendo adaptar para Pokemon Rep+ Para quem Ajudar Essa função manda uma mensagem em um determinado channel que o player tenha aberto no momento.
-
Meu sistema de Shop
Gostei, cara. Boa sorte com seu projeto ^_^. Poderia me ensinar como fez para deixar esse background nos ítens um pouco transparente? Como por exemplo na opção das Montarias.
-
Spell Info ao avançar o level
Tenta assim: if not SERVER_SPELLS then SERVER_SPELLS = {} local file = io.open("data/spells/spells.xml") local str = file:read("*all") file:close() for line in str:gmatch("<instant name=\"(.-)</instant>") do for voc in line:gmatch("<vocation id=\"(.-)\"") do for _, vocation in pairs(string.explode(voc, ";")) do if SERVER_SPELLS[tonumber(vocation)] then table.insert(SERVER_SPELLS[tonumber(vocation)], line:match("(.-)\"")) else SERVER_SPELLS[tonumber(vocation)] = {line:match("(.-)\"")} end end end end end function onAdvance(cid, skill, oldLevel, newLevel) if skill == SKILL__MAGLEVEL then local str = "" for _, name in pairs(SERVER_SPELLS[getPlayerVocation(cid)]) do local spell = getInstantSpellInfo(false, name) if spell.mlevel > oldLevel and spell.mlevel <= newLevel then str = str .. "\n [".. name .."] \"".. spell.words .. "\" Mana[".. spell.mana .."]" end end if str ~= "" then doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have just advanced to magic level ".. newLevel .." and learned new spells!" .. str) end end return true end Obrigado, Matheus
-
spell info
Opa, perdão. Uma linha que acabei esquecendo de tirar enquanto testava o código. Pode copiar de novo no meu antigo post!
-
Spell Info ao avançar o level
Bem, pessoal. O script foi criado a partir do pedido do membro loreal: Sem mais delongas, para instalar é simples: Crie o arquivo creaturescripts/scripts/advancespells.lua e adicione o seguinte conteúdo: function onAdvance(cid, skill, oldLevel, newLevel) if skill == SKILL__LEVEL then local spells = {} for index = 0, getPlayerInstantSpellCount(cid) - 1 do local spell = getPlayerInstantSpellInfo(cid, index) if spell.level > oldLevel and spell.level <= newLevel then table.insert(spells, " [".. spell.name .."] \"".. spell.words .. "\" Mana[".. spell.mana .."]") end end if #spells > 0 then doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have just advanced to level ".. newLevel .." and learned new spells!") for _, v in pairs(spells) do doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, v) end end end return true end No arquivo creaturescripts/creaturescripts.xml adicione a tag: <event type="advance" name="AdvLevelSpells" event="script" value="advancespells.lua" /> No seu arquivo creaturescripts/scritps/login.lua adicione a seguinte linha ANTES DO ÚLTIMO return true: registerCreatureEvent(cid, "AdvLevelSpells") Exemplo: registerCreatureEvent(cid, "AdvLevelSpells") return true end
-
spell info
Não cheguei a testar creaturescripts/scripts/advancespells.lua if not SERVER_SPELLS then SERVER_SPELLS = {} local file = io.open("data/spells/spells.xml") local str = file:read("*all") file:close() for line in str:gmatch("<instant name=\"(.-)</instant>") do for voc in line:gmatch("<vocation id=\"(.-)\"") do for _, vocation in pairs(string.explode(voc, ";")) do if SERVER_SPELLS[tonumber(vocation)] then table.insert(SERVER_SPELLS[tonumber(vocation)], line:match("(.-)\"")) else SERVER_SPELLS[tonumber(vocation)] = {line:match("(.-)\"")} end end end end end function onAdvance(cid, skill, oldLevel, newLevel) if skill == SKILL__LEVEL then local str = "" for _, name in pairs(SERVER_SPELLS[getPlayerVocation(cid)]) do local spell = getInstantSpellInfo(false, name) if spell.level > oldLevel and spell.level <= newLevel then str = str .. "\n [".. name .."] \"".. spell.words .. "\" Mana[".. spell.mana .."]" end end if str ~= "" then doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You have just advanced to level ".. newLevel .." and learned new spells!" .. str) end end return true end creaturescripts/creaturescripts.xml <event type="advance" name="AdvLevelSpells" event="script" value="advancespells.lua" /> No seu arquivo creaturescripts/scritps/login.lua adicione a seguinte linha ANTES DO ÚLTIMO return true: registerCreatureEvent(cid, "AdvLevelSpells") Exemplo: registerCreatureEvent(cid, "AdvLevelSpells") return true end
-
OTClient - Otui Generator
Que ótima ideia. Iria facilitar e agilizar bastante o trabalho de quem curte fazer uns mods para OT Client. Espero que não se importe se eu utilizar sua ideia para desenvolver um em Python, somente com fins didáticos. Curti muito a ideia.
-
(Resolvido)Pedido Catapulta sistem
actions/actions.xml : <action actionid="2101" event="script" value="catapulta.lua"/> E não esquece de colocar a actionid na catapulta pelo map editor.
-
[Pedido] Enchanted System
Isso, caso não possua as tags, pode usar essas: <!-- Weapons enchanting (Gems) --> <action itemid="2146" event="script" value="other/enchanting.lua"/> <action itemid="2147" event="script" value="other/enchanting.lua"/> <action itemid="2150" event="script" value="other/enchanting.lua"/> <action itemid="2149" event="script" value="other/enchanting.lua"/> <action itemid="7759" event="script" value="other/enchanting.lua"/> <action itemid="7760" event="script" value="other/enchanting.lua"/> <action itemid="7761" event="script" value="other/enchanting.lua"/> <action itemid="7762" event="script" value="other/enchanting.lua"/> E não precisa configurar uma posição específica, independentemente de onde ela estiver no mapa, vai encantar do mesmo jeito.
-
(Resolvido)Pedido Catapulta sistem
local config = { shoot = "cima", -- Direção do tiro -- "cima" -- "baixo" -- "direita" -- "esquerda" damage = {100, 500}, -- Dano mínimo e máximo, respectivamente ammo_id = 2160, -- Itemid da pedra ammo_shoot = 10, -- Quantas stones para um "tiro" ammo_pos = {x = 160, y = 54, z = 7}, -- Posição onde as stones vão ficar } local area = createCombatArea({ {1, 1, 1}, {1, 1, 1}, {1, 1, 1}, {1, 1, 1} }) local aux = { ["cima"] = {0, -10}, ["baixo"] = {0, 10}, ["direita"] = {10, 0}, ["esquerda"] = {-10, 0}, } function onUse(cid, item, frompos, item2, tp) local pos = {x = tp.x + aux[config.shoot][1], y = tp.y + aux[config.shoot][2], z = tp.z} local stones = getTileItemById(config.ammo_pos, config.ammo_id) if stones.uid == 0 or stones.type < config.ammo_shoot then return false end doRemoveItem(stones.uid, config.ammo_shoot) doAreaCombatHealth(cid, COMBAT_PHYSICALDAMAGE, pos, area, -config.damage[1], -config.damage[2], CONST_ME_HITAREA) return true end
-
[Pedido] Enchanted System
-- [( Script edited by DoidinMapper )] -- function onUse(cid, item, fromPosition, item2, toPosition) local gems = {2146, 2147, 2149, 2150} local egems = {7759, 7760, 7761, 7762} local altars = {{7508, 7509, 7510, 7511}, {7504, 7505, 7506, 7507}, {7516, 7517, 7518, 7519}, {7512, 7513, 7514, 7515}} local weapons = {2383, 7384, 7389, 7406, 7402, 2429, 2430, 2435, 7380, 2454, 2423, 2445, 7415, 7392, 2391, 2544, 8905} local eweapons = {{7763, 7744, 7854, 7869}, {7765, 7746, 7856, 7871}, {7770, 7751, 7861, 7876}, {7766, 7747, 7857, 7872}, {7767, 7748, 7858, 7873}, {7768, 7749, 7859, 7874}, {7769, 7750, 7860, 7875}, {7770, 7751, 7861, 7876}, {7771, 7752, 7862, 7877}, {7772, 7753, 7863, 7878}, {7773, 7754, 7864, 7879}, {7774, 7755, 7865, 7880}, {7775, 7756, 7866, 7881}, {7776, 7757, 7867, 7882}, {7777, 7758, 7868, 7883}, {7839, 7840, 7838, 7850}, {8907, 8906, 8909, 8908}} local type = item.type == 0 and 1 or item.type local mana = -300 * type local soul = -2 * type if isInArray(gems, item.itemid) then for aa=1, #gems do if item.itemid == gems[aa] then a=aa end end if isInArray(altars[a], item2.itemid) then if getPlayerMana(cid) >= mana and getPlayerSoul(cid) >= soul then doTransformItem(item.uid,egems[a]) doPlayerAddMana(cid,mana) doPlayerAddSoul(cid,soul) doSendMagicEffect(fromPosition,39) else doPlayerSendCancel(cid,"You dont have mana or soul points.") end else return 2 end elseif isInArray(egems, item.itemid)== TRUE then for bb = 1, #egems do if item.itemid == egems[bb] then b = bb end end if isInArray(weapons, item2.itemid)== TRUE then for cc=1, #weapons do if item2.itemid == weapons[cc] then c=cc end end doTransformItem(item2.uid,eweapons[c][b],1000) doSendMagicEffect(fromPosition,39) doRemoveItem(item.uid,1) else doPlayerSendCancel(cid,"You can't enchanted this.") end else return 0 end return 1 end Créditos: DoidinMapper
-
AutoEquipar clickando em um Item[AJUDA]
Quando houver um item dentro da backpack que não seja "equipável" ou não seja da parte do set em si, o que aconteceria? Quando eu clicar na backpack e já possuir algo equipado, ele simplesmente abririra a backpack como se fosse uma bp normal?
-
Poste sua depressão da noite
Minha depressão é porque tô deprimido.
-
[CTF] Capture The Flag 2.0(Automático)
Me desculpe por não te ensinar a ler, realmente foi meu erro fazer esse script para a comunidade. Perdão mesmo.
-
Hoje sou um novato, amanhã um novo OTserv
Bem vindo ao TK. Tenha uma ótima estadia (: E boa sorte com seu servidor.
-
[CTF] Capture The Flag 2.0(Automático)
Você não há via removido essa "tralha não-funcional" do seu OT? Para pegar a bandeira é pisando no tile cuja posição para configurar está descrita na lib. E sim, você vai ter que fazer o mapa Sobre adicionar o outro item ao vencedor: Tem uma função que é executada pra acabar o evento, ela que adicionar todos os ítens aos vencedores, lê a lib e tenta adicionar. Sobre o looktype, já está configurado, não?
-
Uma pequena modificação nessa Action
Ah, um exemplo de um dialog normal mesmo.
-
Uma pequena modificação nessa Action
Me mostra um exemplo pra eu ver como é. Se me lembro bem, ele define os dialogs quando tá carregando o script. E mais tarde, ele só faz ler os dialogs que já estão definidos. Por isso seria necessário criar dois dialogs, e na hora, só escolher qual mostrar
-
Uma pequena modificação nessa Action
Creio que você teria que fazer dois dialogs com a mesma estrutura, mas só mudando o nome. Ai caso a storage assumisse um valor, você enviava um dialog, caso fosse outro valor, enviava outro dialog. Se pudesse postar o resto do script, eu ajeitava pra você. Não lembro qual lógica os modal dialogs seguem, hehe
-
(Resolvido)[Pedido] Alterar effect
local events = {} function getPositionsByDirection(uid) pos = getCreaturePosition(uid) positionsByDirection = { [1] = {x = pos.x + 1, y = pos.y, z = pos.z, stackpos = 0}, [2] = {x = pos.x, y = pos.y + 1, z = pos.z, stackpos = 0}, [3] = {x = pos.x - 1, y = pos.y, z = pos.z, stackpos = 0}, [4] = {x = pos.x, y = pos.y - 1, z = pos.z, stackpos = 0}, } return positionsByDirection end function changeOutfit(cid) local sec = 0.5 if not isPlayer(cid) then return false end local positions = getPositionsByDirection(cid) local last = last or 1 local last = (positions[last] and last) or 1 local next = (last == #positions) and 1 or last + 1 doSendDistanceShoot(positions[last], positions[next], 18) local event = addEvent(changeOutfit, 3.0*sec*450, cid) events[cid] = event return true end function onLogin(cid) local storage = getGlobalStorageValue(13340) if storage == getPlayerGuildId(cid) then local event = addEvent(changeOutfit, 0, cid) events[cid] = event end return true end function onLogout(cid) if events[cid] then stopEvent(events[cid]) end return true end
-
(Resolvido)[Pedido] Alterar effect
Estranho, testei aqui e funcionou de boa. Tenta assim: local interval = 0.5 -- Em segundos local function getPositions(uid) local pos = getCreaturePosition(uid) local ret = { [1] = {x = pos.x + 1, y = pos.y, z = pos.z}, [2] = {x = pos.x, y = pos.y + 1, z = pos.z}, [3] = {x = pos.x - 1, y = pos.y, z = pos.z}, [4] = {x = pos.x, y = pos.y - 1, z = pos.z}, } return ret end function changeOutfit(cid, last) local sec = 0.5 if not isPlayer(cid) then return false end local positions = getPositions(cid) local last = last or 1 local last = (positions[last] and last) or 1 local next = (last == #positions) and 1 or last + 1 doSendDistanceShoot(positions[last], positions[next], 18) addEvent(changeOutfit, 3.0 * interval * 450, cid, last + 1) return true end function onLogin(cid) addEvent(changeOutfit, 0, cid) return true end
-
(Resolvido)Ordenar tabela
Desse modo vai ordenar em ordem decrescente: local t = {{1,30},{2,35},{3,55},{4,20},{5,70}} table.sort(t, function(a, b) return a[2] > b[2] end) for i, v in ipairs(t) do print(v[1] .. " = ".. v[2]) end Desse em ordem decrescente: local t = {{1,30},{2,35},{3,55},{4,20},{5,70}} table.sort(t, function(a, b) return a[2] < b[2] end) for i, v in ipairs(t) do print(v[1] .. " = ".. v[2]) end
-
(Resolvido)[Pedido] Alterar effect
local interval = 0.5 -- Em segundos local function getPositions(uid) local pos = getCreaturePosition(uid) local ret = { [1] = {x = pos.x + 1, y = pos.y, z = pos.z}, [2] = {x = pos.x, y = pos.y + 1, z = pos.z}, [3] = {x = pos.x - 1, y = pos.y, z = pos.z}, [4] = {x = pos.x, y = pos.y - 1, z = pos.z}, } return ret end function changeOutfit(cid, last) local sec = 0.5 if not isPlayer(cid) then return false end local positions = getPositions(cid) local last = last or 1 local last = (positions[last] and last) or 1 local next = (last == #positions) and 1 or last + 1 doSendDistanceShoot(positions[last], positions[next], 18) addEvent(changeOutfit, 3.0 * interval * 450, cid, last + 1) return true end function onLogin(cid) if getGlobalStorageValue(13340) == getPlayerGuildId(cid) then addEvent(changeOutfit, 0, cid) end return true end function onLogout(cid) return true end
- Pagseguro entrega de pontos