Forum

> > CS2D > Scripts > +1 each level
Forums overviewCS2D overview Scripts overviewLog in to reply

English +1 each level

3 replies
To the start Previous 1 Next To the start

old +1 each level

RebornDuck
User Off Offline

Quote
Hello!

I want that some numbers increase with 1 each time you level up. I have been trying to figure it out but I can't come up with anything.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("ms100","save_hud")
function save_hud()
     for id = 1,32 do
          if (player(id,"exists")) then
			parse('hudtxt2 '..id..' 48 "©000100255Level: '..level[id]..' " 230 445')
			parse('hudtxt2 '..id..' 49 "©000100255Kills needed: '..exp[id]..'/5 " 230 460')
		end
	end
end

addhook("kill","save_kill")
function save_kill(id)
	exp[id]=exp[id]+1
	if exp[id] == 5 then
		exp[id]=0
		level[id]=level[id]+1
		msg2(id,"©000255000Level up!@C")
		msg("©255075000"..player(id,"name").." reached "..level[id].." level!")
	end
end

How can I do so the number 5 (line 6) and the number 5 (line 14) increases with 1 each time you lvl up?
The script does that it takes 5 kills to lvl up but I want to increase it with 1 kill each level (lvl 1 = 5 kills, lvl 2 = 6 kills, etc)

Thanks.

NOTE: There's more script over and under that.

old Re: +1 each level

Gajos
BANNED Off Offline

Quote
this is very easy.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("ms100","save_hud")
function save_hud()
     for id = 1,32 do
          if (player(id,"exists")) then
               parse('hudtxt2 '..id..' 48 "©000100255Level: '..level[id]..' " 230 445')
               parse('hudtxt2 '..id..' 49 "©000100255Kills needed: '..exp[id]..'/'..(level[id] + 4)..' " 230 460')
          end
     end
end

addhook("kill","save_kill")
function save_kill(id)
     exp[id] = exp[id] + 1
     if exp[id] == level[id] + 4 then
          exp[id] = 0
          level[id] = level[id] + 1
          msg2(id,"©000255000Level up!@C")
          msg("©255075000"..player(id,"name").." reached "..level[id].." level!")
     end
end

old Re: +1 each level

Alistaire
User Off Offline

Quote
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
function array(s, e, l)
	local a = {}
	for i = s, e do
		a[i] = l
	end
	return a;
end

local plr = {level = array(1, 32, 1), exp = array(1, 32, 0)}

addhook('kill', 'killHook')

function neededForLevel(level)
	local needed = level * 2 - 1
	return needed;
end

function updateHud(id)
	function update(id)
		parse('hudtxt2 '..id..' 49 "©000100255Level: '..plr.level[id]..'" 230 445')
		parse('hudtxt2 '..id..' 48 "©000100255Kills: '..plr.exp[id]..' / '..neededForLevel(plr.level[id])..'" 230 460')
	end
	if id then
		update(id)
	else
		for _,id in pairs(player(0, 'table')) do
			update(id)
		end
	end
end

function checkLevelUp(id)
	if plr.exp[id] == neededForLevel(plr.level[id]) then
		plr.exp[id] = 0
		plr.level[id] = plr.level[id] + 1
		return true;
	else
		return false;
	end
end

function killHook(id)
	plr.exp[id] = plr.exp[id] + 1
	if checkLevelUp(id) then
		msg2(id, "©050200050-Level up-@C")
		msg('©050200050'..player(id, 'name')..' reached level '..plr.level[id])
	end
	updateHud(id)
end

This is more efficient. Like, really much more efficient.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview