Hundanger
Member
Hello, this func is called when another client log in a player already online... EX:
You are online, your friend enter in a same char... This func is called xD
In creatureevent.cpp after this:
paster it:
after this:
paste this:
after this:
paste this:
after this:
paste this:
aftet this:
paste this:
now in creatureevent.h, after this:
paste this:
after this:
paste this:
after this:
paste this:
now in the protocolgame.cpp change this:
for this:
after this:
paste this:
change this:
for this:
now in protocolgame.h change this:
for this:
now recompile your TFS and use it xD...
You are online, your friend enter in a same char... This func is called xD
In creatureevent.cpp after this:
Code:
bool CreatureEvents::playerLogout(Player* player, bool forceLogout)
{
//fire global event if is registered
bool result = true;
for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it)
{
if((*it)->getEventType() == CREATURE_EVENT_LOGOUT && (*it)->isLoaded()
&& !(*it)->executeLogout(player, forceLogout) && result)
result = false;
}
return result;
}
paster it:
Code:
bool CreatureEvents::executeReLogin(Player* player)
{
// onReLogin(cid)
bool result = true;
for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it)
{
if((*it)->getEventType() == CREATURE_EVENT_RELOGIN && (*it)->isLoaded()
&& !(*it)->onReLogin(player) && result)
return false;
}
return result;
}
after this:
Code:
else if(type == "preparedeath")
_type = CREATURE_EVENT_PREPAREDEATH;
paste this:
Code:
else if(type == "relogin")
_type = CREATURE_EVENT_RELOGIN;
after this:
Code:
case CREATURE_EVENT_PREPAREDEATH:
return "onPrepareDeath";
paste this:
Code:
case CREATURE_EVENT_RELOGIN:
return "onReLogin";
after this:
Code:
case CREATURE_EVENT_LOGIN:
paste this:
Code:
case CREATURE_EVENT_RELOGIN:
aftet this:
Code:
uint32_t CreatureEvent::executeLogout(Player* player, bool forceLogout)
{
//onLogout(cid, forceLogout)
if(m_interface->reserveEnv())
{
ScriptEnviroment* env = m_interface->getEnv();
if(m_scripted == EVENT_SCRIPT_BUFFER)
{
env->setRealPos(player->getPosition());
std::stringstream scriptstream;
scriptstream << "local cid = " << env->addThing(player) << std::endl;
scriptstream << "local forceLogout = " << (forceLogout ? "true" : "false") << std::endl;
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", player->getName().c_str());
env->setEvent(desc);
#endif
env->setScriptId(m_scriptId, m_interface);
env->setRealPos(player->getPosition());
lua_State* L = m_interface->getState();
m_interface->pushFunction(m_scriptId);
lua_pushnumber(L, env->addThing(player));
lua_pushboolean(L, forceLogout);
bool result = m_interface->callFunction(2);
m_interface->releaseEnv();
return result;
}
}
else
{
std::clog << "[Error - CreatureEvent::executeLogout] Call stack overflow." << std::endl;
return 0;
}
}
paste this:
Code:
uint32_t CreatureEvent::onReLogin(Player* player)
{
//onReLogin(cid)
if(m_interface->reserveEnv())
{
ScriptEnviroment* env = m_interface->getEnv();
if(m_scripted == EVENT_SCRIPT_BUFFER)
{
env->setRealPos(player->getPosition());
std::stringstream scriptstream;
scriptstream << "local cid = " << env->addThing(player) << std::endl;
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", player->getName().c_str());
env->setEvent(desc);
#endif
env->setScriptId(m_scriptId, m_interface);
env->setRealPos(player->getPosition());
lua_State* L = m_interface->getState();
m_interface->pushFunction(m_scriptId);
lua_pushnumber(L, env->addThing(player));
bool result = m_interface->callFunction(1);
m_interface->releaseEnv();
return result;
}
}
else
{
std::clog << "[Error - CreatureEvent::executePlayer] Call stack overflow." << std::endl;
return 0;
}
}
now in creatureevent.h, after this:
Code:
CREATURE_EVENT_ATTACK,
paste this:
Code:
CREATURE_EVENT_RELOGIN,
after this:
Code:
bool playerLogout(Player* player, bool forceLogout);
paste this:
Code:
bool executeReLogin(Player* player);
after this:
Code:
uint32_t executeLogout(Player* player, bool forceLogout);
paste this:
Code:
uint32_t onReLogin(Player* player);
now in the protocolgame.cpp change this:
Code:
bool ProtocolGame::connect(uint32_t playerId, OperatingSystem_t operatingSystem, uint16_t version)
for this:
Code:
bool ProtocolGame::connect(uint32_t playerId, OperatingSystem_t operatingSystem, uint16_t version, bool reLogin)
after this:
Code:
m_acceptPackets = true;
paste this:
Code:
if(reLogin)
g_creatureEvents->executeReLogin(_player);
change this:
Code:
m_eventConnect = Scheduler::getInstance().addEvent(createSchedulerTask(
1000, boost::bind(&ProtocolGame::connect, this, _player->getID(), operatingSystem, version)));
for this:
Code:
m_eventConnect = Scheduler::getInstance().addEvent(createSchedulerTask(
1000, boost::bind(&ProtocolGame::connect, this, _player->getID(), operatingSystem, version, true)));
now in protocolgame.h change this:
Code:
bool connect(uint32_t playerId, OperatingSystem_t operatingSystem, uint16_t version);
for this:
Code:
bool connect(uint32_t playerId, OperatingSystem_t operatingSystem, uint16_t version, bool reLogin = false);
now recompile your TFS and use it xD...