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

TURN DELAY LIMITED

alisonrenna

New Member
Joined
Sep 24, 2011
Messages
29
Reaction score
2
TFS 1.3
good, would like to put a time on the server dancing, players are running with very fast ElfBot, this is generating increased cpu ??
 
Solution
You cant do 0.5 in os.time() im pretty sure. It has to be atleast 1 second.

You also didn't code it correctly at all. You broke the gm's ability to teleport with arrow keys only....

try this
Lua:
local storage1 = 1000
local delay1 = 0.5 -- seconds

function Player:onTurn(direction)
    if self:getGroup():getAccess() and self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)
        self:teleportTo(nextPosition, false)
        return false
    end
   
    if not self:getGroup():getAccess() then
        if self:getStorageValue(storage1) >= os.time() then
            return false
        else
            self:setStorageValue(storage1, os.time() + delay1)...
There is no need to mess with "dancing".

Instead, in your config.lua, set maxPacketsPerSecond to something around 25.
 
I forgot to mention, my server is 8.60, people use elf bot if I leave maxPacketsPerSecond 25, people get kicked by a simple hotkey on elfbot, so I need to delay these dances, for the dolls to spin in 0.5 seconds each way !
 
I don't really think that anything related to dancing would increase your cpu usage to anything noticeable, your issue must really be somewhere else
 
I forgot to mention, my server is 8.60, people use elf bot if I leave maxPacketsPerSecond 25, people get kicked by a simple hotkey on elfbot, so I need to delay these dances, for the dolls to spin in 0.5 seconds each way !
And how you measure that it is the "turn" that actually increased cpu usage? This function doesn't even have any complexity xD
Limiting packets per second is the only way to fix your problem, because your cpu have increased usage due to massive amount of xtea_decryption and it will happen even if you add exhaust to "turn".
 
Pretty sure TFS 1.3 has Player.onTurn(self) in events/scripts/players.lua.. Add an exhaust like you would to anything else.
 
Pretty sure TFS 1.3 has Player.onTurn(self) in events/scripts/players.lua.. Add an exhaust like you would to anything else.
Lua:
local storage1 = 1000
local delay1 = 0.5 -- seconds


function Player:onTurn(direction)
    if self:getGroup():getAccess() and self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)
                if os.time() > self:getStorageValue(storage1) then
                self:setStorageValue(storage1, os.time() + delay1)
            else
        self:teleportTo(nextPosition, false)
        self:sendCancelMessage("Sorry, not possible.")
                return false
            end
        end
 
    return true
end


I did it this way but I was not successful
 
You cant do 0.5 in os.time() im pretty sure. It has to be atleast 1 second.

You also didn't code it correctly at all. You broke the gm's ability to teleport with arrow keys only....

try this
Lua:
local storage1 = 1000
local delay1 = 0.5 -- seconds

function Player:onTurn(direction)
    if self:getGroup():getAccess() and self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)
        self:teleportTo(nextPosition, false)
        return false
    end
   
    if not self:getGroup():getAccess() then
        if self:getStorageValue(storage1) >= os.time() then
            return false
        else
            self:setStorageValue(storage1, os.time() + delay1)
        end
    end
    return true
end
 
Last edited:
Solution
Pretty sure TFS 1.3 has Player.onTurn(self) in events/scripts/players.lua.. Add an exhaust like you would to anything else.
You know that even if you put a delay in turning logic in your lua scripts, server still has to process the network message and execute this method right? There is problem as @fabian766 said, xtea decryption spams the shit out of his cpu.
 
Yes, but if the players think its not working then they might stop using the script. Its all head games.
 
TFS 1.3
good, would like to put a time on the server dancing, players are running with very fast ElfBot, this is generating increased cpu ??
There is no need to mess with "dancing".

Instead, in your config.lua, set maxPacketsPerSecond to something around 25.
What never knew it, is it actually true that turning around your character have something to do with maxPacketsPerSecond? What kind of magic is that i never heard about. Thought maxPacketsPerSecond is related like to skill spamming or similar stuff
 
What never knew it, is it actually true that turning around your character have something to do with maxPacketsPerSecond? What kind of magic is that i never heard about. Thought maxPacketsPerSecond is related like to skill spamming or similar stuff
Any client action that you do in tibia is a packet, that is sent from client to server and server has to parse it.
 
You cant do 0.5 in os.time() im pretty sure. It has to be atleast 1 second.

You also didn't code it correctly at all. You broke the gm's ability to teleport with arrow keys only....

try this
Lua:
local storage1 = 1000
local delay1 = 0.5 -- seconds

function Player:onTurn(direction)
    if self:getGroup():getAccess() and self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)
        self:teleportTo(nextPosition, false)
        return false
    end
   
    if not self:getGroup():getAccess() then
        if self:getStorageValue(storage1) >= os.time() then
            return false
        else
            self:setStorageValue(storage1, os.time() = delay1)
        end
    end
    return true
end

this following error occurred

[Warning - Events::load] Can not load script: player.lua
data/events/scripts/player.lua:616: ')' expected near '='



the line and this self:setStorageValue(storage1, os.time() = delay1)
 
It should be + instead of = if that's what bothers you, but people told you several times that in order to decrease the CPU usage you need to lower the maxPacketsPerSecond. And hell, they are right
 
Back
Top