• 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 0.X Get combat status?

warriorfrog

Active Member
Joined
Jul 29, 2015
Messages
334
Reaction score
35
I was thinking about kick players with high ping, but it would broke the PvP...

So is it possible to detect if player:
1- is attacking another player
2- is being attack for another player

To make this script to protect players???
 
You can use this one

and add this.
Lua:
if(isPlayerPzLocked(cid) == false)
or
Lua:
if not getCreatureCondition(cid, CONDITION_INFIGHT)
 
Last edited:
You can use this one

and add this.
Lua:
if(isPlayerPzLocked(cid) == false)
or
Lua:
if not getCreatureCondition(cid, CONDITION_INFIGHT)

LOL, this DDOs protection is a amazing idea
I'll try...

But to protect lagged players only
Lua:
if(isPlayerPzLocked(cid) == false)
It would return players who arent with that red swords, right?
who are attacking a PK, or are PK

Lua:
if not getCreatureCondition(cid, CONDITION_INFIGHT)
It wouldnt return players who are being attack from monsters?

The main objective is to save players to die on hunts if they are lagged
 
If the main reason is to save players from monsters then use first one which is
Lua:
if(isPlayerPzLocked(cid) == false)
it will not kick players with the red sword (PZ mark) but others who aren't pz and lagging will get kicked.
 
If the main reason is to save players from monsters then use first one which is
Lua:
if(isPlayerPzLocked(cid) == false)
it will not kick players with the red sword (PZ mark) but others who aren't pz and lagging will get kicked.

The main problem is...
And if the players who are being attacking from another players?

Some bad boys could abuse, fake lag to dont die on PVP...
 
What? This won't kick players on PVP situation so they can't fake anything.
If you don't know were to add it try this one.
Lua:
---Script by mock the bear
local ping_timeout_ = 2000  -- Equals 2 seconds of non response
local active_anti_ddos = true;
local ping_to_execute_anti_ddos = 0.75 --[[is ping timeout * self.
If helf of this server ping if near this value
the server will auto kick]]

local pingbase = 0;
local pingN = 0;
local block = false;
local player_o = 0;
function onThink(interval, lastExecution) -- MTB
    pingbase = 0;
    pingN = 0;
    block = false;
    local pls = getPlayersOnline()
    player_o = #pls
    for i,cid in pairs(pls) do
        ping.getPing(cid,29894,function(cid,_,ping_,i)
        if active_anti_ddos then
            pingbase = pingbase+ping_
            pingN = pingN+1
            if (math.floor(player_o/2) > 5) and math.floor(player_o/2) <= pingN then
                if pingbase/pingN > ping_timeout_*ping_to_execute_anti_ddos then
                    broadcastMessage("DDoS attack maby detected! KICKING EVEBODY!", 25)
                    block = true;
                    for a,cid in pairs(getPlayersOnline()) do
                        doRemoveCreature(cid)
                    end
                    doSaveServer()
                end
            end
        end
        if ping_ > ping_timeout_ and not block and (isPlayerPzLocked(cid) == false) then
            doRemoveCreature(cid)
        end
        if i == pls then
            print('Ping avarage: '..pingbase/pingN..' ms/player.')
        end
        end,i)
    end
    return true
end
 
What? This won't kick players on PVP situation so they can't fake anything.
If you don't know were to add it try this one.
Lua:
---Script by mock the bear
local ping_timeout_ = 2000  -- Equals 2 seconds of non response
local active_anti_ddos = true;
local ping_to_execute_anti_ddos = 0.75 --[[is ping timeout * self.
If helf of this server ping if near this value
the server will auto kick]]

local pingbase = 0;
local pingN = 0;
local block = false;
local player_o = 0;
function onThink(interval, lastExecution) -- MTB
    pingbase = 0;
    pingN = 0;
    block = false;
    local pls = getPlayersOnline()
    player_o = #pls
    for i,cid in pairs(pls) do
        ping.getPing(cid,29894,function(cid,_,ping_,i)
        if active_anti_ddos then
            pingbase = pingbase+ping_
            pingN = pingN+1
            if (math.floor(player_o/2) > 5) and math.floor(player_o/2) <= pingN then
                if pingbase/pingN > ping_timeout_*ping_to_execute_anti_ddos then
                    broadcastMessage("DDoS attack maby detected! KICKING EVEBODY!", 25)
                    block = true;
                    for a,cid in pairs(getPlayersOnline()) do
                        doRemoveCreature(cid)
                    end
                    doSaveServer()
                end
            end
        end
        if ping_ > ping_timeout_ and not block and (isPlayerPzLocked(cid) == false) then
            doRemoveCreature(cid)
        end
        if i == pls then
            print('Ping avarage: '..pingbase/pingN..' ms/player.')
        end
        end,i)
    end
    return true
end

Rly!?
I did think that if u are being attacking from another players and don't return the attack back, your isPlayerPzLocked(cid) should be = false
 
That depends on what option you have in your config.lua
You can edit it so when players return the attack back they get PZ locked also.
Lua:
allowFightback = false
 
That depends on what option you have in your config.lua
You can edit it so when players return the attack back they get PZ locked also.
Lua:
allowFightback = false

But imagine, you go to my hunt, start to attack me
I uses fake lag, got disconnect and u dont kill me, even attacking me, just because i don't attack back and abuse the protect players script
 
You can decrease or increase this line to get sure that no one will have enough time to fake it.
ping_timeout_ = 2000
1000 = 1 second of non-response.
 
You can decrease or increase this line to get sure that no one will have enough time to fake it.
ping_timeout_ = 2000
1000 = 1 second of non-response.

what u think about it?
Code:
---Script by mock the bear
local ping_timeout_ddos = 2000  -- Equals 2 seconds of non response
local ping_timeout_player = 5000  -- Equals 5 seconds of non response
local active_anti_ddos = true;
local ping_to_execute_anti_ddos = 0.75 --[[is ping timeout * self.
If helf of this server ping if near this value
the server will auto kick]]

local pingbase = 0;
local pingN = 0;
local block = false;
local player_o = 0;
function onThink(interval, lastExecution) -- MTB
    pingbase = 0;
    pingN = 0;
    block = false;
    local pls = getPlayersOnline()
    player_o = #pls
    for i,cid in pairs(pls) do
        ping.getPing(cid,29894,function(cid,_,ping_,i)
        if active_anti_ddos then
            pingbase = pingbase+ping_
            pingN = pingN+1
            if (math.floor(player_o/2) > 5) and math.floor(player_o/2) <= pingN then
                if pingbase/pingN > ping_timeout_ddos*ping_to_execute_anti_ddos then
                    broadcastMessage("DDoS attack maby detected! KICKING EVEBODY!", 25)
                    block = true;
                    for a,cid in pairs(getPlayersOnline()) do
                        doRemoveCreature(cid)
                    end
                    doSaveServer()
                end
            end
        end
        if ping_ > ping_timeout_player and not block and (isPlayerPzLocked(cid) == false) then
            doRemoveCreature(cid)
        end
        if i == pls then
            print('Ping avarage: '..pingbase/pingN..' ms/player.')
        end
        end,i)
    end
    return true
end

u think it is it working?
how can i test it!? HAHA
 
Let someone login and then let him make huge downloads or something that can lag his connection for 5 seconds then check if he'll get kicked or not.
About the anti DDoS test there's many free stress test available you can google and test them on yourself.
 
did u know why my 0.4 is not compiling?

luascript.cpp

luascript.h

