dawnking
Member
- Joined
- Jun 23, 2016
- Messages
- 176
- Reaction score
- 22
Hello, i've tried to add this old script to protect server...
How work: When server avarange IP get to high, it kick all players to protect in a DDOS attack
It's just need some sources edits, thats i made in:
look for: // getOtsysTime() + getPlayerPing(cid) + doPlayerSendPing(cid)
- luascript.cpp(3x) e luascript.h
luascript.cpp
http://hastebin.com/umodedehuy.go
luascript.h
http://hastebin.com/xonixeluqe.cpp
Script:
The problem:
I was test in localhost, only me in 1 character login, and thats is what print on console:
How work: When server avarange IP get to high, it kick all players to protect in a DDOS attack
It's just need some sources edits, thats i made in:
look for: // getOtsysTime() + getPlayerPing(cid) + doPlayerSendPing(cid)
- luascript.cpp(3x) e luascript.h
luascript.cpp
http://hastebin.com/umodedehuy.go
luascript.h
http://hastebin.com/xonixeluqe.cpp
Script:
Code:
<globalevent name="ddosprotect" interval="1000" event="script" value="antiddos.lua"/>
Code:
function onThink(interval, lastExecution)
local averageServerPing = 0
local playerCount = 0
for _, cid in ipairs(getPlayersOnline()) do
averageServerPing = (playerGetLastPing(cid) + averageServerPing)
print(playerGetLastPing)
playerCount =_
end
averageServerPing = (averageServerPing / playerCount)
print(averageServerPing)
if averageServerPing > 2000 then
doBroadcastMessage("DDos attack! Everyone will be kicked")
for _, cid in ipairs(getPlayersOnline()) do
addEvent(function(cid)
doRemoveCreature(cid)
end, 1000, cid)
end
end
return TRUE
end
The problem:
I was test in localhost, only me in 1 character login, and thats is what print on console:
Code:
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
-nan
[16:57:15.345] Daniel has logged in.
1480964235200
> Broadcasted message: "DDos attack! Everyone will be kicked".
[16:57:17.290] Daniel has logged out.
-nan
-nan
-nan
-nan
-nan
-nan