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

GM Teleport by Map Click on TFS 1.4

farp

Member
Joined
Nov 18, 2022
Messages
20
Reaction score
8
I've been trying to add this change from TFS 1.5 to my TFS 1.4 Source.


But I'm getting some errors, something related to lambda (I have no idea what is it)

1679810031811.png

Does anyone know how to fix this? what can I do to apply this changes to TFS 1.4? is there any previous commit I should add?
 
add this constructor

or alternatively, use this code instead
C++:
        case 0x73:
            g_dispatcher.addTask(createTask([playerID = player->getID(), pos = msg.getPosition()]() {
                Player* player = g_game.getPlayerByID(playerID);
                if (player && player->isAccessPlayer()) {
                    g_game.internalTeleport(player, pos);
                }
                }));
            break;

not quite sure if packet 0x73 is available in other versions besides 12.x tho
 
add this constructor

or alternatively, use this code instead
C++:
        case 0x73:
            g_dispatcher.addTask(createTask([playerID = player->getID(), pos = msg.getPosition()]() {
                Player* player = g_game.getPlayerByID(playerID);
                if (player && player->isAccessPlayer()) {
                    g_game.internalTeleport(player, pos);
                }
                }));
            break;

not quite sure if packet 0x73 is available in other versions besides 12.x tho
looks like this packet doesn't work on my version, added the constructor and it compiled but ctrl+map click does nothing
maybe its because I use otc...

Well I guess it will be too complex to add this to my server, not sure if its worth the work just to add something to make GM life easier
 
looks like this packet doesn't work on my version, added the constructor and it compiled but ctrl+map click does nothing
maybe its because I use otc...

Well I guess it will be too complex to add this to my server, not sure if its worth the work just to add something to make GM life easier
I don't know if OTC has this packet enabled for mini map clicks, if it doesn't there is no way to make it work server side.

The client is the one in charge of extracting the position of the mini map and sending this information to the server, when the server receives the packet, it obtains the player's ID and the position where the click was made, it is verified if it is an administrator and it send to that location.

As you can see, the client is the one who notifies the server of said action and is the one who provides the information.
 
I don't know if OTC has this packet enabled for mini map clicks, if it doesn't there is no way to make it work server side.

The client is the one in charge of extracting the position of the mini map and sending this information to the server, when the server receives the packet, it obtains the player's ID and the position where the click was made, it is verified if it is an administrator and it send to that location.

As you can see, the client is the one who notifies the server of said action and is the one who provides the information.
Yea, I figured..to make it work on my server I Would have to find a way to implement this packet on my OTC, and the work would be too much just to enable a GM teleport
 
I don't think it's that hard, but I don't have a way to prove it.

I'm not sure but probably with an opcode you can do something similar, without having to enable additional packages, just opcodes.
HERE:
Lua:
local protocolGame = g_game.getProtocolGame()
if protocolGame then
    local pos = player:getPosition()
    protocolGame:sendExtendedOpcode(70, string.format("%d,%d,%d", pos.x, pos.y, pos.z))
end

and on the server something like this:
Lua:
local OP_CODE = 70

local creatureEvent = CreatureEvent("MapClickTeleport")

function creatureEvent.onExtendedOpcode(player, opcode, buffer)
    if opcode == OP_CODE then
        if player:getGroup():getAccess() then
            local x, y, z = buffer:match("(%d+),(%d+),(%d+)")
            if x and y and z then
                player:teleportTo(Position(x, y, z))
            end
        end
    end
end

creatureEvent:register()
this is just an example, i can't test those things.
 
Last edited:
I don't think it's that hard, but I don't have a way to prove it.

I'm not sure but probably with an opcode you can do something similar, without having to enable additional packages, just opcodes.
HERE:
Lua:
if protocolGame then
    local pos = player:getPosition()
    protocolGame:sendExtendedOpcode(70, string.format("%d,%d,%d", pos.x, pos.y, pos.z))
end

and on the server something like this:
Lua:
local OP_CODE = 70

local creatureEvent = CreatureEvent("MapClickTeleport")

function creatureEvent.onExtendedOpcode(player, opcode, buffer)
    if opcode == OP_CODE then
        if player:getGroup():getAccess() then
            local x, y, z = buffer:match("(%d+),(%d+),(%d+)")
            if x and y and z then
                player:teleportTo(Position(x, y, z))
            end
        end
    end
end

creatureEvent:register()
this is just an example, i can't test those things.


it worked for me
Lua:
  local mapPos = self:getTilePosition(pos)
  if not mapPos then return end

  if button == MouseLeftButton then

  local protocolGame = g_game.getProtocolGame()
    if protocolGame then
    protocolGame:sendExtendedOpcode(70, string.format("%d,%d,%d", mapPos.x, mapPos.y, mapPos.z))
    end


edit:

Lua:
  local mapPos = self:getTilePosition(pos)
  if not mapPos then return end

  if button == MouseLeftButton then

local player = g_game.getLocalPlayer()
if player:getName() == "GM" then   --player:isGM() does not exist ????
   local protocolGame = g_game.getProtocolGame()
    if protocolGame then
    protocolGame:sendExtendedOpcode(70, string.format("%d,%d,%d", mapPos.x, mapPos.y, mapPos.z))
end
else
        if self.autowalk then
            player:autoWalk(mapPos)
        end
    end
 
Last edited:
Back
Top