Created
September 13, 2012 05:07
-
-
Save FloooD/3712002 to your computer and use it in GitHub Desktop.
cheathunter server lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ip = '91.239.66.190' -- Your server IP address -> example '192.168.0.5' | |
local port = '36963' -- Your server port number -> example '36963' | |
local interval = 5 -- DO NOT EDIT | |
local host = 'http://cheathunter.tk/' -- DO NOT EDIT | |
local file = 'serverinfo.php' -- DO NOT EDIT | |
local h | |
os.execute("touch "..file) | |
function dlData() | |
if h then h:close() end | |
h = io.popen("wget -q -O "..file.." "..host..file.."?ip="..ip..":"..port) | |
end | |
timer(1000*interval, "dlData", "", 0) | |
function readData() | |
f = assert(io.open(file, "r")) | |
s = f:read("*a") | |
f:close() | |
return s | |
end | |
local tries = {} | |
for i = 1, 32 do | |
tries[i] = 0 | |
end | |
function CH_Reset( id ) | |
tries[id] = 0 | |
end | |
addhook("join", "CH_Reset") | |
addhook("leave", "CH_Reset") | |
function CH_Check() | |
data = readData() | |
if(data == "niepoprawne ip") then | |
print('Invalid ip address: "'..ip..':'..port..'"') | |
return | |
end | |
local valid = {} | |
for id in string.gmatch(data, "(%d+)[^%d]*") do | |
valid[tonumber(id)] = true | |
end | |
for _,id in pairs(player(0,"table")) do | |
if valid[id] then | |
tries[id] = 0 | |
else | |
tries[id] = tries[id] + 1 | |
if tries[id] > 2 then | |
parse("msg ©138200000CheatHunter: player "..player(id,"name").." kicked - no heartbeats.") | |
parse('kick '..id..' "©138200000This server requires CheatHunter Anticheat..\n©138200000Get it at »cheathunter.tk«"') | |
end | |
end | |
end | |
end | |
function addChecktimer() | |
timer(1000*interval, "CH_Check", "", 0) | |
freetimer("addChecktimer") | |
end | |
timer(1000*interval/2, "addChecktimer", "", 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment