Yes i think what i did is corrects, but i don't know why it don't works xD
I can show you my code : (i didn't make the repeat of the updating function yet)
Server = {};
local port = System.GetCVar("sv_port") or 64087
local name = System.GetCVar("sv_servername")
local numPlayers = 0
local maxPlayers = tonumber(System.GetCVar("sv_maxplayers")) or 16
local mapPath = System.GetCVar("sv_map") or ""
local mapDownloadLink = ""
local desc = "Test_noSFW"
local rank = System.GetCVar("sv_ranked") or 0
local pass = System.GetCVar("sv_password") or ""
function Server:RequestHTTP(url)
os.execute("curl.exe ""..url.."" > output.tmp")
local f,err=io.open("output.tmp","r")
if f then
local content=f:read("*all")
f:close()
return content
else return nil end
end
function urlencode(str)
if type(str)=="string" then return str:gsub("[^a-zA-Z0-9]",function(chr) return string.format("%%%02X",chr:byte(1,1)) end)
else return str end
end
function Server:Register(port, name, numPlayers, maxPlayers, mapPath, mapDownloadLink, timeLeft)
mapDownloadLink=mapDownloadLink or "" -- http link to map download
timeLeft=timeLeft or 0 --remaining round time in seconds
pass = System.GetCVar("sv_password") or ""
local result = Server:RequestHTTP("http://crymp.net/api/reg.php?ver=6156&port="..urlencode(port).."&name="..urlencode(name).."&desc="..desc.."&pass="..pass.."&numpl="..numPlayers.."&maxpl="..maxPlayers.."&map="..urlencode(mapPath).."&ranked="..rank.."&timel="..timeLeft.."&local=localhost");
local token=string.match(result,"<<Cookie>>([a-z0-9]-)<<")
return token
end
local cookie = Server:Register(port, name, numPlayers, maxPlayers, mapPath, mapDownloadLink, g_gameRules.game:GetRemainingGameTime())
function Server:Update(token)
local result = Server:RequestHTTP("http://crymp.net/api/up.php?&port="..urlencode(port).."&numpl="..numPlayers.."&name="..urlencode(name).."&desc="..desc.."&pass=".."&ver=6156".."&cookie="..token.."&map="..urlencode(mapPath).."&ranked="..rank.."&timel="..g_gameRules.game:GetRemainingGameTime().."&local=localhost")
System.LogAlways("-----UPDATING------") --not finished but it should at least show max players number at startup..
end
Server:Update(cookie)
❤️ 0