• 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!

( REMOVE ) Move through other players!

Hashirama479

World of Ninja
Joined
Dec 19, 2016
Messages
536
Solutions
6
Reaction score
74
As the title says how can I remove so players cant move through other players? I know its in source but I dont know the code which I need xD im using tfs 0.4 rev3777

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    if((((g_game.getWorldType() == WORLDTYPE_OPTIONAL && !player->isEnemy(this, true) &&
        player->getVocation()->isAttackable()) || player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) || (player->getVocation()->isAttackable() &&
        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))) && player->getTile()->ground &&
        Item::items[player->getTile()->ground->getID()].walkStack) && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
        || player->getAccess() <= getAccess()))
        return true;

    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
Last edited by a moderator:
Solution
my quest was if I need to replace this part
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(!creature)
        return true;

    if(creature == this)
        return false;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    if(g_game.getWorldType() == WORLD_TYPE_NO_PVP && player->getTile()->ground
        && player->getTile()->ground->getID() != ITEM_GLOWING_SWITCH)
        return true;

    return player->isGhost() && getGhostAccess() < player->getGhostAccess();
}
with this part
Looks like he just took an old canWalkthrough code which will give you undesired results. For one you won't be able to walk through ghost players. Aside from that it's actually allowing...
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
       (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;
   else
        return true;

}
 
Last edited by a moderator:
Do I need to edit this part?

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;
 
Last edited by a moderator:
Do I need to edit this part?

Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;
you have to replace that function... find and replace
 
you have to replace that function... find and replace

my quest was if I need to replace this part
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(!creature)
        return true;

    if(creature == this)
        return false;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    if(g_game.getWorldType() == WORLD_TYPE_NO_PVP && player->getTile()->ground
        && player->getTile()->ground->getID() != ITEM_GLOWING_SWITCH)
        return true;

    return player->isGhost() && getGhostAccess() < player->getGhostAccess();
}
with this part
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
       (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;
   else
        return true;

}
 
Last edited by a moderator:
my quest was if I need to replace this part
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(!creature)
        return true;

    if(creature == this)
        return false;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    if(g_game.getWorldType() == WORLD_TYPE_NO_PVP && player->getTile()->ground
        && player->getTile()->ground->getID() != ITEM_GLOWING_SWITCH)
        return true;

    return player->isGhost() && getGhostAccess() < player->getGhostAccess();
}
with this part
yes
 
my quest was if I need to replace this part
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(!creature)
        return true;

    if(creature == this)
        return false;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    if(g_game.getWorldType() == WORLD_TYPE_NO_PVP && player->getTile()->ground
        && player->getTile()->ground->getID() != ITEM_GLOWING_SWITCH)
        return true;

    return player->isGhost() && getGhostAccess() < player->getGhostAccess();
}
with this part
Looks like he just took an old canWalkthrough code which will give you undesired results. For one you won't be able to walk through ghost players. Aside from that it's actually allowing you to pass through players (returning true if creature is player??).

Try this:
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(hasCustomFlag(PlayerCustomFlag_CanWalkthrough))
        return true;

    if(!creature)
        return true;

    if(creature == this)
        return false;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    return player->isGhost() && getGhostAccess() < player->getGhostAccess();
}
 
Last edited:
Solution
Looks like he just took an old canWalkthrough code which will give you undesired results. For one you will be able to walk through ghost players. Aside from that it's actually allowing you to pass through players (returning true if creature is player??).

Try this:
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(!creature)
        return true;

    if(creature == this)
        return false;

    const Player* player = creature->getPlayer();
    if(!player)
        return false;

    return player->isGhost() && getGhostAccess() < player->getGhostAccess();
}

Although I still think it might not work flawlessly. Which was the original canWalkthrough from your sources?

It did work thanks!
 
I don't think it will work if a GM is ghost and tries to walk through a player. Can you try that and tell me if it works? So I can fix it if it doesn't.

Nope does not work, is it possible if the god char can move through players and monsters? Doesnt matter if in ghost or not?
 
Back
Top