Ir para conteúdo

Líderes

Conteúdo Popular

Exibindo conteúdo com a maior reputação em 02/29/24 em todas áreas

  1. 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.
  2. 1 ponto
    Não sai a palavra do mesmo geito do outro, e não cura tambe, e aparece esse erro na distro: [27/07/2015 18:33:40] [Error - Spell Interface] [27/07/2015 18:33:41] data/spells/scripts/curavida.lua:onCastSpell [27/07/2015 18:33:41] Description: [27/07/2015 18:33:41] data/spells/scripts/curavida.lua:6: attempt to call global 'getPlayerMaxHealth' (a nil value) [27/07/2015 18:33:41] stack traceback: [27/07/2015 18:33:41] data/spells/scripts/curavida.lua:6: in function <data/spells/scripts/curavida.lua:5> voce por acaso conseguiria fazer a uh heala por % do hp total? tamben serviria no caso se não conseguisse uma spell assim ae pessoal consegui um valeu por tentarem me ajudar. function onCastSpell(cid, item, fromPosition, itemEx, toPosition) local hpmax = getCreatureMaxHealth(cid) local min = 15.0 -- this means 15% minimum healing local max = 15.0 -- this means 15% maximum healing local hp_add = math.random((hpmax * (min/100)), (hpmax * (max/100))) if(hasCondition(cid, CONDITION_EXHAUST)) then doSendMagicEffect(getThingPos(cid), CONST_ME_POFF) doPlayerSendCancel(cid, "You are exhausted") return true end doCreatureAddHealth(cid, hp_add) doSendMagicEffect(getThingPos(cid), 32) doSendAnimatedText(getPlayerPosition(cid),"+"..hp_add.."", TEXTCOLOR_GREEN) return true end
Líderes está configurado para São Paulo/GMT-03:00

Informação Importante

Confirmação de Termo