- Joined
- Jan 15, 2014
- Messages
- 1,318
- Solutions
- 35
- Reaction score
- 435
Hello OTland Community,
I'm trying to make it so players that are within the protection level can be walked through.
I did some research and copied part of a code from somewhere else and this is what I tried:
However, I got these errors:
I'm trying to make it so players that are within the protection level can be walked through.
I did some research and copied part of a code from somewhere else and this is what I tried:
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
if (group->access || creature->isInGhostMode()) {
return true;
}
const Player* player = creature->getPlayer();
if (
player->getVocation()->isAttackable() &&
player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL)
) {
return true;
}
const Player* player = creature->getPlayer();
if (!player) {
return false;
}
const Tile* playerTile = player->getTile();
if (playerTile && playerTile->hasFlag(TILESTATE_PROTECTIONZONE)) {
Item* playerTileGround = playerTile->ground;
if (playerTileGround && playerTileGround->hasWalkStack()) {
Player* thisPlayer = const_cast<Player*>(this);
if ((OTSYS_TIME() - lastWalkthroughAttempt) > 2000) {
thisPlayer->setLastWalkthroughAttempt(OTSYS_TIME());
return false;
}
if (creature->getPosition() != lastWalkthroughPosition) {
thisPlayer->setLastWalkthroughPosition(creature->getPosition());
return false;
}
thisPlayer->setLastWalkthroughPosition(creature->getPosition());
return true;
}
}
return false;
}
However, I got these errors:
Code:
/home/otsmanager/forgottenserver/src/player.cpp: In member function 'bool Player::canWalkthrough(const Creature*) const':
/home/otsmanager/forgottenserver/src/player.cpp:964:30: error: 'class Vocation' has no member named 'isAttackable'
/home/otsmanager/forgottenserver/src/player.cpp:970:16: error: redeclaration of 'const Player* player'
/home/otsmanager/forgottenserver/src/player.cpp:962:16: error: 'const Player* player' previously declared here