Forum

> > CS2D > Scripts > High Point Check
Forums overviewCS2D overview Scripts overviewLog in to reply

English High Point Check

1 reply
To the start Previous 1 Next To the start

old High Point Check

Syph
User Off Offline

Quote
How do i make the server check who has the highest point on the server
basing on Point[id] ?

old Re: High Point Check

Apache uwu
User Off Offline

Quote
Here you go!

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
addhook("second","_second")

function _second()
	local tmp,tmp2=greatestScore()
	if #tmp2==1 then
		msg(player(tmp2[1],"name").." has the greatest score. ("..tmp..")")
	else
		msg("There are "..#tmp2.." people with the greatest score of "..tmp..".")
		for _,id in ipairs(tmp2) do
			msg("-- "..player(id,"name").." --")
		end
	end
end

function greatestScore()
	local tmp={}
	local tmp2={}
	for _,id in ipairs(player(0,"table")) do
		table.insert(tmp,player(id,"score"))
	end
	for _,id in ipairs(player(0,"table")) do
		if math.max(unpack(tmp))==player(id,"score") then
			table.insert(tmp2,id)
		end
	end
	return math.max(unpack(tmp)),tmp2
end

greatestScore() returns 2 values:
     the greatest score and a table of the people who have this score

In this example: every second will message the people with the greatest score.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview