Forum

> > CS2D > Scripts > Ranking System
Forums overviewCS2D overview Scripts overviewLog in to reply

English Ranking System

7 replies
To the start Previous 1 Next To the start

old Ranking System

ReVoltage
User Off Offline

Quote
Hello us ,
I want to make a Rank System like "Top 30 player kill"
I just want to know:
1) How to make script that can load ALL data (notepad) in a folder
2) How to sort player kill from highest to lowest
Thx before
Sorry if i had a bad english

old Re: Ranking System

_Yank
User Off Offline

Quote
I can't understand you at all. Also you will need to use io.library, at least is what i think.
But to dont use it always, use an array system.

Lets talk on skype, will send you my by private message.
edited 1×, last 29.07.13 01:45:34 pm

old Re: Ranking System

ReVoltage
User Off Offline

Quote
@user Gajos: I cant understand the code
Im a newbie scripter that want to learn more
I dont want to use script that i cant understand

@user _Yank: Yeah i use Array to save the player kill, that why i want a script to load all file in a folder.
Sad, i dont have Skype

old Re: Ranking System

Thug Life
User Off Offline

Quote
@user ReVoltage: If you don't know how to make scripts and you want to learn, look here and you'll learn
This tutorial helped me to understand and make scripts, so maybe it will be good for you too

old Re: Ranking System

ReVoltage
User Off Offline

Quote
user Thug Life has written
@user ReVoltage: If you don't know how to make scripts and you want to learn, look here and you'll learn
This tutorial helped me to understand and make scripts, so maybe it will be good for you too

I can make lua script, but this script is above my skill
Btw, I never open that site but i can make lua.

old Re: Ranking System

_Yank
User Off Offline

Quote
Sorry i get lazy after think about how long the script will be. But i think you can complete it. Here it is
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
plrnumber = io.open('sys/lua/ranksys/howmuch.txt','r')
pl_number=plrnumber:read() 
plrnumber:close()

function initArray(m)
	local initArray = {}
	for i = 1, m do
		initArray[i] = 0
	end
	return initArray
end

pl_count = game('sv_maxplayers')
pl_ratio = initArray(pl_count)
pl_rank = initArray(pl_count)
pl_frags = initArray(pl_count)
pl_deaths = initArray(pl_count)
pl_score = initArray(pl_count)

addhook("join","clear")
function clear(id)
	if player(id,"usgn") > 0 then
		plr_rank = io.open('sys/lua/ranksys/'..player(id,"usgn")..'.txt','r')
		if (plr_data ~= nil) then
			for line in io.lines('sys/lua/ranksys/'..player(id,"usgn")..'.txt','r') do
				local parses = totable(line)
				if (tonumber(parses[1]) > 0) then
					pl_rank[id] = tonumber(parses[1])
					pl_score[id] = tonumber(parses[2])
					pl_frags[id] = tonumber(parses[3])
					pl_deaths[id] = tonumber(parses[4])
					pl_ratio[id] = tonumber(parses[5])
				end
			end
		else
			adduser(id)
			pl_crank = io.open('sys/lua/ranksys/'..player(id,"usgn")..'.txt','w')
			pl_crank:write('0 \n') -- rank
			pl_crank:write('0 \n') -- score
			pl_crank:write('0 \n') -- frags
			pl_crank:write('0 \n') -- deaths
			pl_crank:write('0 \n') -- ratio	
			pl_crank:close()
		end
	end			
end

addhook("kill","add_kill")
function add_kill(id)
	pl_frags[id] = pl_frags[id] + 1
	pl_updaterank(id)
end

addhook("die","add_die")
function add_die(victim)
	pl_deaths[id] = pl_deaths[id] + 1
	pl_updaterank(id)
end

function adduser(id)
	pl_number = pl_number + 1
	playernumber = io.open('sys/lua/ranksys/howmuch.txt','w+')
	playernumber:write(''..pl_number..'') -- rank
	playernumber:close()
end

function pl_updaterank(id)
	pl_ratio[id]=pl_frags[id] / pl_deaths[id]
end

gamemode = game('sv_gamemode')

addhook("say","pl_sayrank")
function pl_sayrank(id,txt)
	if txt == rank then
		if player(id,"usgn")>0 then
			if player(id,"team")==1 and gamemode == 2 or gamemode == 3 or gamemode == 4 then
				msg('©000000255'..player(id,"name")..': ©255230010'..txt)
				msg('Rank '..pl_rank[id]..' of '..pl_number)
			elseif player(id,"team")==2 and gamemode == 2 or gamemode == 3 or gamemode == 4 then
				msg('©255000000'..player(id,"name")..': ©255230010'..txt)
				msg('Rank '..pl_rank[id]..' of '..pl_number)
			elseif player(id,"team")==0 and gamemode == 2 or gamemode == 3 or gamemode == 4 then
				msg(player(id,"name")..': '..txt)
				msg('Rank '..pl_rank[id]..' of '..pl_number)
			elseif player(id,"team")==1 or player(id,"team")==2 and gamemode == 0 or gamemode == 1 then
				msg('©000255000'..player(id,"name")..': ©255230010'..txt)
				msg('Rank '..pl_rank[id]..' of '..pl_number)
			end
		else 
			msg2('©255000000Your not registered! Make an account at unrealsoftware.de')
			msg(player(id,"name")..' is not registered!')
		end
		return "1"
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview