• 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++ alana sio

Fortera Global

Intermediate OT User
Joined
Nov 20, 2015
Messages
1,180
Solutions
2
Reaction score
117
The problem is that the command is giving to use even with the player (that typed the command) outside the house.

How I can make an check for this in c++?

C++:
bool InstantSpell::HouseKick(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();

    Player* targetPlayer = g_game.getPlayerByName(param);
    if (!targetPlayer) {
        targetPlayer = player;
    }

    House* house = getHouseFromPos(targetPlayer);
    if (!house) {
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
        return false;
    }

    if (!house->kickPlayer(player, targetPlayer)) {
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
        return false;
    }
    return true;
}

tfs 1.2
 
Solution
C++:
bool InstantSpell::HouseKick(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    Player* targetPlayer = g_game.getPlayerByName(param);
    if (!targetPlayer) {
        targetPlayer = player;
    }
    House* house = getHouseFromPos(targetPlayer);
    House* phouse = getHouseFromPos(player);
    if (!house || !phouse || (house->getId() != phouse->getId()) {
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
        return false;
    }
    if (!house->kickPlayer(player, targetPlayer)) {
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF)...
C++:
bool InstantSpell::HouseKick(const InstantSpell*, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    Player* targetPlayer = g_game.getPlayerByName(param);
    if (!targetPlayer) {
        targetPlayer = player;
    }
    House* house = getHouseFromPos(targetPlayer);
    House* phouse = getHouseFromPos(player);
    if (!house || !phouse || (house->getId() != phouse->getId()) {
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
        return false;
    }
    if (!house->kickPlayer(player, targetPlayer)) {
        g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
        player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
        return false;
    }
    return true;
}
 
Solution
Back
Top