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

[Event] Walkthrough everything Ctrl + Arrow keys [TFS 1.X]

Can I dynamically edit the amount of packets allowed to be sent? This keeps booting me out of the server for exceeding packet limit on a 10.90 server (did that exist on latest official TFS?)
 
Change the following amount in your config.lua:

maxPacketsPerSecond = 25
maxPacketsPerSecond = 40 (try higher ones if you want)
 
@zbizu But you don't need to store player direction in a table in order to make it work like TFS 0.4 :p

Code:
function Player:onTurn(direction)
    if self:getDirection() == direction and self:getGroup():getAccess() then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end
    return true
end
where to put this please bro
 
Data -> Events -> Scripts -> Player.lua -> Change this ->
Code:
function Player:onTurn(direction)
    return true
end

to ->

Code:
function Player:onTurn(direction)
    if self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end
    return true
end

After you have added, go to ...\data\events\events.xml and open the XML file, change bold code ->
Code:
    <event class="Player" method="onTurn" enabled="0" />
to enabled="1" (if it already was marked 1, then leave it as it is).
 
Data -> Events -> Scripts -> Player.lua -> Change this ->
Code:
function Player:onTurn(direction)
    return true
end

to ->

Code:
function Player:onTurn(direction)
    if self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end
    return true
end

After you have added, go to ...\data\events\events.xml and open the XML file, change bold code ->
Code:
    <event class="Player" method="onTurn" enabled="0" />
to enabled="1" (if it already was marked 1, then leave it as it is).
thx dyablo for answer but the edit is for tfs 0.4 and u just rewrite the first post
i need to know where to add this in 0.4 not 1.x
 
i searched a lot where to edit to add this but i found nothing so my question is which file i edit to add this
Code:
function Player:onTurn(direction)
if self:getDirection() == direction and self:getGroup():getAccess() then
local nextPosition = self:getPosition()
nextPosition:getNextPosition(direction)

self:teleportTo(nextPosition, true)
end
return true
end
i searched in player.cpp, creature.cpp and creatureevent.cpp but didn't know where to add
 
That is .LUA code and not C++ code. You are not supposed to write inside any C++ file. Check my post above before you comment anything. (I'm feeling stupid now that you are not listening to anyone)
https://otland.net/threads/event-wa...arrow-keys-tfs-1-x.226973/page-2#post-2347758

Of course, there are ways to do inside C++ codes, but that won't be easy. For that reason you have LUA script, you can modify anything very easily without touching the C++ files and compiling your engine over and over.
 
thx alot for helping dyabl0 i just misunderstanding the code
 
Hello,

Well some people have requested this missing feature which could be found in 0.3 series. Well i have made one for TFS 1.x.

I will send a pull request to the forgottenserver project, but in case it may not be accepted. Due to, this is mby a personal future. This way is alot better than 0.3, since 0.3 was hardcoded while this is made by lua with few lines. Which make it even more easier to edit stuff.

Go to events/events.xml and onTurn make sure write from 0 to 1.
Now go to events/scripts and open player.lua and find Player:eek:nTurn(direction) and replace with this:
Code:
function Player:onTurn(direction)
    if self:getGroup():getAccess() and self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end

    return true
end

Cheers.
its possible this system but for levels 50-? (chars with protection pz) I need because have many players trap zones in my server, please :D
 
Felt unnecessary to create a new thread for this, however here's my take on it:

Code:
playerLastTurn = playerLastTurn or {}
function Player:onTurn(direction)
    if not self:getGroup():getAccess() or self:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local lastTurn = playerLastTurn[self:getId()]
    if self:getDirection() ~= direction and (not lastTurn or os.time() - lastTurn > 1) then
        return true
    end
  
    playerLastTurn[self:getId()] = os.time()

    local pos = self:getPosition()
    pos:getNextPosition(direction)
    while not Tile(pos) and pos.z < 7 do
        pos.z = pos.z + 1
    end
    self:teleportTo(pos, true)

    return true
end

Will throw you down from roofs, mountains and similar (not below ground floor) if you reach the end. Also makes turning much smoother. You will have to stop running for one second if you want to turn normally (without it moving you).
 
Felt unnecessary to create a new thread for this, however here's my take on it:

Code:
playerLastTurn = playerLastTurn or {}
function Player:onTurn(direction)
    if not self:getGroup():getAccess() or self:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end

    local lastTurn = playerLastTurn[self:getId()]
    if self:getDirection() ~= direction and (not lastTurn or os.time() - lastTurn > 1) then
        return true
    end
 
    playerLastTurn[self:getId()] = os.time()

    local pos = self:getPosition()
    pos:getNextPosition(direction)
    while not Tile(pos) and pos.z < 7 do
        pos.z = pos.z + 1
    end
    self:teleportTo(pos, true)

    return true
end

Will throw you down from roofs, mountains and similar (not below ground floor) if you reach the end. Also makes turning much smoother. You will have to stop running for one second if you want to turn normally (without it moving you).
how does that make you go downstairs if you're adding +1 to z pos
 
great script i come up with works only when you have /ghost enabled - im using Downgraded TFS 1.3

Lua:
function Player:onTurn(direction)
  if self:isInGhostMode() and self:getDirection() == direction then
    local nextPosition = self:getPosition()
    nextPosition:getNextPosition(direction)

    self:teleportTo(nextPosition, true)
  end

    return true
end
 
Back
Top