• 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+ Admin cant move objects from long distances

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,249
Solutions
71
Reaction score
621
Location
Hell
TFS : 1.3

I have an admin character (GroupID = 3, Account Type = 5)
As you may know in lower versions like TFS 0.4 (8.6) Admins are able to move objects (Players, monsters, items) from long distances without moving 1 SQM. But in this version (1.3, 10.98) I am not able to do that. I can only push items/creatures like any normal player.

Is there some sort of configuration for this ? How do I activate/implement it?
 
Solution
You have to go to each different check like:

Z Position check (up or down stairs)
Code:
const Position& playerPos = player->getPosition();
    const Position& mapFromPos = fromCylinder->getTile()->getPosition();
    if (playerPos.z != mapFromPos.z) {
        player->sendCancelMessage(playerPos.z > mapFromPos.z ? RETURNVALUE_FIRSTGOUPSTAIRS : RETURNVALUE_FIRSTGODOWNSTAIRS);
        return;
    }

Throw Distance
Code:
if ((Position::getDistanceX(playerPos, mapToPos) > item->getThrowRange()) ||
            (Position::getDistanceY(playerPos, mapToPos) > item->getThrowRange()) ||
            (Position::getDistanceZ(mapFromPos, mapToPos) * 4 > item->getThrowRange())) {
        player->sendCancelMessage(RETURNVALUE_DESTINATIONOUTOFREACH)...
you can compare both functions, I guess it is called internalMoveItem or something like that :p or you can post both repos and I can do some research
 
you can compare both functions, I guess it is called internalMoveItem or something like that :p or you can post both repos and I can do some research

Not sure but it might be this one:

0.4

1.3
 
BUMP @StreamSide
Did you find anything ?


EDIT:

[ An experienced Friend ] said that 1.3 is based on 0.2 which did not have the flags of 0.3.6 or 0.4 such as PlayerCustomFlag_CanMoveFromFar. So he said that I had to add the code myself.

@Znote M'lord may you guide me trough these dark times and Lord Pepe shall grant you the freedom of gods
 
Last edited:
Not sure but it might be this one:

0.4

1.3
I'll have a look at this when i get home or tomorrow if no one else offers a solution
 
In game.cpp

void Game::playerMoveItem(Player* player, const Position& fromPos, uint16_t spriteId, uint8_t fromStackPos, const Position& toPos, uint8_t count, Item* item, Cylinder* toCylinder)

Code:
if (!Position::areInRange<1, 1>(playerPos, mapFromPos)) {
        //need to walk to the item first before using it
        std::forward_list<Direction> listDir;
        if (player->getPathTo(item->getPosition(), listDir, 0, 1, true, true)) {
            g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
                                            this, player->getID(), listDir)));

            SchedulerTask* task = createSchedulerTask(400, std::bind(&Game::playerMoveItemByPlayerID, this,
                                  player->getID(), fromPos, spriteId, fromStackPos, toPos, count));
            player->setNextWalkActionTask(task);
        } else {
            player->sendCancelMessage(RETURNVALUE_THEREISNOWAY);
        }
        return;
    }

You need to add a check for the player to see if he is a god or however you want to set it up.
 
In game.cpp

void Game::playerMoveItem(Player* player, const Position& fromPos, uint16_t spriteId, uint8_t fromStackPos, const Position& toPos, uint8_t count, Item* item, Cylinder* toCylinder)

Code:
if (!Position::areInRange<1, 1>(playerPos, mapFromPos)) {
        //need to walk to the item first before using it
        std::forward_list<Direction> listDir;
        if (player->getPathTo(item->getPosition(), listDir, 0, 1, true, true)) {
            g_dispatcher.addTask(createTask(std::bind(&Game::playerAutoWalk,
                                            this, player->getID(), listDir)));

            SchedulerTask* task = createSchedulerTask(400, std::bind(&Game::playerMoveItemByPlayerID, this,
                                  player->getID(), fromPos, spriteId, fromStackPos, toPos, count));
            player->setNextWalkActionTask(task);
        } else {
            player->sendCancelMessage(RETURNVALUE_THEREISNOWAY);
        }
        return;
    }

You need to add a check for the player to see if he is a god or however you want to set it up.

I did do that but It didnt produce the expected results (read more in the link:)
 
You have to go to each different check like:

Z Position check (up or down stairs)
Code:
const Position& playerPos = player->getPosition();
    const Position& mapFromPos = fromCylinder->getTile()->getPosition();
    if (playerPos.z != mapFromPos.z) {
        player->sendCancelMessage(playerPos.z > mapFromPos.z ? RETURNVALUE_FIRSTGOUPSTAIRS : RETURNVALUE_FIRSTGODOWNSTAIRS);
        return;
    }

Throw Distance
Code:
if ((Position::getDistanceX(playerPos, mapToPos) > item->getThrowRange()) ||
            (Position::getDistanceY(playerPos, mapToPos) > item->getThrowRange()) ||
            (Position::getDistanceZ(mapFromPos, mapToPos) * 4 > item->getThrowRange())) {
        player->sendCancelMessage(RETURNVALUE_DESTINATIONOUTOFREACH);
        return;
    }

and add the flag check to each one.
 
Solution
You have to go to each different check like:

Z Position check (up or down stairs)
Code:
const Position& playerPos = player->getPosition();
    const Position& mapFromPos = fromCylinder->getTile()->getPosition();
    if (playerPos.z != mapFromPos.z) {
        player->sendCancelMessage(playerPos.z > mapFromPos.z ? RETURNVALUE_FIRSTGOUPSTAIRS : RETURNVALUE_FIRSTGODOWNSTAIRS);
        return;
    }

Throw Distance
Code:
if ((Position::getDistanceX(playerPos, mapToPos) > item->getThrowRange()) ||
            (Position::getDistanceY(playerPos, mapToPos) > item->getThrowRange()) ||
            (Position::getDistanceZ(mapFromPos, mapToPos) * 4 > item->getThrowRange())) {
        player->sendCancelMessage(RETURNVALUE_DESTINATIONOUTOFREACH);
        return;
    }

and add the flag check to each one.

Thanks alot. I was able to understand the logic and apply that to the part about moving creatures. :D
 
only edit flags in data/xml/groups

Which flags? All I could find was the following ( in const.h )

C++:
enum PlayerFlags : uint64_t {
    PlayerFlag_CannotUseCombat = 1 << 0,
    PlayerFlag_CannotAttackPlayer = 1 << 1,
    PlayerFlag_CannotAttackMonster = 1 << 2,
    PlayerFlag_CannotBeAttacked = 1 << 3,
    PlayerFlag_CanConvinceAll = 1 << 4,
    PlayerFlag_CanSummonAll = 1 << 5,
    PlayerFlag_CanIllusionAll = 1 << 6,
    PlayerFlag_CanSenseInvisibility = 1 << 7,
    PlayerFlag_IgnoredByMonsters = 1 << 8,
    PlayerFlag_NotGainInFight = 1 << 9,
    PlayerFlag_HasInfiniteMana = 1 << 10,
    PlayerFlag_HasInfiniteSoul = 1 << 11,
    PlayerFlag_HasNoExhaustion = 1 << 12,
    PlayerFlag_CannotUseSpells = 1 << 13,
    PlayerFlag_CannotPickupItem = 1 << 14,
    PlayerFlag_CanAlwaysLogin = 1 << 15,
    PlayerFlag_CanBroadcast = 1 << 16,
    PlayerFlag_CanEditHouses = 1 << 17,
    PlayerFlag_CannotBeBanned = 1 << 18,
    PlayerFlag_CannotBePushed = 1 << 19,
    PlayerFlag_HasInfiniteCapacity = 1 << 20,
    PlayerFlag_CanPushAllCreatures = 1 << 21,
    PlayerFlag_CanTalkRedPrivate = 1 << 22,
    PlayerFlag_CanTalkRedChannel = 1 << 23,
    PlayerFlag_TalkOrangeHelpChannel = 1 << 24,
    PlayerFlag_NotGainExperience = 1 << 25,
    PlayerFlag_NotGainMana = 1 << 26,
    PlayerFlag_NotGainHealth = 1 << 27,
    PlayerFlag_NotGainSkill = 1 << 28,
    PlayerFlag_SetMaxSpeed = 1 << 29,
    PlayerFlag_SpecialVIP = 1 << 30,
    PlayerFlag_NotGenerateLoot = static_cast<uint64_t>(1) << 31,
    PlayerFlag_CanTalkRedChannelAnonymous = static_cast<uint64_t>(1) << 32,
    PlayerFlag_IgnoreProtectionZone = static_cast<uint64_t>(1) << 33,
    PlayerFlag_IgnoreSpellCheck = static_cast<uint64_t>(1) << 34,
    PlayerFlag_IgnoreWeaponCheck = static_cast<uint64_t>(1) << 35,
    PlayerFlag_CannotBeMuted = static_cast<uint64_t>(1) << 36,
    PlayerFlag_IsAlwaysPremium = static_cast<uint64_t>(1) << 37,
};
 
In your server files (not the source code) go to data/xml/groups.xml

There you can add the new flags to your character. I am not sure how the flags are calculated, if you find out please pm me the solution.

You can add a custom flag there for allowThrowFromFar and use that flag so that only gods, or whoever you see fit can move from far.
 
In your server files (not the source code) go to data/xml/groups.xml

There you can add the new flags to your character. I am not sure how the flags are calculated, if you find out please pm me the solution.

You can add a custom flag there for allowThrowFromFar and use that flag so that only gods, or whoever you see fit can move from far.

but only 0.3 and 0.4 has custom flags.

35100
 
In your server files (not the source code) go to data/xml/groups.xml

There you can add the new flags to your character. I am not sure how the flags are calculated, if you find out please pm me the solution.

You can add a custom flag there for allowThrowFromFar and use that flag so that only gods, or whoever you see fit can move from far.
Flags are calculated by adding them together the sum of any number of flags is unique and can't be reproduced by any other combination.
 
