Qualquer conteúdo feito do zero é lucro chapa, e o que pode ser inútil para alguns pode ser útil para outros. Gostei, depois vou da uma lida no código.
- Forums
- OTServ
- Recursos
- Linguagens de Programação
- [CreatureEvent] onTalk(cid, type, text, position)
ME
[CreatureEvent] onTalk(cid, type, text, position)
By meubk, 22 de jan. de 2014 in Linguagens de Programação
ontalk
xotservx
otserv
tibia
script
5
1.4k
info
Group: Herói
Joined: 12/03/11
Posts: 1.9k
Reputation: +284
Gender: Masculino
Tibia Character: Nokte

22 de janeiro de 2014 às 15:00
info
Group: Conde
Joined: 20/09/12
Posts: 711
Reputation: +86
Tibia Character: noé

22 de janeiro de 2014 às 15:07
poisé cara, o código feito do zero, tem lucro como o Beeki disse.
info
Group: Colaborador
Joined: 27/12/10
Posts: 271
Reputation: +87
Gender: Masculino

22 de janeiro de 2014 às 15:40
Que lixo miiller toma vergonha ! aehEUIAHEIUEHAIUEHAE
Tá manjando (y)




info
Group: Visconde
Joined: 21/04/08
Posts: 311
Reputation: +257
onTalk(cid, type, text, position)
Estava de boa no meu serviço, sem nada pra fazer, então resolvi criar essa função ai, não sei se vai ter utilidade para alguém, mais ta ae, ela retorna tudo aquilo que foi dito pela criatura, o tipo, e a posição.
Vamos as códigos:
em creatureevent.h :
em creatureevent.cpp :
depois de:
--
procure pela função :
depois que a função terminar adicione esta função:
uint32_t CreatureEvent::executeTalk(Creature* creature, MessageClasses type, const std::string& text, const Position& position) { //onTalk(cid, type, text, pos) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local type = " << (uint32_t)type << std::endl; scriptstream << "local text = " << text << std::endl; env->streamPosition(scriptstream, "position", position, 0); if(m_scriptData) scriptstream << *m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[35]; sprintf(desc, "%s", creature->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, (uint32_t)type); lua_pushstring(L, text.c_str()); LuaInterface::pushPosition(L, position, 0); bool result = m_interface->callFunction(4); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::executeTalk] Call stack overflow." << std::endl; return 0; } }em game.cpp :
procure a função:
e depois de:
Player* player = creature->getPlayer(); if(player && player->isAccountManager() && !ghostMode) { player->manageAccount(text); return true; }adicione isto:
bool deny = false; CreatureEventList talkEvents = creature->getCreatureEvents(CREATURE_EVENT_TALK); for(CreatureEventList::iterator it = talkEvents.begin(); it != talkEvents.end(); ++it) { if(!(*it)->executeTalk(creature, type, text, creature->getPosition())) deny = true; } if(deny) return false;e pronto ja vai estar funcionando !
uma das utilidades dessa função é não permitir divulgação de outros server, mais pra qm tem criatividade da pra fazer mtas outras coisas, o exemplo de divulgação:
local linkProibidos = {"no-ip.com", "servergame.com", "sytes.net"} function onTalk(cid, type, text, position) for _, link in pairs(linkProibidos) do if text:find(link) then return false end end return true enda tag pro xml fica:
bom, não sei se alguém ja fez essa função mais eu sei q essa é 100% de minha autoria, e eu não permito que ela seja postada em outro forum a não ser o xtibia !
eu testei em um tfs 0.4
obrigado a todos, xotservx (miillerdomingues)
bj