errors:
Code:
luascript.cpp:7393:2: error: stray ‘\357’ in program
 {��
  ^
luascript.cpp:7393:3: error: stray ‘\273’ in program
 {��
   ^
luascript.cpp:7393:4: error: stray ‘\277’ in program
 {�
    ^
luascript.cpp:7395:22: error: stray ‘\357’ in program
     ScriptEnviroment*�� env = getEnv();
                      ^
luascript.cpp:7395:23: error: stray ‘\273’ in program
     ScriptEnviroment*�� env = getEnv();
                       ^
luascript.cpp:7395:24: error: stray ‘\277’ in program
     ScriptEnviroment*� env = getEnv();
                        ^
luascript.cpp:7403:23: error: stray ‘\357’ in program
     player->lastPing =�� timeNow;
                       ^
luascript.cpp:7403:24: error: stray ‘\273’ in program
     player->lastPing =�� timeNow;
                        ^
luascript.cpp:7403:25: error: stray ‘\277’ in program
     player->lastPing =� timeNow;
                         ^
luascript.cpp:7403:26: error: stray ‘\357’ in program
     player->lastPing =�� timeNow;
                          ^
luascript.cpp:7403:27: error: stray ‘\273’ in program
     player->lastPing =�� timeNow;
                           ^
luascript.cpp:7403:28: error: stray ‘\277’ in program
     player->lastPing =� timeNow;
                            ^
luascript.cpp:7404:23: error: stray ‘\357’ in program
     if(player->client)��
                       ^
luascript.cpp:7404:24: error: stray ‘\273’ in program
     if(player->client)��
                        ^
luascript.cpp:7404:25: error: stray ‘\277’ in program
     if(player->client)�
                         ^
luascript.cpp:7407:24: error: stray ‘\357’ in program
             lua_pushboo��lean(L, true);
                        ^
luascript.cpp:7407:25: error: stray ‘\273’ in program
             lua_pushboo��lean(L, true);
                         ^
luascript.cpp:7407:26: error: stray ‘\277’ in program
             lua_pushboo�lean(L, true);
                          ^
luascript.cpp:7419:14: error: stray ‘\357’ in program
     return 1;��
              ^
luascript.cpp:7419:15: error: stray ‘\273’ in program
     return 1;��
               ^
luascript.cpp:7419:16: error: stray ‘\277’ in program
     return 1;�
                ^
luascript.cpp:7427:6: error: stray ‘\357’ in program
     {��
      ^
luascript.cpp:7427:7: error: stray ‘\273’ in program
     {��
       ^
luascript.cpp:7427:8: error: stray ‘\277’ in program
     {�
        ^
luascript.cpp:7429:24: error: stray ‘\357’ in program
          lua_pushboolea��n(L, false);
                        ^
luascript.cpp:7429:25: error: stray ‘\273’ in program
          lua_pushboolea��n(L, false);
                         ^
luascript.cpp:7429:26: error: stray ‘\277’ in program
          lua_pushboolea�n(L, false);
                          ^
luascript.cpp:7445:18: error: stray ‘\357’ in program
         return 1;��
                  ^
luascript.cpp:7445:19: error: stray ‘\273’ in program
         return 1;��
                   ^
luascript.cpp:7445:20: error: stray ‘\277’ in program
         return 1;�
                    ^
luascript.cpp:7446:6: error: stray ‘\357’ in program
     }��
      ^
luascript.cpp:7446:7: error: stray ‘\273’ in program
     }��
       ^
luascript.cpp:7446:8: error: stray ‘\277’ in program
     }�
        ^
luascript.cpp:7446:9: error: stray ‘\357’ in program
     }��
         ^
luascript.cpp:7446:10: error: stray ‘\273’ in program
     }��
          ^
luascript.cpp:7446:11: error: stray ‘\277’ in program
     }�
           ^
luascript.cpp:7447:30: error: stray ‘\357’ in program
     lua_pushnumber(L, player-��>lastPong);
                              ^
luascript.cpp:7447:31: error: stray ‘\273’ in program
     lua_pushnumber(L, player-��>lastPong);
                               ^
luascript.cpp:7447:32: error: stray ‘\277’ in program
     lua_pushnumber(L, player-�>lastPong);
                                ^
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaDoPlayerSendPing(lua_State*)’:
luascript.cpp:7407:13: error: ‘lua_pushboo’ was not declared in this scope
             lua_pushboolean(L, true);
             ^~~~~~~~~~~
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaGetPlayerLastPing(lua_State*)’:
luascript.cpp:7429:10: error: ‘lua_pushboolea’ was not declared in this scope
          lua_pushboolean(L, false);
          ^~~~~~~~~~~~~~
luascript.cpp:7432:13: warning: unused variable ‘timeNow’ [-Wunused-variable]
     int64_t timeNow = OTSYS_TIME();
             ^~~~~~~
luascript.cpp: In static member function ‘static int32_t LuaInterface::luaGetPlayerLastPong(lua_State*)’:
luascript.cpp:7447:33: error: expected primary-expression before ‘>’ token
     lua_pushnumber(L, player->lastPong);
                                 ^
luascript.cpp:7447:34: error: ‘lastPong’ was not declared in this scope
     lua_pushnumber(L, player->lastPong);
                                  ^~~~~~~~
Makefile:33: recipe for target 'luascript.o' failed
 
Let someone login and then let him make huge downloads or something that can lag his connection for 5 seconds then check if he'll get kicked or not.
About the anti DDoS test there's many free stress test available you can google and test them on yourself.

Hmmm thanks, i'll search about this stuff stress test, didnt head about, thanks
 
How you are compiling it? Visual studio 2010? Boost_1_53 and you got the right libraries/includes?
 
Sorry I don't know enough bout compiling in Linux but since you said you were compiling it before.
So check if you have added something lately and it can be the cause.
luaGetPlayerLastPong
What is this in luascript.cpp? This is what causing the error.
If you removed it and still stuck please create a different Support thread and you'll get helped.
 
To use the script: GlobalEvent - Auto kick lagged players + DDoS protection (https://otland.net/threads/auto-kick-lagged-players-ddos-protection.121492/#post-1187916)
You need the lib: [Lua & C++] Ping lib -- ping.getPing(cid,storage) (https://otland.net/threads/lua-c-ping-lib-ping-getping-cid-storage.121183/)

And to you use the lib, need this C++ code:

But it's for 0.3.6, and i'm using 0.4

I found this guy converting to 0.4

Tried to use, but now its wont compiling, and idk C++
 
Back
Top