@Steve Albert What is the value of each one then?
Lua:
PlayerFlag_CannotUseCombat                =         1
PlayerFlag_CannotAttackPlayer            =         2
PlayerFlag_CannotAttackMonster            =         4
PlayerFlag_CannotBeAttacked                =         8
PlayerFlag_CanConvinceAll                =         16
PlayerFlag_CanSummonAll                    =         32
PlayerFlag_CanIllusionAll                =         64
PlayerFlag_CanSenseInvisibility            =         128
PlayerFlag_IgnoredByMonsters            =         256
PlayerFlag_NotGainInFight                =         512
PlayerFlag_HasInfiniteMana                =         1024
PlayerFlag_HasInfiniteSoul                =         2048
PlayerFlag_HasNoExhaustion                =         4096
PlayerFlag_CannotUseSpells                =         8192
PlayerFlag_CannotPickupItem                =         16384
PlayerFlag_CanAlwaysLogin                =         32768
PlayerFlag_CanBroadcast                    =         65536
PlayerFlag_CanEditHouses                =         131072
PlayerFlag_CannotBeBanned                =         262144
PlayerFlag_CannotBePushed                =         524288
PlayerFlag_HasInfiniteCapacity            =         1048576
PlayerFlag_CanPushAllCreatures            =         2097152
PlayerFlag_CanTalkRedPrivate            =         4194304
PlayerFlag_CanTalkRedChannel            =         8388608
PlayerFlag_TalkOrangeHelpChannel        =         16777216
PlayerFlag_NotGainExperience            =         33554432
PlayerFlag_NotGainMana                    =         67108864
PlayerFlag_NotGainHealth                =         134217728
PlayerFlag_NotGainSkill                    =         268435456
PlayerFlag_SetMaxSpeed                    =         536870912
PlayerFlag_SpecialVIP                    =         1073741824
PlayerFlag_NotGenerateLoot                =         2147483648
PlayerFlag_CanTalkRedChannelAnonymous    =         4294967296
PlayerFlag_IgnoreProtectionZone            =         8589934592
PlayerFlag_IgnoreSpellCheck                =         17179869184
PlayerFlag_IgnoreWeaponCheck            =         34359738368
PlayerFlag_CannotBeMuted                =         68719476736
PlayerFlag_IsAlwaysPremium                =         137438953472

I made those with this script
Lua:
local flags = {
  [1] =    "PlayerFlag_CannotUseCombat",
  [2] =    "PlayerFlag_CannotAttackPlayer",
  [3] =    "PlayerFlag_CannotAttackMonster",
  [4] =    "PlayerFlag_CannotBeAttacked",
  [5] =    "PlayerFlag_CanConvinceAll",
  [6] =    "PlayerFlag_CanSummonAll",
  [7] =    "PlayerFlag_CanIllusionAll",
  [8] =    "PlayerFlag_CanSenseInvisibility",
  [9] =    "PlayerFlag_IgnoredByMonsters",
  [10] =   "PlayerFlag_NotGainInFight",
  [11] =   "PlayerFlag_HasInfiniteMana",
  [12] =   "PlayerFlag_HasInfiniteSoul",
  [13] =   "PlayerFlag_HasNoExhaustion",
  [14] =   "PlayerFlag_CannotUseSpells",
  [15] =   "PlayerFlag_CannotPickupItem",
  [16] =   "PlayerFlag_CanAlwaysLogin",
  [17] =   "PlayerFlag_CanBroadcast",
  [18] =   "PlayerFlag_CanEditHouses",
  [19] =   "PlayerFlag_CannotBeBanned",
  [20] =   "PlayerFlag_CannotBePushed",
  [21] =   "PlayerFlag_HasInfiniteCapacity",
  [22] =   "PlayerFlag_CanPushAllCreatures",
  [23] =   "PlayerFlag_CanTalkRedPrivate",
  [24] =   "PlayerFlag_CanTalkRedChannel",
  [25] =   "PlayerFlag_TalkOrangeHelpChannel",
  [26] =   "PlayerFlag_NotGainExperience",
  [27] =   "PlayerFlag_NotGainMana",
  [28] =   "PlayerFlag_NotGainHealth",
  [29] =   "PlayerFlag_NotGainSkill",
  [30] =   "PlayerFlag_SetMaxSpeed",
  [31] =   "PlayerFlag_SpecialVIP",
  [32] =   "PlayerFlag_NotGenerateLoot",
  [33] =   "PlayerFlag_CanTalkRedChannelAnonymous",
  [34] =   "PlayerFlag_IgnoreProtectionZone",
  [35] =   "PlayerFlag_IgnoreSpellCheck",
  [36] =   "PlayerFlag_IgnoreWeaponCheck",
  [37] =   "PlayerFlag_CannotBeMuted",
  [38] =   "PlayerFlag_IsAlwaysPremium",
}

for k, v in ipairs(flags) do
  print(v,  1 * (2 ^ (k-1)) )
end

-- The above for loop is based on this method
function leftShift(x, y)
    return x * (2 ^ y)
end
 
Last edited:
Back
Top