potinho
Intermediate OT User
Hello everyone, everything good?
I saw a common question but I couldn't find a way to remove it in the sources, without having to do some LUA script. I managed to get the battle to be removed when the player enters a Protection Zone, but if he leaves soon after, the battle blocks the char again. Is there any way to take out the battle when the player steps on a PZ?
Here's follow:
Im fighting
Goes to a PZ (battle gone and i can log out)
And after this, when i go out, battle lock returns:
Follow my function who removes battle in PZ:
I saw a common question but I couldn't find a way to remove it in the sources, without having to do some LUA script. I managed to get the battle to be removed when the player enters a Protection Zone, but if he leaves soon after, the battle blocks the char again. Is there any way to take out the battle when the player steps on a PZ?
Here's follow:
Im fighting
Goes to a PZ (battle gone and i can log out)
And after this, when i go out, battle lock returns:
Follow my function who removes battle in PZ:
C++:
bool ProtocolGame::logout(bool displayEffect, bool forceLogout)
{
//dispatcher thread
if(!player)
return false;
if(player->hasCondition(CONDITION_EXHAUST, 1))
{
player->sendTextMessage(MSG_STATUS_SMALL, "You have to wait a while.");
return false;
}
if(!player->isRemoved())
{
if(!forceLogout)
{
if(!IOLoginData::getInstance()->hasCustomFlag(player->getAccount(), PlayerCustomFlag_CanLogoutAnytime))
{
if(player->getTile()->hasFlag(TILESTATE_NOLOGOUT))
{
if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EXHAUST, 500, 0, false, 1))
player->addCondition(condition);
player->sendCancelMessage(RET_YOUCANNOTLOGOUTHERE);
return false;
}
if(player->getZone() != ZONE_PROTECTION && player->hasCondition(CONDITION_INFIGHT))
{
if(Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_EXHAUST, 500, 0, false, 1))
player->addCondition(condition);
player->sendCancelMessage(RET_YOUMAYNOTLOGOUTDURINGAFIGHT);
return false;
}
if(!g_creatureEvents->playerLogout(player, false)) //let the script handle the error message
return false;
}
else
g_creatureEvents->playerLogout(player, true);
}
else if(!g_creatureEvents->playerLogout(player, true))
return false;
if(displayEffect && !player->isGhost())
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
}
player->client->clear(true);
disconnect();
if(player->isRemoved())
return true;
return g_game.removeCreature(player);
}