Forum

> > CS2D > Scripts > first/second/third score
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch first/second/third score

13 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt first/second/third score

loldlold123
User Off Offline

Zitieren
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)
1× editiert, zuletzt 10.07.12 12:43:21

alt Re: first/second/third score

Alistaire
User Off Offline

Zitieren
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.

alt Re: first/second/third score

EngiN33R
Moderator Off Offline

Zitieren
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.

alt Re: first/second/third score

loldlold123
User Off Offline

Zitieren
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

alt Re: first/second/third score

EngiN33R
Moderator Off Offline

Zitieren
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

alt Re: first/second/third score

EngiN33R
Moderator Off Offline

Zitieren
@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
1× editiert, zuletzt 10.07.12 15:38:56

alt Re: first/second/third score

Alistaire
User Off Offline

Zitieren
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.

alt Re: first/second/third score

Infinite Rain
Reviewer Off Offline

Zitieren
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...

alt Re: first/second/third score

EngiN33R
Moderator Off Offline

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