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

C++ Walking through players in PZ | ADD MORE TILES

Unvincible

Member
Joined
Sep 1, 2015
Messages
44
Reaction score
10
Hi guys, im using a perfect system that ive found here. But, i want to add more tile that players cant walk through players on theses tiles. can someone help me?


only in that TILE ID 11063 players can not walk through others.

C++ part:

player->getTile()->ground->getID() != 11063
 
Last edited:
Thank you very much guys, I'll test soon as i arrive home.

im home already, Scripts dindnt work, no errors on console. (tfs 0.3.6)

C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;
    const Player* player = creature->getPlayer();
    if(!player)
        return false;
    if(
        (
            (
                (
                    (
                        player->getVocation()->isAttackable() &&
                        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
                    )
                    || (
                        player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) &&
                        !player->getTile()->hasFlag(TILESTATE_HOUSE)
                    )
                )
            ) && player->getTile()->ground &&
                player->getTile()->ground->getID() != ( 417 || 425 || 447 || 3217 || 3215 || 10552 )
        ) && (
            !player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
            || player->getAccess() <= getAccess()
        )
    ) return true;
    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
Last edited:
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(creature == this || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;
    const Player* player = creature->getPlayer();
    if(!player)
        return false;
    if(
        (
            (
                (
                    (
                        player->getVocation()->isAttackable() &&
                        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
                    )
                    || (
                        player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) &&
                        !player->getTile()->hasFlag(TILESTATE_HOUSE)
                    )
                )
            ) && player->getTile()->ground &&
                (player->getTile()->ground->getID() != 417 || player->getTile()->ground->getID() != 447 || player->getTile()->ground->getID() != 3217 || player->getTile()->ground->getID() !=3215 || player->getTile()->ground->getID() !=10552 || player->getTile()->ground->getID() != yourtile_id)
        ) && (
            !player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
            || player->getAccess() <= getAccess()
        )
    ) return true;
    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
Last edited:
you just ignored my code that definitely works
what you did doesn't make logical sense, using (x || y || z || i || ...) doesn't work like you think it does
you have to compare every single id with every player->getTile()->ground->getID(), or you could just use the vector method
 
you just ignored my code that definitely works
what you did doesn't make logical sense, using (x || y || z || i || ...) doesn't work like you think it does
you have to compare every single id with every player->getTile()->ground->getID(), or you could just use the vector method

I didnt ignored you, i dont know how to insert it in my code, can you help me.
 
try this
C++:
bool Player::canWalkthrough(const Creature* creature) const
{
    std::vector<int> blocked_tiles = {10552, 3215, 3217, 447, 425, 417};
    if(creature == this || creature->isWalkable() ||
        (creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
        return true;
    const Player* player = creature->getPlayer();
    if(!player)
        return false;
    if(
        (
            (
                (
                    (
                        player->getVocation()->isAttackable() &&
                        player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
                    )
                    || (
                        player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) &&
                        !player->getTile()->hasFlag(TILESTATE_HOUSE)
                    )
                )
            ) && player->getTile()->ground && std::find(blocked_tiles.begin(), blocked_tiles.end(), player->getTile()->ground->getID()) != blocked_tiles.end()
        ) && (
            !player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
            || player->getAccess() <= getAccess()
        )
    ) return true;
    return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
        || (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
error on compile

using make:

std::vector<int> blocked_tiles = {10552, 3215, 3217, 447, 425, 417};
-bash: int: No such file or directory
root@root:/home/86/src/linux# ^
^: command not found
root@root:/home/86/src/linux# player.cpp:856:71: error: could not convert ‘{10552, 3215, 3217, 447, 425, 417}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<int>’
-bash: brace-enclosed: No such file or directory


rebuild all sources:


player.cpp:856:71: error: in C++98 ‘blocked_tiles’ must be initialized by constructor, not by ‘{...}’
std::vector<int> blocked_tiles = {10552, 3215, 3217, 447, 425, 417};
^
player.cpp:856:71: error: could not convert ‘{10552, 3215, 3217, 447, 425, 417}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<int>’
make[1]: *** [player.o] Error 1
 
Last edited:
Back
Top