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

TFS 1.X+ Make sure Player is unable to dismount in specific tiles.

Jaki Maoh

Member
Joined
Sep 13, 2017
Messages
52
Reaction score
11
Hello, Otland!
Is there a way to make sure the players can't:
  • dismount (even with Ctrl + R);
  • change current mount;
  • change outfits.
If they are on top of specific tiles (Tile ID, UID or AID)? 🤔
I'm pretty sure such changes must be made inside the sources, but am unable to make it work without breaking something else 😝
My best guess is trying to mess around in Player.cpp (link)
C++:
uint8_t Player::getCurrentMount() const
{
    int32_t value;
    if (getStorageValue(PSTRG_MOUNTS_CURRENTMOUNT, value)) {
        return value;
    }
    return 0;
}

void Player::setCurrentMount(uint8_t mountId) { addStorageValue(PSTRG_MOUNTS_CURRENTMOUNT, mountId); }

bool Player::toggleMount(bool mount)
{
    if ((OTSYS_TIME() - lastToggleMount) < 3000 && !wasMounted) {
        sendCancelMessage(RETURNVALUE_YOUAREEXHAUSTED);
        return false;
    }

    if (mount) {
        if (isMounted()) {
            return false;
        }

        if (!group->access && tile->hasFlag(TILESTATE_PROTECTIONZONE)) {
            sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
            return false;
        }

        const Outfit* playerOutfit = Outfits::getInstance().getOutfitByLookType(getSex(), defaultOutfit.lookType);
        if (!playerOutfit) {
            return false;
        }

        uint8_t currentMountId = getCurrentMount();
        if (currentMountId == 0) {
            sendOutfitWindow();
            return false;
        }

        if (randomizeMount) {
            currentMountId = getRandomMount();
        }

        Mount* currentMount = g_game.mounts.getMountByID(currentMountId);
        if (!currentMount) {
            return false;
        }

        if (!hasMount(currentMount)) {
            setCurrentMount(0);
            sendOutfitWindow();
            return false;
        }

        if (currentMount->premium && !isPremium()) {
            sendCancelMessage(RETURNVALUE_YOUNEEDPREMIUMACCOUNT);
            return false;
        }

        if (hasCondition(CONDITION_OUTFIT)) {
            sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
            return false;
        }

        defaultOutfit.lookMount = currentMount->clientId;

        if (currentMount->speed != 0) {
            g_game.changeSpeed(this, currentMount->speed);
        }
    } else {
        if (!isMounted()) {
            return false;
        }

        dismount();
    }

    g_game.internalCreatureChangeOutfit(this, defaultOutfit);
    lastToggleMount = OTSYS_TIME();
    return true;
}
If someone can lighthen the path a little it would be much appreciated ;)
Thanks as always! 🙏
Jaki
 
Try with this before line 27

C++:
const Tile* tile = getTile();
if(tile)
{
    const Item* ground = tile->getGround();
    if(ground && (ground->getID() >= 1000 && ground->getID() <= 2000))
    {
        sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
        return false;
    }
}
 
Last edited:
Try with this before line 27

C++:
const Tile* tile = getTile();
if(tile)
{
    const Item* ground = tile->getGround();
    if(ground && (ground->getId() >= 1000 && ground->getId() <= 2000))
    {
        sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE);
        return false;
    }
}
}
Got this error now
1663192408203.png
in the line
C++:
                if (ground && (ground->getId() >= 2000 && ground->getId() <= 2005))
😧
Good try, @Acubens !
 

Attachments

Last edited:
Got an error
in the line
C++:
                if (tile->ground && tile->ground->getActionId() == 1000)
😧
Is there a way to make it by a range of tile ID? I don't mind making a new floor with said IDs.
Thanks, anyway, @Acubens !
I update my post try now, i hope it helps you <3
 
Bro i update the post yesterday was wrong function used getId instead of getID, copy it again.
@Acubens Thanks for the answer, but I'm afraid it is not yet done 😥
This time I've got no errors while building 🤩, but the player / god can still dismount in the said areas. Probably something else is going through the radar?
🤔
If someone has any ideas worth sharing, all help is welcome, as always! 🙏
Thanks again!
Jaki
 
@Acubens Thanks for the answer, but I'm afraid it is not yet done 😥
This time I've got no errors while building 🤩, but the player / god can still dismount in the said areas. Probably something else is going through the radar?
🤔
If someone has any ideas worth sharing, all help is welcome, as always! 🙏
Thanks again!
Jaki
in this message you mentioned the "said area" for the first time you gave 0 information about it, not even groundIDs so did you edit the code provided by contributors to fit your needs? --Whatever the case, you did or not, you mentioned about the area and i didn't see or not, please understand that 99.99% of developers will implement the logic with meaningless values that needs to be changed for the code to work as you want, we implement to logic that needs your data to be inserted on, talking about my self and who i know [i don't even import data for myself]
 
in this message you mentioned the "said area" for the first time you gave 0 information about it, not even groundIDs so did you edit the code provided by contributors to fit your needs? --Whatever the case, you did or not, you mentioned about the area and i didn't see or not, please understand that 99.99% of developers will implement the logic with meaningless values that needs to be changed for the code to work as you want, we implement to logic that needs your data to be inserted on, talking about my self and who i know [i don't even import data for myself]
Thanks for the explanations, @Shadow_ ! 👍
I've got an area where I need the players to cross while mounted, and it would break the "immersion" if they could dismount as they please, in my opinion. I've searched the forum and did not found this bit of code anywhere else. That's when I've thought about asking for help.
I also think many servers could use a feature like this one too. ;)

When the contributors elaborate a code that I could use, I always test it on my server and try to adapt it to my needs, in this case, with the data/ground IDs/AIDs that I am using.
Thanks again! :D
Jaki
 
Back
Top