• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Msg only for access >=3

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,210
Solutions
35
Reaction score
207
I need the mensage "You are visible again." and "You are now invisible."
Only be sent to those players who have access greater than or equal to 3, thank you!
TFS 0.4

Code:
bool TalkAction::ghost(Creature* creature, const std::string& cmd, const std::string& param)
{
    Player* player = creature->getPlayer();
    if(!player)
        return false;
    if(player->hasFlag(PlayerFlag_CannotBeSeen))
    {
        player->sendTextMessage(MSG_INFO_DESCR, "Command disabled for players with special, invisibility flag.");
        return true;
    }
    SpectatorVec::iterator it;
    SpectatorVec list = g_game.getSpectators(player->getPosition());
    Player* tmpPlayer = NULL;
    Condition* condition = NULL;
    if((condition = player->getCondition(CONDITION_GAMEMASTER, CONDITIONID_DEFAULT, GAMEMASTER_INVISIBLE)))
    {
        player->sendTextMessage(MSG_INFO_DESCR, "You are visible again.");
        IOLoginData::getInstance()->updateOnlineStatus(player->getGUID(), true);
        for(AutoList<Player>::iterator pit = Player::autoList.begin(); pit != Player::autoList.end(); ++pit)
        {
            if(!pit->second->canSeeCreature(player))
                pit->second->notifyLogIn(player);
        }
        for(it = list.begin(); it != list.end(); ++it)
        {
            if((tmpPlayer = (*it)->getPlayer()) && !tmpPlayer->canSeeCreature(player))
                tmpPlayer->sendMagicEffect(player->getPosition(), MAGIC_EFFECT_TELEPORT);
        }
        player->removeCondition(condition);
        g_game.internalCreatureChangeVisible(creature, VISIBLE_GHOST_APPEAR);
    }
    else if((condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_GAMEMASTER, -1, 0, false, GAMEMASTER_INVISIBLE)))
    {
        player->addCondition(condition);
        g_game.internalCreatureChangeVisible(creature, VISIBLE_GHOST_DISAPPEAR);
        for(it = list.begin(); it != list.end(); ++it)
        {
            if((tmpPlayer = (*it)->getPlayer()) && !tmpPlayer->canSeeCreature(player))
                tmpPlayer->sendMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        }
        for(AutoList<Player>::iterator pit = Player::autoList.begin(); pit != Player::autoList.end(); ++pit)
        {
            if(!pit->second->canSeeCreature(player))
                pit->second->notifyLogOut(player);
        }
        IOLoginData::getInstance()->updateOnlineStatus(player->getGUID(), false);
        if(player->isTrading())
            g_game.internalCloseTrade(player);
        player->clearPartyInvitations();
        if(player->getParty())
            player->getParty()->leave(player);
        player->sendTextMessage(MSG_INFO_DESCR, "You are now invisible.");
    }
    return true;
}
 
Last edited:
Solution
edited, sry!
No problem, it just makes it way easier and faster for people to reply with accurate info :)

You can use the following function to get a player's access group (as defined in player.h);
C++:
player->getAccess()

For example;
C++:
// line 17
if( player->getAccess() >= 3)
player->sendTextMessage(MSG_INFO_DESCR, "You are now visible again.");

// line 51
if( player->getAccess() >= 3)
player->sendTextMessage(MSG_INFO_DESCR, "You are now invisible.");
edited, sry!
No problem, it just makes it way easier and faster for people to reply with accurate info :)

You can use the following function to get a player's access group (as defined in player.h);
C++:
player->getAccess()

For example;
C++:
// line 17
if( player->getAccess() >= 3)
player->sendTextMessage(MSG_INFO_DESCR, "You are now visible again.");

// line 51
if( player->getAccess() >= 3)
player->sendTextMessage(MSG_INFO_DESCR, "You are now invisible.");
 
Last edited:
Solution
Back
Top