Forum

> > CS2D > Scripts > High Point Check
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch High Point Check

1 Antwort
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt High Point Check

Syph
User Off Offline

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

alt Re: High Point Check

Apache uwu
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht