Example :
If player say !RANK (not rank, it is !rank)
then msg : YOUR RANK IS XXX
Can you help me ?
Scripts
LUA show rank ?
LUA show rank ?
1

if RANK_LUA ~= nil then return end
RANK_LUA = 1
local INTERVAL = 60
local rank_players = {}
local rank_nextrefresh = 0
local rank_refreshedrows = 0
function rank_get(usgn, maxrows)
	if maxrows == nil then maxrows = math.huge end
	if os.clock() > rank_nextrefresh or maxrows > rank_refreshedrows then rank_refreshtable(maxrows) end
	local stats = rank_players[usgn]
	return stats ~= nil and rank_players[usgn][1] or math.huge
end
function rank_refreshtable(maxrows)
	local buff
	
	rank_players = {}
	
	local f = io.open(CS2D_ROOT .. "sys/stats/userstats.dat", "rb")
	if f == nil then return end
	
	f:read("*l")
	for i = 1, maxrows do
		local stats = {}
		
		stats[1] = i
		
		buff = f:read("*l")
		if buff == nil then break end
		stats[2] = buff
		
		buff = f:read(20)
		if buff == nil then break end
		for i = 1, 20, 4 do
			table.insert(stats, binstr2num(string.sub(buff, i, i+4)))
		end
		rank_players[stats[3]] = stats
		rank_refreshedrows = i
	end
	
	f:close()
	
	rank_nextrefresh = os.time() + INTERVAL
	if maxrows == math.huge then rank_refreshedrows = math.huge end
end
function binstr2num(str)
	local b1, b2, b3, b4 = string.byte(str, 1, 4)
	return b4 * 0x100000 + b3 * 0x10000 + b2 * 0x100 + b1
end
rank_refreshtable(math.huge)
if RANK_LUA ~= nil then return end
RANK_LUA = 1
local INTERVAL = 60
local rank_players = {} -- PUT USGN IDs HERE
local rank_nextrefresh = 0
local rank_refreshedrows = 0
function rank_get(usgn, maxrows)
if maxrows == nil then maxrows = math.huge end
if os.clock() > rank_nextrefresh or maxrows > rank_refreshedrows then rank_refreshtable(maxrows) end
local stats = rank_players[usgn]
return stats ~= nil and rank_players[usgn][1] or math.huge
end
function rank_refreshtable(maxrows)
local buff
rank_players = {}
local f = io.open("sys/stats/userstats.dat", "rb")
if f == nil then return end
f:read("*l")
for i = 1, maxrows do
local stats = {}
stats[1] = i
buff = f:read("*l")
if buff == nil then break end
stats[2] = buff
buff = f:read(20)
if buff == nil then break end
for i = 1, 20, 4 do
table.insert(stats, binstr2num(string.sub(buff, i, i+4)))
end
rank_players[stats[3]] = stats
rank_refreshedrows = i
end
f:close()
rank_nextrefresh = os.time() + INTERVAL
if maxrows == math.huge then rank_refreshedrows = math.huge end
end
function binstr2num(str)
local b1, b2, b3, b4 = string.byte(str, 1, 4)
return b4 * 0x100000 + b3 * 0x10000 + b2 * 0x100 + b1
end
rank_refreshtable(math.huge)
huh=GetUserStatRank(53360) if huh.isexists then 	-- Get necessary information, like time on server else 	-- The usgn doesn't exist(or never enter the server) end
addhook("say","Potato")
function Potato(id,txt)
if (txt == "!myrank") then
local name = player(id, "name")
local usgn = player(id, "usgn")
local ip = player(id, "ip")
parse("sv_msg2 " .. id .. " Stats for ©000255255" .. name .. "")
parse("sv_msg2 " .. id .. " ©000255000USGN: ©000255255" .. usgn)
return 1
	end
end
1
