Forum

> > CS2D > Scripts > first/second/third score
Forums overviewCS2D overview Scripts overviewLog in to reply

English first/second/third score

13 replies
To the start Previous 1 Next To the start

old first/second/third score

loldlold123
User Off Offline

Quote
hello guys,can someone help me about that

if one player has got best score then message will be appread "player got to first place" but only if player exist currently. when he leaves someone else will be at the first place
and same as second and third (needed with table)
edited 1×, last 10.07.12 12:43:21 pm

old Re: first/second/third score

Alistaire
User Off Offline

Quote
Score on what, kills? You should add a hook for kills or just paste some function which checks scores after a part of the script which can get you scores.

old Re: first/second/third score

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
addhook("second","topscore")
function topscore()
	local scores={}
	for _,id in pairs(player(0,"table")) do
		table.insert(scores,{id,player(id,"score")})
	end
	table.sort(scores,function(a,b) return a[2]>b[2] end)
	parse('hudtxt 1 "Top scores:" 16 240')
	parse('hudtxt 2 "1. '..player(scores[1][1],"name")..' ('..scores[1][2]..')" 16 256')
	parse('hudtxt 3 "2. '..player(scores[2][1],"name")..' ('..scores[2][2]..')" 16 272')
	parse('hudtxt 4 "3. '..player(scores[3][1],"name")..' ('..scores[3][2]..')" 16 288')
end

I'm quite sure that works.

old Re: first/second/third score

loldlold123
User Off Offline

Quote
it works,but it gives error when there are less then 3 players so what was the code of if player number>3 then ? i forgot it...if there is tell me, if there is no i'll put "player counter" and player=player+1 thing you know

old Re: first/second/third score

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("second","topscore")
function topscore()
	local scores={}
	for _,id in pairs(player(0,"table")) do
		table.insert(scores,{id,player(id,"score")})
	end
	table.sort(scores,function(a,b) return a[2]>b[2] end)
	parse('hudtxt 1 "Top scores:" 16 240')
	for i=1,#scores do
		if i<=3 then
			parse('hudtxt '..i+1 ..' "'..i..'. '..player(scores[i][1],"name")..' ('..scores[i][2]..')" 16 '..(256+16*(i-1)))
		end
	end
end

old Re: first/second/third score

EngiN33R
Moderator Off Offline

Quote
@user Alistaire: Good point.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
addhook("die","topscore")
addhook("flagcapture","topscore")
addhook("bombexplode","topscore")
addhook("bombdefuse","topscore")
addhook("endround","topscore")
addhook("parse","topscore")
addhook("rcon","topscore")
addhook("hostagerescue","topscore")
addhook("join","topscore")
addhook("leave","topscore")
function topscore()
	local scores={}
	for _,id in pairs(player(0,"table")) do
		table.insert(scores,{id,player(id,"score")})
	end
	table.sort(scores,function(a,b) return a[2]>b[2] end)
	parse('hudtxt 1 "Top scores:" 16 240')
	for i=1,#scores do
		if i<=3 then
			parse('hudtxt '..i+1 ..' "'..i..'. '..player(scores[i][1],"name")..' ('..scores[i][2]..')" 16 '..(256+16*(i-1)))
		end
	end
end
edited 1×, last 10.07.12 03:38:56 pm

old Re: first/second/third score

Alistaire
User Off Offline

Quote
Also, the score is 'Crimepoint[id]', which is earned on playerkill. This means that you could make 1 function which updates the hud, only called at playerkill. Also, if someone leaves it should also update.

old Re: first/second/third score

Infinite Rain
Reviewer Off Offline

Quote
Maybe he need to return SERVER'S BEST players
Not only online best players.
I know how to get only top 30

Edit: OH nvm, I failed again...

old Re: first/second/third score

EngiN33R
Moderator Off Offline

Quote
Also, user loldlold123, please do not specify in each of your threads that the code you need should contain tables. If they must be done, they will be done, you don't need to specify that every time.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview