Forum
CS2D General Allow for Top 10Allow for Top 10
9 replies 1
usgnid
rank
From what can I see in the docs, it works only for users.. I'm not sure about Steam users.
You can use stats and steamstats
1
2
3
4
5
6
2
3
4
5
6
function isTop10(id) if stats(player(id,"usgn"), "rank") <= 10 or steamstats(player(id,"steamid"), "rank") <= 10 then return true end return false end
stats & steamstats has written
rank: gets the current rank of the player on the server 1 for the best (0 if unranked)
This means the current check at the moment not only considers the top 10 players valid, but also considers unranked players valid.
stats & steamstats has written
The command returns the boolean value false if stats are not available for the specified U.S.G.N. / Steam ID or if wrong parameters are specified.
If you have players that don't actually use both USGN and Steam, then the code kinda bugs out because one or all of the checks is comparing a number to a boolean.
So I'd do something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function isTop10(id) 	local uid, sid = player(id,"usgn"), player(id,"steamid") 	if stats(uid,"exists") then 		local u = stats(uid,"rank") 		if u > 0 and u <= 10 then 			return true 		end 	end 	if steamstats(sid,"exists") then 		local s = steamstats(sid,"rank") 		if s > 0 and s <= 10 then 			return true 		end 	end 	return false end
edited 2×, last 25.09.19 06:55:49 am
Top 20? So it's like Top 10 for USGN + Top 10 for Steam? Who can fix it?
edited 1×, last 13.05.19 11:28:28 pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
rankTab = {} function initRankTable() 	rankTab = {} 	-- combine the USGN and Steam ranking charts while accounting for duplicates (if any) 	local i = 1 	for _, id in pairs(player(0,"table")) do 		local ukdr, skdr = 0, 0 		local uid, sid = player(id,"usgn"), player(id,"steamid") 		if stats(uid,"exists") then 			local ur = stats(uid,"rank") 			if ur > 0 and ur <= 10 then 				ukdr = stats(uid,"killsperdeath") 			end 		end 		if steamstats(sid,"exists") then 			local sr = steamstats(sid,"rank") 			if sr > 0 and sr <= 10 then 				skdr = steamstats(sid,"killsperdeath") 			end 		end 		if ukdr > 0 or skdr > 0 then 			if ukdr > skdr then 				rankTab[i].id = uid 				rankTab[i].kdr = ukdr 			else 				rankTab[i].id = sid 				rankTab[i].kdr = skdr 			end 			i = i + 1 		end 	end 	-- sorting it out 	if #rankTab > 0 then 		table.sort(rankTab,function(k1,k2) return k1.kdr > k2.kdr end) 	end end function isTop10(id) 	initRankTable() 	if #rankTab > 0 then 		for x = 1, math.min(#rankTab,10) do 			local t = type(rankTab[x].id) 			if t == "number" then 				if rankTab[x].id == player(id,"usgn") then 					return true 				end 			elseif t == "string" then 				if rankTab[x].id == player(id,"steamid") then 					return true 				end 			end 		end 	end 	return false end
edited 2×, last 14.05.19 12:50:20 pm
1