Ir para conteúdo

zipter98

Membro
  • Registro em

  • Última visita

Tudo que zipter98 postou

  1. zipter98 postou uma resposta no tópico em Suporte Tibia OTServer
    Abaixo de: local x = pokes[pokemon] coloque: if #getCreatureSummons(cid) > 0 then return doPlayerSendCancel(cid, "You're already using a pokemon.") end
  2. local config = { [9] = 35; -- [VOCATION] = CORES; [10] = 66; [11] = 144; [12] = 205; } function effectText(cid) local texts, eff = "´ . ," for vocation, color in pairs(config) do if getPlayerVocation(cid) == vocation then eff = color break end end if eff then doSendAnimatedText(getThingPos(cid), texts, eff) addEvent(function() if isPlayer(cid) then effectText(cid) end end, 1000) end end function onLogin(cid) effectText(cid) return true end
  3. Como Lua é case-sensitive, letras maiúsculas e minúsculas fazem diferença no nome de uma função. Troque: player:SetStorageValue(cid, rankStorage, 0) por: player:setStorageValue(cid, rankStorage, 0)
  4. Não sei como esse NPC vai funcionar, nem conheço as funções desta versão, entretanto escrevi um pequeno bloco de código como exemplo do que poderia ser feito: local letter_id = xxx --ID da carta. local text = "texto" --Texto da carta. if msgcontains(msg, "player") then selfSay("Tell me the player's name.") talkState[talkUser] = 1 elseif talkState[talkUser] == 1 then local player = getPlayerByName(msg) talkState[talkUser] = 0 if isPlayer(player) then local letter = doCreateItemEx(letter_id) doSetItemText(letter, text) SendItemTo(msg, letter, getPlayerTown(player)) else local query = db.getResult("SELECT town_id FROM players WHERE name = "..msg) if query:getID() == -1 then return selfSay("This player doesn't exist.") and query:free() end local letter = doCreateItemEx(letter_id) doSetItemText(letter, text) SendItemTo(msg, letter, query:getDataInt("town_id")) query:free() end selfSay("You sent "..msg.." a letter.") end O jogador diria "player" ao NPC, e depois diria o nome do player que receberia a carta.
  5. local config = { items = { {position = {x = x, y = y, z = z}, itemid = xxx}, --{position = posição_do_item, itemid = id_do_item}, {position = {x = x, y = y, z = z}, itemid = xxx}, {position = {x = x, y = y, z = z}, itemid = xxx}, --etc }, players = { {position = {x = x, y = y, z = z}, toPos = {x = x, y = y, z = z}, vocation = {xxx, xxx, ...}}, --{position = posição_do_jogador, toPos = posição_final, vocation = ID_das_vocações}, {position = {x = x, y = y, z = z}, toPos = {x = x, y = y, z = z}, vocation = {xxx, xxx, ...}}, {position = {x = x, y = y, z = z}, toPos = {x = x, y = y, z = z}, vocation = {xxx, xxx, ...}}, --etc } } function onUse(cid) local items, quest_players = {}, {} for _, item in pairs(config.items) do local position_item = getTileItemById(item.position, item.itemid).uid if position_item > 0 then table.insert(items, position_item) else return doPlayerSendCancel(cid, "There's missing some item(s).") end end for _, player in pairs(config.players) do local pid = getTopCreature(player.position).uid if isPlayer(pid) and isInArray(player.vocation, getPlayerVocation(pid)) then table.insert(quest_players, pid) else return doPlayerSendCancel(cid, "There's some player(s) missing or there's some wrong vocation(s).") end end for i = 1, #items do doRemoveItem(items[i]) end for i = 1, #quest_players do doPlayerSendTextMessage(quest_players[i], MESSAGE_INFO_DESCR, "Good luck at the quest!") doTeleportThing(quest_players[i], config.players[i].toPos) end return true end
  6. No código do NPC, você está usando como objeto dos metamétodos getStorageValue e setStorageValue uma variável inexistente (player). Confesso não programar nas novas versões do TFS, mas tente: local choose = {} local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) local player = Player(cid) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid if isInArray({"task", "tasks"}, msg:lower()) then selfSay("Here.", cid) taskNPCuid = getNpcCid() if player:getStorageValue(cid, 32150) < 0 then player:setStorageValue(cid, 32150, 0) end return taskWindow:sendToPlayer(cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
  7. local config = { rockid = 1304, --ID da pedra. time = xxx, --Tempo, em minutos, para a pedra voltar. pos = {x = x, y = y, z = z} --Posição da pedra. } function onUse(cid) local rock = getTileItemById(config.pos, config.rockid).uid if rock < 1 then return doPlayerSendCancel(cid, "The stone was already removed.") end doRemoveItem(rock) addEvent(doCreateItem, config.time * 60 * 1000, config.rockid, 1, config.pos) return true end
  8. zipter98 postou uma resposta no tópico em Suporte Tibia OTServer
    É um erro ocasionado por um moveveent (onStepIn/Out, pelo que parece) que é executado sem parar. Como se fosse um teleporte localizado em um tile que levasse ao mesmo tile, teleportando o jogador infinitamente. Talvez seja algum problema em um código ou até mesmo em itens no próprio mapa (uma escada, talvez).
  9. function onSay(cid, words, param) local t = param:explode(",") local pid, itemid, count = getPlayerByName(t[1]), tonumber(t[2]), tonumber(t[3]) or 1 if not isPlayer(pid) then return doPlayerSendCancel(cid, "This player doesn't exist or is offline.") elseif not itemid then return doPlayerSendCancel(cid, "Write a existent item.") end local item = doCreateItemEx(itemid, count) doPlayerSendTextMessage(cid, 27, "You sent "..count.."x "..getItemNameById(itemid).." to "..getCreatureName(pid)..".") doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_ORANGE, "You received "..count.."x "..getItemNameById(itemid)..".") doPlayerSendMailByName(getCreatureName(pid), item) return true end ops, mandaram outra versão acima mais completa. w/e, se não funcionar, taí.
  10. Isso é chamado de identação ou indentação. Em Lua não é algo obrigatório, entretanto é recomendado para tornar o código mais elegante, legível e organizado.
  11. function onSay(cid, words, param) local t = param:explode(", ") local pid = getPlayerByName(t[1]) if isPlayer(pid) then doSetItemText(doPlayerAddItem(pid, 8761), t[2] or "Nothing.") end return true end
  12. Como indiquei no outro fórum, troque: doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid).." ref "..config.reflectBonus.."%") por: doItemSetAttribute(itemEx.uid, "name", getItemName(itemEx.uid).." ref "..config.reflectBonus.."%")
  13. Tag: <!-- Coloque o time 5 minutos antes do horário previsto para o servidor ser fechado --> <globalevent name="CloseServer" time="11:55" event="script" value="nome_do_arquivo.lua"/> Código: function countdownForClose(times) if times <= 0 then doSetGameState(GAMESTATE_CLOSED) else broadcastMessage("O servidor irá fechar em "..times.." minuto(s).") addEvent(countdownForClose, 60000, times - 1) end end function onTime() countdownForClose(5) return true end
  14. Troque: doSendAnimatedText(getThingPos(cid), value, combats[combat].cor) por: doSendAnimatedText(getThingPos(cid), "-"..value, combats[combat].cor) troque: doSendAnimatedText(getThingPos(cid), valor, races[getMonsterInfo(getCreatureName(cid)).race].cor) por: doSendAnimatedText(getThingPos(cid), "-"..valor, races[getMonsterInfo(getCreatureName(cid)).race].cor) troque: doSendAnimatedText(getThingPos(cid), valor, combats[damageCombat].cor) por: doSendAnimatedText(getThingPos(cid), "-"..valor, combats[damageCombat].cor)
  15. Isso se não me engano é configurado em items.xml.
  16. Ops, esqueci de verificar se o item existe. Corrigido.
  17. Qual o erro do statschange? Modifiquei a action para aceitar boots, helmets e etc.
  18. O evento é onStatsChange, não onLogin. Tag: <event type="statschange" name="reflect" event="script" value="reflect.lua"/> O creatureevent foi alterado e foram colocadas algumas proteções para evitar o erro que aconteceu com o 574747. Também corrigi uma bobeira na action (aproveitei e coloquei o que você pediu - o nome do item ser modificado). Os valores da tabela noReflect são esses: WEAPON_NONE = 0 WEAPON_SWORD = 1 WEAPON_CLUB = 2 WEAPON_AXE = 3 WEAPON_SHIELD = 4 WEAPON_DIST = 5 WEAPON_WAND = 6 WEAPON_AMMO = 7 WEAPON_FIST = 8
  19. Como não jogo Tibia, não conheço este sistema de guerra. O que deve ser feito para ele acabar? Poderia disponibilizar o tópico em que você encontrou este sistema? Se o tempo determinado acabar e a guerra não tiver acontecido, o que acontecerá com os jogadores que estavam na área?
  20. Action: local config = { reflectBonus = 2, --Bônus de reflect, em %. failChance = 50, --Chance de falhar, em porcentagem. types = {"armor", "legs", "helmet", "boots"}, noReflect = {1, 2, 3, 5, 6} --Tipos de armamento bloqueados (valores podem ser conferidos em 000-constant.lua, data/lib) } function onUse(cid, item, fromPos, itemEx, toPos) if itemEx.itemid < 100 then return doPlayerSendCancel(cid, "Use this in valid itens.") elseif isInArray(config.noReflect, getItemWeaponType(itemEx.uid)) then return doPlayerSendCancel(cid, "Use this in valid itens.") elseif getItemAttribute(itemEx.uid, "reflect") then return doPlayerSendCancel(cid, "This item has already a reflect bonus.") elseif math.random(1, 100) > config.failChance then return doPlayerSendTextMessage(cid, 27, "Sorry, your item didn't get a reflect bonus. Good luck at the next try! =]"), doRemoveItem(item.uid, 1) end local checkItemName for i = 1, #config.types do if getItemNameById(itemEx.itemid):find(config.types[i]) then checkItemName = true break end end if not checkItemName then return doPlayerSendCancel(cid, "Use this in valid itens.") end doPlayerSendTextMessage(cid, 27, "Congratulations, now your item has a reflect bonus of "..config.reflectBonus.."%!") doItemSetAttribute(itemEx.uid, "reflect", config.reflectBonus) doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid).." ref "..config.reflectBonus.."%") doRemoveItem(item.uid, 1) return true end Creaturescript (não se esqueça de registrar o evento em login.lua): function onStatsChange(cid, attacker, type, combat, value) if isPlayer(cid) and isCreature(attacker) and type == STATSCHANGE_HEALTHLOSS then local bonusReflect = 0 for i = 1, 10 do local item = getPlayerSlotItem(cid, i).uid if item > 0 and getItemAttribute(item, "reflect") then bonusReflect = bonusReflect + getItemAttribute(item, "reflect") end end if bonusReflect > 0 then local damage = value * bonusReflect / 100 doSendAnimatedText(getThingPos(attacker), -damage, COLOR_RED) doCreatureAddHealth(attacker, -damage) end end return true end
  21. Não deve ser isso, mas este evento não precisa ser registrado em login.lua.
  22. Mesmo falhando o bônus no equipamento, o jogador ainda poderá usar o item nele (para tentar obter o bônus)?
  23. Ops, burrice minha. Creatureevent corrigido.

Informação Importante

Confirmação de Termo