Ir para conteúdo

brun123

Conde
  • Total de itens

    512
  • Registro em

  • Última visita

  • Dias Ganhos

    16

Tudo que brun123 postou

  1. acabei de testar aqui, o onEquip é lançado antes de atualizar a última data que o player fez login, então a função getPlayerLastLogin retorna a última vez que o player fez login (antes do login que está sendo feito no momento), então tá aqui a solução do teu problema: function onEquip(cid, item, slot) if getPlayerSlotItem(cid, slot).uid == item.uid then return true end local forc = getPlayerStorageValue(cid, 23222) setPlayerStorageValue(cid, 23222, forc + 2) return true end function onDeEquip(cid, item, slot) local forc = getPlayerStorageValue(cid, 23222) setPlayerStorageValue(cid, 23222, forc - 2) return true end dessa forma o onEquip vai ser executado apenas uma vez, então já coloquei pra aumentar o storage em 2
  2. function onEquip(cid, item, slot) if os.time() - getPlayerLastLogin(cid) <= 1 then return true end local forc = getPlayerStorageValue(cid, 23222) setPlayerStorageValue(cid, 23222, forc + 1) return true -- +2 de forc, porque o return true faz executar 2x o setStorage. end function onDeEquip(cid, item, slot) local forc = getPlayerStorageValue(cid, 23222) setPlayerStorageValue(cid, 23222, forc - 2) return true -- no DeEquip o return true não executa 2x o serStorage, não tenho idéia do porque. end
  3. local block = {} function onEquip(cid, item, slot) if os.time() - getPlayerLastLogin(cid) <= 1 then return true end if block[cid] then block[cid] = nil return true else block[cid] = 1 end setCreatureMaxMana(cid, getCreatureMaxMana(cid) + 100) doCreatureAddMana(cid, 100) return true end function onDeEquip(cid, item, slot) setCreatureMaxMana(cid, getCreatureMaxMana(cid) - 100) doCreatureAddMana(cid, -100) return true end E no xml: <movevent type="Equip" itemid="????" slot="ammo" event="script" value="???.lua"/> <movevent type="DeEquip" itemid="????" slot="ammo" event="script" value="???.lua"/>
  4. function onCastSpell(cid, var) local maxSummons = 8 for n = 1, maxSummons do if #getCreatureSummons(cid) >= maxSummons then break end local clone = doCreateMonster("clone sanin", getThingPos(cid), false) if isCreature(clone) then doTeleportThing(clone, getThingPos(cid), false) doConvinceCreature(cid, clone) setCreatureMaxHealth(clone, getCreatureMaxHealth(cid)) doCreatureAddHealth(clone, getCreatureHealth(cid)) doSetCreatureOutfit(clone, getCreatureOutfit(cid), -1) doSendMagicEffect(getThingPos(cid), 111) end end return true end
  5. brun123

    Simplificar Função

    function recursive_skipLine(string, maxLength) if string:len() > maxLength then return string:sub(1, maxLength) .. "\n" .. recursive_skipLine(string:sub(maxLength + 1, string:len()), maxLength) end return string end function iterative_skipLine(string, maxLength) for n = maxLength, string:len() * (1 + 2/maxLength), maxLength + 2 do string = string:sub(1, n) .. "\n" .. string:sub(n + 1, string:len()) end return string end uma função recursiva e outra iterativa pra você ver ambas formas de resolver seu probleminha em questão de tempo de execução, a iterative é ligeiramente mais rápida, só que em questão de memória, a recursiva pesa mais... mas isso só chega a ser um problema se o texto for realmente grande, pode testar com um debugger um código do tipo: local text = "" for a = 1, 1280 do text = text .. "Um texto realmente muito grande! " end local time = os.clock() text = ?????????_skipLine(text, 4) time = os.clock() - time print(time, #text) no lugar dos "??????" coloque a se é a função iterative ou recursiva, aí você consegue ver o tempo que cada uma demora pra separar um texto grandinho em 4 em 4... um detalhezinho, não coloque 0 como maxLength que você vai abrir um loop sem fim... no caso do recursivo, aponta stack overflow no final por exigir muito da memória, mas a iterativa rola pra sempre e inclusive trava o servidor.
  6. estilo de programação é estilo de programação... meu "tab" tem 4 espaços em vez de 8, assim como também não vejo problema nenhum em fazer algo do tipo: if x <= 0 then return false end acho mais bonito uma função assim: function myFunctionName() do que: function my_function_name() mas o que eu sempre fiz foi seguir o padrão do tibia, que separa palavras usando letras maiúsculas
  7. troca essa linha: local dmg = getCreatureLevel(cid) / 10 por essa: local dmg = getPlayerLevel(cid) / 10 Não entendi direito isso que você está falando de "combar em 4 hits nos sqms desejados" eu só reproduzi a script que você postou no tópico, só que ela tem um monte de variável inutilizada e coisas que poderiam ser simplificadas, o autor tentou usar for mas não se atentou ao fato de tudo ser executado ao mesmo tempo se não for utilizado addEvent e também na script original poderia dar erros se não tivesse alvo selecionado, já que a verificação de isCreature foi feito horrorosamente errada e sempre retornará true, e o player é teleportado em cima do alvo. só esses erros aí que arrumei
  8. é foi erro bobo meu> function onCastSpell(cid, var) local function blink(cid, target, turn) if not isCreature(cid) or not isCreature(target) or turn <= 0 then return end local dir, targetPos = {0, 1, 2, 3, 4, 5, 6, 7}, getThingPos(target) table.remove(dir, getDirectionTo(targetPos, getThingPos(cid)) + 1) doTeleportThing(cid, getPosByDir(targetPos, dir[math.random(#dir)]), false) doCreatureSetLookDir(cid, getDirectionTo(getThingPos(cid), targetPos)) local dmg = getCreatureLevel(cid) / 10 doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -dmg * 0.9, -dmg * 1.1, CONST_ME_BLOCKHIT) addEvent(blink, 650, cid, target, (turn or 3) - 1) end if not isCreature(getCreatureTarget(cid)) then doPlayerSendCancel(cid, "You need a target.") return false end addEvent(blink, 1000, cid, getCreatureTarget(cid), 3) return true end
  9. function onCastSpell(cid, var) local function blink(cid, target, turn) if not isCreature(cid) or not isCreature(target) or turn <= 0 then return end local dir, targetPos = {0, 1, 2, 3, 4, 5, 6, 7}, getThingPos(target) table.remove(dir, getDirectionTo(targetPos, getThingPos(cid)) + 1) doTeleportThing(cid, getPosByDir(targetPos, dir[math.random(#dir)]), false) doCreatureSetLookDir(cid, getDirectionTo(getThingPos(cid), targetPos)) local dmg = getCreatureLevel(cid) / 10 doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -dmg * 0.9, -dmg * 1.1, CONST_ME_BLOCKHIT) addEvent(blink, 650, cid, target, (turn or 3) - 1) end if not isCreature(getCreatureTarget(cid)) then doPlayerSendCancel(cid, "You need a target.") return false end addEvent(blink, 1000, cid, target, 3) return true end
  10. é uma função que se não me enganho foi o mock que fez, que pega todas as variáveis globais e verifica o tipo delas, e se forem do tipo "function", escreve em um arquivo pedir o que cada uma delas faz e um exemplo é demais cara, cabe a você ler elas e deduzir o que elas fazem e se sobrar alguma dúvida, pesquise e tente testá-las em alguma script pra ver o resultado, não custa nada tentar fazer sozinho, e você aprende bem mais. todas as funções aí são em lua, pra quem disse que tinha coisa em c++. Como a função deve ter sido executada em um server 8.54 ou numa versão anterior, é óbvio que não vai ter as funções de mount, e aí tem todas as funções possíveis de serem utilizadas no server que o cara testou. Óbvio também que em um server com código fonte alterado e libs modificadas vão ter funções a mais, principalmente os servidores derivados... O máximo que dava pra fazer era colocar os parâmetros de cada função, isso sim ajudaria bastante, mas nem adianta pedir para o autor do tópico fazer isso, que já deu pra ver que não tem experiência nenhuma não acredito mesmo que você procurou por essas funções, inclusive tem umas aí que mal tem utilidade para scripts de tibia mesmo, e ainda colocou elas em ordem alfabética
  11. faça a verificação: isCreature(uid) se o player tiver logado ou morrido, essa verificação retorna false e para de ficar teleportando o player
  12. brun123

    Modificar Número

    function func(number) local number = number local decimal = number - math.floor(number) decimal = tonumber(tostring(decimal):sub(3, string.len(decimal))) number = tostring(math.floor(number)):reverse() for _ = 3, #number, 4 do number = number:sub(1, _) .. "." .. number:sub(_ + 1, #number) end return number:reverse() .. (decimal and "," .. decimal or "") end
  13. ops, erro idiota meu, aqui: local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then pass = false break elseif type(area.creatureName) == "string" and getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) return false end return true end
  14. local areas = { [1] = { fromPosition = {x = 93, y = 125, z = 7}, -- upper-left sqm toPosition = {x = 95, y = 127, z = 7}, -- lower-right sqm creatureName = {"Rat", "Cave Rat"} } } function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) local pass = true for _, area in ipairs(areas) do local x = {min = math.min(area.fromPosition.x, area.toPosition.x), max = math.max(area.fromPosition.x, area.toPosition.x)} local y = {min = math.min(area.fromPosition.y, area.toPosition.y), max = math.max(area.fromPosition.y, area.toPosition.y)} local width = ((x.max - x.min) / 2) + 1 local lenght = ((y.max - y.min) / 2) + 1 local center = {x = x.min + width, y = y.min + lenght, z = area.fromPosition.z} local specs = getSpectators(center, width, lenght, false) if specs then for _, cn in ipairs(specs) do if type(area.creatureName) == "table" and isInArray(area.creatureName, getCreatureName(cn)) then pass = false break elseif getCreatureName(cn):lower() == area.creatureName:lower() then pass = false break end end end end if pass == false then doPlayerSendCancel(cid, "Sorry, you need to kill all the monsters in the area to pass.") doTeleportThing(cid, fromPosition, true) return false end return true end
  15. Fiz por direção, basta configurar a tabela "dirPref" e ver quais direções você quer dar prioridade pra sumonar: local delay = {} function onUse(cid, item, frompos, item2, topos) local maxSummons = 8 -- máximo de summons permitidos por player local timeForReuse = 5 -- segundos para usar novamente local cost = 1500 -- gold para sumonar local dirPref = {NORTHWEST, SOUTHEAST, NORTHEAST, SOUTHWEST, NORTH, SOUTH, EAST, WEST} local monsters = { -- tabela com monstros, e a quantidade que vai sumonar ["Rat"] = 3, ["Tiger"] = 2, } if delay[0] and delay[0] - os.time() > 0 then return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.") end local monsterCount = 0 local guid = getPlayerGUID(cid) if delay[guid] then for _, mid in pairs(delay[guid]) do if isCreature(mid) then monsterCount = monsterCount + 1 else delay[guid][_] = nil end end else delay[guid] = {} end if monsterCount >= maxSummons then return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!") end if not doPlayerRemoveMoney(cid, cost) then return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!") end delay[0] = os.time() + timeForReuse monsterCount = 0 local dir = 1 for monsterName, number in pairs(monsters) do for _ = 1, number do local range = 1 local pos = getPosByDir(getThingPos(cid), dirPref[dir], range) local loops = 0 while doTileQueryAdd(cid, pos, 0, false) ~= 1 and loops <= #dirPref * 2 do dir = (dir + 1) > #dirPref and 1 or dir + 1 if dir == 1 then range = range + 1 end pos = getPosByDir(getThingPos(cid), dirPref[dir], range) loops = loops + 1 end if doTileQueryAdd(cid, pos, 0, false) ~= 1 then pos = getClosestFreeTile(cid, getThingPos(cid), true) end local newMonster = doCreateMonster(monsterName, pos, false) if isCreature(newMonster) then monsterCount = monsterCount + 1 table.insert(delay[guid], newMonster) doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT) if monsterCount >= maxSummons then return true end end end end return true end
  16. Assim: local delay = {} function onUse(cid, item, frompos, item2, topos) local maxSummons = 8 -- máximo de summons permitidos por player local timeForReuse = 5 -- segundos para usar novamente local cost = 1500 -- gold para sumonar local monsters = { -- tabela com monstros, e a quantidade que vai sumonar ["Rat"] = 3, ["Tiger"] = 2, } if delay[0] and delay[0] - os.time() > 0 then return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.") end local monsterCount = 0 local guid = getPlayerGUID(cid) if delay[guid] then for _, mid in pairs(delay[guid]) do if isCreature(mid) then monsterCount = monsterCount + 1 else delay[guid][_] = nil end end else delay[guid] = {} end if monsterCount >= maxSummons then return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!") end if not doPlayerRemoveMoney(cid, cost) then return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!") end delay[0] = os.time() + timeForReuse monsterCount = 0 for monsterName, number in pairs(monsters) do for _ = 1, number do local newMonster = doCreateMonster(monsterName, getClosestFreeTile(cid, getThingPos(cid), true), false) if isCreature(newMonster) then monsterCount = monsterCount + 1 table.insert(delay[guid], newMonster) doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT) if monsterCount >= maxSummons then return true end end end end return true end
  17. e tem que compilador o servidor e trocar o executável, não é só editar o arquivo não
  18. Use essa script: Fiz o mesmo esquema de como sumona criaturas, basta editar a tabela monsters. Se quiser algo do tipo monstro de acordo com level do player etc, só pedir local delay = {} function onUse(cid, item, frompos, item2, topos) local maxSummons = 8 -- máximo de summons permitidos por player local timeForReuse = 5 -- segundos para usar novamente local cost = 1500 -- gold para sumonar local monsters = { -- tabela com monstros, e a quantidade que vai sumonar ["Rat"] = 3, ["Tiger"] = 2, } if delay[0] and delay[0] - os.time() > 0 then return doPlayerSendCancel(cid, "Espere "..(delay[0] - os.time()).." segundos para puxar a alavanca novamente.") end local monsterCount = 0 local guid = getPlayerGUID(cid) if delay[guid] then for _, mid in pairs(delay[guid]) do if isCreature(mid) then monsterCount = monsterCount + 1 else delay[guid][_] = nil end end end if monsterCount >= maxSummons then return doPlayerSendCancel(cid, "Há muitos monstros sumonados por você, mate-os primeiro!") end if not doPlayerRemoveMoney(cid, cost) then return doPlayerSendCancel(cid, "Você não tem dinheiro suficiente para pagar!") end delay[0] = os.time() + timeForReuse monsterCount = 0 for monsterName, number in pairs(monsters) do for _ = 1, number do local newMonster = doCreateMonster(monsterName, getClosestFreeTile(cid, getThingPos(cid), true), false) if isCreature(newMonster) then monsterCount = monsterCount + 1 table.insert(delay[guid], newMonster) doSendMagicEffect(getThingPos(newMonster), CONST_ME_TELEPORT) if monsterCount >= maxSummons then return true end end end end return true end
  19. Teste trocar: doTeleportThing(cid, fromPosition, true) para: addEvent(doTeleportThing, 5, cid, fromPosition, true)
  20. mude isso: if skillId.add == "none" then return false elseif skillId.add == "speed" then doChangeSpeed(cid, getCreatureSpeed(cid)+(value*skillId.count)) elseif skillId.add == "health" then setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(value*skillId.count)) elseif skillId.add == "mana" then setCreatureMaxMana(cid, getCreatureMaxMana(cid)+(value*skillId.count)) end para isso: if skillId.add == "speed" then doChangeSpeed(cid, getCreatureSpeed(cid)+(value*skillId.count)) elseif skillId.add == "health" then setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+(value*skillId.count)) elseif skillId.add == "mana" then setCreatureMaxMana(cid, getCreatureMaxMana(cid)+(value*skillId.count)) end
  21. brun123

    Script quest

    abre o arquivo actions.xml (data/actions) e adicione essa linha: <action actionid="9543" event="script" value="tocha_quest.lua"/> aí cria um arquivo chamado tocha_quest.lua em data/actions/scripts e coloca aquele script que postei lá em cima agora vai no map editor, clica 2x em cima daquela tocha que precisa dar use e coloque o action id dela como 9543, e teste
  22. local spell_config = { [1] = { damage = COMBAT_FIREDAMAGE, areaEffect = CONST_ME_FIREAREA, shootEffect = 15, }, [2] = { damage = COMBAT_ENERGYDAMAGE, areaEffect = CONST_ME_ENERGYAREA, shootEffect, 13, }, [3] = { damage = COMBAT_EARTHDAMAGE, areaEffect = CONST_ME_SMALLPLANTS, shootEffect, 1, } } local combats = {} for _, config in ipairs(spell_config) do local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, config.damage) setCombatParam(combat, COMBAT_PARAM_EFFECT, config.areaEffect) function onGetFormulaValues(cid, level, skill, attack, factor) return -(((skill + 25) / 3) + (level / 5)), -((skill + 25) + (level / 5)) end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") table.insert(combats, {combat, config.shootEffect}) end function onCastSpell(cid, var) local function doSendDistance(cid, target, effect) if not isCreature(cid) or not isCreature(target) then return end doSendDistanceShoot(getThingPos(cid), getThingPos(target), effect) end for n = 1, #combats do addEvent(doCombat, n * 100, cid, combats[n][1], var) addEvent(doSendDistance, n * 100, cid, getCreatureTarget(cid), combats[n][2]) end return true end
  23. dá erro no distro, porque a função setMagic remove o player, e logo após você executa uma função que o player precisa estar online pra funcionar... basta trocar a ordem das funções do meio. sobre o ot cair, se for isso mesmo que o usuário acima postou, teste deixar o ml como 50 e vê se continua dando crash
  24. Use a script assim: local spellsb = { ["energy explosion"] = 2378, ["gale"] = 2385, ["twisting slash"] = 2376, ["elemental hits"] = 2377, ["meteor"] = 2382, } local spellsbids = {2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398} function onTextEdit(cid,item,newText) if not isInArray(spellsbids, item.itemid) then return true end local spell = spellsb[newText:lower()] if not spell then doPlayerSendCancel(cid, "Spell doesn't exist.") return false end doSendMagicEffect(getThingPos(cid), 30) doTransformItem(item.uid, spell) return false end
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...