Ir para conteúdo

Imperius

Membro
  • Registro em

  • Última visita

  1. Doria Louro reagiu a uma resposta no tópico: TFS 0.4 Jogadores não logam
  2. Dá uma olhada se o problema está em creaturescripts. Talvez um "return false" em vez de "return true" em algum script com callback "onLogin".
  3. O propósito é criar uma nova função em creaturescripts que será acionada toda vez que um novo report (CTRL + R) for aberto. Eu implementei para enviar uma notificação no grupo do Telegram, contendo os dados do report. Isso garantirá que os GMs tenham acesso aos reports dos jogadores mesmo quando não estiverem logados, e também evitará que algum report seja perdido caso o jogador saia do servidor. A parte do Telegram é apenas um exemplo. Você pode ajustar o script para executar outras ações desejadas. creatureevent.cpp: Dentro deste arquivo, localize a função: uint32_t CreatureEvent::executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap) abaixo dela, adicione: uint32_t CreatureEvent::executeOpenRuleViolation(Player* player, std::string message) { if (!m_interface->reserveEnv()) { std::clog << "[Error - CreatureEvent::executeOpenRuleViolation] Call stack overflow." << std::endl; return 0; } ScriptEnviroment* env = m_interface->getEnv(); env->setScriptId(m_scriptId, m_interface); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushstring(L, message.c_str()); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } Após, procure por: std::string CreatureEvent::getScriptEventName() const abaixo de: case CREATURE_EVENT_CHANNEL_LEAVE: return "onLeaveChannel"; adicione: case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "onOpenRuleViolation"; Agora, procure por: std::string CreatureEvent::getScriptEventParams() const abaixo de: case CREATURE_EVENT_CHANNEL_LEAVE: return "cid, channel, users"; adicione: case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "cid, message"; Procure por: bool CreatureEvent::configureEvent(xmlNodePtr p) abaixo de: else if(tmpStr == "leavechannel") m_type = CREATURE_EVENT_CHANNEL_LEAVE; adicione: else if(tmpStr == "openruleviolation") m_type = CREATURE_EVENT_OPEN_RULE_VIOLATION; creatureevent.h: Dentro deste arquivo, localize: enum CreatureEventType_t adicione "CREATURE_EVENT_OPEN_RULE_VIOLATION" como o último item de enum CreatureEventType_t Exemplo: enum CreatureEventType_t { // ... CREATURE_EVENT_OPEN_RULE_VIOLATION }; Agora, procure por: uint32_t executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap); abaixo dela, adicione: uint32_t executeOpenRuleViolation(Player* player, std::string message); game.cpp: Dentro deste arquivo, localize: bool Game::playerReportRuleViolation(Player* player, const std::string& text) e substitua por: bool Game::playerReportRuleViolation(Player* player, const std::string& text) { //Do not allow reports on multiclones worlds since reports are name-based if(g_config.getNumber(ConfigManager::ALLOW_CLONES)) { player->sendTextMessage(MSG_INFO_DESCR, "Rule violation reports are disabled."); return false; } cancelRuleViolation(player); boost::shared_ptr<RuleViolation> rvr(new RuleViolation(player, text, time(NULL))); ruleViolations[player->getID()] = rvr; ChatChannel* channel = g_chat.getChannelById(CHANNEL_RVR); if(!channel) return false; for(UsersMap::const_iterator it = channel->getUsers().begin(); it != channel->getUsers().end(); ++it) it->second->sendToChannel(player, SPEAK_RVR_CHANNEL, text, CHANNEL_RVR, rvr->time); CreatureEventList joinEvents = player->getCreatureEvents(CREATURE_EVENT_OPEN_RULE_VIOLATION); for(CreatureEventList::iterator it = joinEvents.begin(); it != joinEvents.end(); ++it) (*it)->executeOpenRuleViolation(player, text); return true; } Agora é só compilar a source. depois em "data > creaturescripts > creaturescripts.xml", adicione: <event type="login" name="loginNotifyRuleViolation" script="notifyRuleViolation.lua"/> <event type="openruleviolation" name="openNotifyRuleViolation" script="notifyRuleViolation.lua"/> em "data > creaturescripts > scripts", crie um arquivo notifyRuleViolation.lua e adicione: function onOpenRuleViolation(cid, message) local config = { token = "", -- Token do seu BOT no Telegram chatId = "" -- ID do chat do Telegram que será enviado a notificação. } local message = "Player: "..getCreatureName(cid).."\n\nReport:\n"..message.."" message = string.gsub(message, "\n", "%%0A") local url = "https://api.telegram.org/bot"..config.token.."/sendMessage" local data = "chat_id="..config.chatId.."&text="..message.."" local curl = io.popen('curl -d "'..data..'" "'..url..'"'):read("*a") return true end function onLogin(cid) registerCreatureEvent(cid, "openNotifyRuleViolation") return true end Demonstração: 1. Jogador abre um novo report (CTRL + R) 2. notifyRuleViolation.lua, definido em creaturescripts.xml, é acionado para enviar uma notificação ao grupo do Telegram.
  4. data > npc > scripts > NomeDoNPC.lua local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) 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 local config = { itemID = 11192, -- ID da Moeda VIP quantity = 100, -- Quantidade de moedas que o jogador precisa ter na mochila minLevel = 8 -- Level minimo que o jogador precisa ter para comprar a promotion } local itemName = getItemNameById(config.itemID) function checkPlayerHavePromotion(cid) local currentVocation = getPlayerVocation(cid) - 4 local vocationPromoted = getPromotedVocation(currentVocation) - 4 return currentVocation == vocationPromoted; end function checkPlayerHaveItems(cid, message, keywords, parameters, node) if (not npcHandler:isFocused(cid)) then return false end if (config.minLevel ~= nil and getPlayerLevel(cid) < config.minLevel) then npcHandler:say('You must reach level '..config.minLevel..' to buy promotion.', cid) return true end if checkPlayerHavePromotion(cid) then npcHandler:say('You are already promoted!', cid) return true end if (not doPlayerRemoveItem(cid, config.itemID, config.quantity)) then npcHandler:say('You do not have enough '..itemName..'!', cid) return true end doPlayerSetVocation(cid, getPlayerVocation(cid) + 4) npcHandler:say(parameters.text, cid) return true end local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, { npcHandler = npcHandler, onlyFocus = true, text = "I can promote you for "..config.quantity.." {"..itemName.."}. Do you want me to promote you?" }) node1:addChildKeyword({'yes'}, checkPlayerHaveItems, { npcHandler = npcHandler, text = "Congratulations! You are now promoted." }) node1:addChildKeyword({'no'}, StdModule.say, { npcHandler = npcHandler, onlyFocus = true, reset = true, text = "Alright then, come back when you are ready." }) npcHandler:addModule(FocusModule:new()) data > npc > NomeDoNPC.xml <?xml version="1.0" encoding="UTF-8"?> <npc name="NomeDoNPC" script="data/npc/scripts/NomeDoNPC.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="160" head="77" body="79" legs="56" feet="115" addons="0"/> </npc>
  5. dá uma conferida no banco de dados se na tabela accounts tem a coluna vipdays ALTER TABLE `accounts` ADD `vipdays` INT(11) NOT NULL
  6. Mikethekingsz reagiu a uma resposta no tópico: ESTOQUE DE ITEM
  7. Mateus Robeerto reagiu a uma resposta no tópico: Error script boss
  8. Under reagiu a uma resposta no tópico: Error script boss
  9. Doidodepeda reagiu a uma resposta no tópico: Error script boss
  10. Imperius postou uma resposta no tópico em Suporte Tibia OTServer
    data > creaturescripts > creaturescripts.xml <event type="kill" name="killTheBoss" event="script" value="killTheBoss.lua"/> <event type="login" name="killTheBossLogin" event="script" value="killTheBoss.lua"/> data > creaturescripts > scripts > killTheBoss.lua local config = { monsters = {"Boss Hits"}, rewards = { {itemID = 8300, chanceToGainInPercent = 10, quantity = 1}, {itemID = 8301, chanceToGainInPercent = 20, quantity = 1}, {itemID = 8302, chanceToGainInPercent = 30, quantity = 1}, {itemID = 8303, chanceToGainInPercent = 40, quantity = 1}, }, effect = 27, } -- Função para selecionar um item com base na porcentagem function selectRandomItem() local totalChance = 0 for _, reward in pairs(config.rewards) do totalChance = totalChance + reward.chanceToGainInPercent end local randomValue = math.random(1, totalChance) local cumulativeChance = 0 for _, reward in pairs(config.rewards) do cumulativeChance = cumulativeChance + reward.chanceToGainInPercent if randomValue <= cumulativeChance then return reward end end end function onKill(cid, target, lastHit) if isPlayer(cid) and isMonster(target) then if getCreatureMaster(target) ~= nil then return true end local monsterNameKilled = getCreatureName(target) if isInArray(config.monsters, monsterNameKilled) then local selectedItem = selectRandomItem() doPlayerAddItem(cid, selectedItem.itemID, selectedItem.quantity) doSendMagicEffect(getCreaturePosition(cid), config.effect) end end return true end function onLogin(cid) registerCreatureEvent(cid, "killTheBoss") return true end
  11. JowL reagiu a uma resposta no tópico: [TFS 0.4] Treasure Chest Lottery + PHP Page
  12. qual versão / servidor vc tá usando? Testei aqui sem erro na distro. única coisa que falta é colocar "return true" no final da function para os players conseguir logar no servidor
  13. data > actions > scripts > enchantmentSystem.lua: function onUse(cid, item, frompos, item2, topos) local playerLocation = getCreaturePosition(cid) local weaponData = { -- ID da arma | ID do item de encantamento | quantidade do item de encantamento (opcional) | ID do item que a arma será transformada. {weaponId = 7735, enchantmentId = 2361, transformId = 2453}, {weaponId = 6132, enchantmentId = 2159, amountEnchantment = 10, transformId = 2646} } local positions = { weaponTable = {x = 32352, y = 31912, z = 7}, -- Onde o jogador deverá colocar a arma. enchantmentTable = {x = 32354, y = 31912, z = 7} -- Onde o jogador deverá colocar o item de encantamento. } function check() for _, data in pairs(weaponData) do local weapon = getTileItemById(positions.weaponTable, data.weaponId) local enchantment = getTileItemById(positions.enchantmentTable, data.enchantmentId) if weapon.itemid == data.weaponId and enchantment.itemid == data.enchantmentId then local amountEnchantment = enchantment.type and data.amountEnchantment or 1 if doRemoveItem(enchantment.uid, amountEnchantment) then doRemoveItem(weapon.uid, 1) doPlayerAddItem(cid, data.transformId, 1) doSendMagicEffect(playerLocation, 39) return true end end end end if not check() then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sem itens necessários para o encantamento.") doSendMagicEffect(playerLocation, CONST_ME_POFF) end return true end data > actions > actions.xml: <!-- Coloque a sua ActionID da alavanca --> <action actionid="11404" event="script" value="enchantmentSystem.lua" />
  14. Seria tipo isso? data > creaturescripts > creaturescripts.xml <event type="login" name="playerTextEffect" event="script" value="playerTextEffect.lua"/> data > creaturescripts > scripts > playerTextEffect.lua local config = { storage = 808072, -- Storage que o player precisa ter. colorsText = {10, 30, 50, 70}, -- valores que o player poderá ter no storage (cada valor corresponde a uma coloração diferente de texto) texts = {"' . ,", ". ' ,", "' . ,", ", ' ."} -- Textos que ficará saindo do jogador. } function ariseText(cid) if not isPlayer(cid) then return true end local playerColorTextEffect = getPlayerStorageValue(cid, config.storage) if not isInArray(config.colorsText, playerColorTextEffect) then return true end local playerPosition = getCreaturePosition(cid) local randomTextEffect = config.texts[math.random(1, #config.texts)] doSendAnimatedText(playerPosition, randomTextEffect, playerColorTextEffect) doSendMagicEffect(playerPosition, CONST_ME_MAGIC_GREEN) -- Efeito mágico adicionado addEvent(ariseText, 1000, cid) return true end function onLogin(cid) ariseText(cid) return true end
  15. Exemplo: data > spells > spells.xml <instant name="NOME DA MAGIA" words="NOME DA MAGIA" lvl="100" mana="160" prem="0" selftarget="1" exhaustion="60000" needlearn="0" event="script" value="support/nomedamagia.lua"> <vocation id="1"/> <vocation id="8"/> </instant> data > spells > scripts > support > nomedamagia.lua function teleportPlayer(player, position) doTeleportThing(player, position) doSendMagicEffect(position, CONST_ME_TELEPORT) end function onCastSpell(cid, var) local playerPosition = getCreaturePosition(cid) addEvent(teleportPlayer, 5000, cid, playerPosition) doSendMagicEffect(playerPosition, 13) return true end
  16. seria tipo isso? Não entendi mt bem como será feito p/ nascer boss, então fiz uma talkaction, aí é só vc adapta da maneira que quiser. data > lib > spawnBoss.lua BOSS_SPAWN_CONFIG = { bosses = { ["Boss Thdagger"] = { -- Nome do Boss. position = { spawnBoss = {x = 263, y = 349, z = 7 }, -- Onde o boss nascerá. openTP = {x = 0, y = 0, z = 0}, -- Onde o TP aparecerá. locationTP = {x = 0, y = 0, z = 0} -- Onde o TP levará o jogador. }, timeInSeconds = { closeTP = 60 -- segundos p/ fechar o TP após o boss ter nascido. } } -- Adicione outros bosses aqui se quiser ... } } -- Mostrará a contagem regressiva em cima do TP -- function spawnBossCountdownOnTeleport(bossCreature, teleport, timeToCloseTP) local bossName = getCreatureName(bossCreature); if not bossName then doRemoveItem(getTileItemById(teleport, 1387).uid) doSendMagicEffect(teleport, CONST_ME_POFF) return true end local timeToCloseTP = tonumber(timeToCloseTP) - 1; if timeToCloseTP == 0 then doRemoveItem(getTileItemById(teleport, 1387).uid) doSendMagicEffect(teleport, CONST_ME_POFF) return true end doSendAnimatedText(teleport, timeToCloseTP, 725) addEvent(spawnBossCountdownOnTeleport, 1000, bossCreature, teleport, timeToCloseTP); return true end data > talkactions > scripts > spawnBoss.lua function onSay(cid, words, param, channel) local bossName = param; if not BOSS_SPAWN_CONFIG.bosses[bossName] then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Boss nao encontrado! Escreva o nome corretamente, incluindo letras maiuscula/minuscula.") return true end local bossCreature = doCreateMonster(bossName, BOSS_SPAWN_CONFIG.bosses[bossName].position.spawnBoss) doCreateTeleport(1387, BOSS_SPAWN_CONFIG.bosses[bossName].position.locationTP, BOSS_SPAWN_CONFIG.bosses[bossName].position.openTP) spawnBossCountdownOnTeleport(bossCreature, BOSS_SPAWN_CONFIG.bosses[bossName].position.openTP, BOSS_SPAWN_CONFIG.bosses[bossName].timeInSeconds.closeTP); doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "BOSS: "..bossName.." foi criado!") return true end data > talkactions > talkactions.xml <!-- Spawn Boss --> <talkaction access="5" words="/boss" script="spawnBoss.lua"/> /boss nome do boss
  17. data > talkactions > scripts > online.lua function onSay(cid, words, param, channel) local quantityOnline = 0 for _, pid in ipairs(getPlayersOnline()) do if getPlayerAccess(pid) < 4 then quantityOnline = quantityOnline + 1 local playerReset = getPlayerStorageValue(pid, 54676) playerReset = (playerReset > 0) and playerReset or 0 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, ""..getCreatureName(pid).." ["..getPlayerLevel(pid).."] - "..getPlayerVocationName(pid).." | Resets: "..playerReset.."") end end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, quantityOnline.." Player(s) online") return true end
  18. aqui funcionou de boa Só que tem um porém: o NPC só vai liberar a opção de "buy" se você tiver a mesma quantidade de gold na backpack em relação ao preço do item em moeda vip.
  19. Olá, pessoal! Acabei encontrando um script que tinha feito a um tempo atrás. Estou compartilhando aqui para quem quiser usar ou melhorar. É bem parecido com os outros sistemas de roleta, igual deste tópico: https://tibiaking.com/forums/topic/101557-action-cassino-roleta-de-items/ Como funciona? O "Treasure Chest" é um item custom, onde o jogador têm a possibilidade de ganhar itens raros ou bem meia boca. Tudo dependerá da sorte. O jogador precisa tacar o treasure chest na bancada e acionar a alavanca. O treasure chest irá se transformar em vários itens de forma randômica no qual o jogador poderá ou não ganhar. No final, apenas um item é entregue ao jogador. Para entender melhor o seu funcionamento, segue o GIF abaixo: em data > actions > actions.xml em data > actions > scripts > crie um arquivo chamado leverTreasureChest.lua no banco de dados do servidor, adicione o seguinte código em "SQL": Também estou disponibilizando uma página PHP, para quem quiser usar no site do servidor. Na página tem informações sobre o funcionamento, quais são os possíveis prêmios e a lista de jogadores que ganharam os itens raros. Espero ter ajudado de alguma forma! : ) treasure_chest.php
  20. Imperius postou uma resposta no tópico em Suporte Tibia OTServer
    Você pode fazer algo do tipo: function calculaFimVip(storageValue) -- diferença em segundos local diferenca = storageValue - os.time() -- conversão em dias local diasRestantes = math.floor(diferenca / 86400) + 1 if diasRestantes >= 1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "voce ainda tem "..diasRestantes.." dia(s) de VIP") else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "seu VIP acabou") end end calculaFimVip(getPlayerStorageValue(cid, 55489))
  21. Olá! Fiz uma adaptação no evento "SafeZone" criado e disponibilizado aqui no TK por @Movie e @luanluciano93. Agora o evento é compatível para TFS 0.4. IMPORTANTE: Como mencionado anteriormente, o evento foi criado por "Movie" e "LuanLuciano93". Eu (imperius) APENAS ADAPTEI para funcionar em TFS 0.4. Todos os créditos do evento vão para os criadores originais. Além disso, é importante alertar que esta adaptação não está 100%. Abaixo está todo o processo explicando como configurar e rodar o evento em seu servidor! Vídeo demonstrativo: em data > lib > crie um arquivo chamado safeZone.lua data > globalevents > globalevents.xml em data > globalevents > scripts > crie um arquivo chamado safeZoneEvent.lua data > movements > movements.xml em data > movements > scripts > crie um arquivo chamado safeZoneMovement.lua por fim, vá até o banco de dados do seu servidor e adicione o seguinte código em "SQL" É isso! Espero ter ajudado o pessoal do TFS 0.4

Informação Importante

Confirmação de Termo