Forum

> > CS2D > Scripts > Function Script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Function Script

2 replies
To the start Previous 1 Next To the start

old Function Script

ViTalIty
User Off Offline

Quote
i have a script which i download called Team deathmatch score. it pretty good except it restarts the round after whichever team reaches the final score. i found a function caled function tdm.restart and was wondering if i could configure this so instead of restart it start a new round and a score to the winning team of last round so they can keep there kills and etc. and so buy the end of the round limit(5) it changes map. oh just in case here is the whole script

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
tdm = {}
-- Final score, 0 to disable
tdm.FinalScore = 25
-----------
tdm.CTscore = 0
tdm.Tscore = 0
tdm.End = false

addhook('die','tdm.kill')
function tdm.kill(k)
	if tdm.End == false then
		if player(k,'team') == 1 then tdm.CTscore = tdm.CTscore + 1; tdm.update(); end
		if player(k,'team') == 2 then tdm.Tscore = tdm.Tscore + 1; tdm.update(); end
		if tdm.Tscore == tdm.FinalScore and tdm.FinalScore ~= 0 then msg('©225050050'..tdm.Tscore..' - '..tdm.CTscore..'! Terrorists win!'); parse("sv_sound \"radio/terwin.ogg\""); tdm.End = true; timer(5000,"tdm.restart") end
		if tdm.CTscore == tdm.FinalScore and tdm.FinalScore ~= 0 then msg('©065105225'..tdm.CTscore..' - '..tdm.Tscore..'! Counter-Terrorists win!'); parse("sv_sound \"radio/ctwin.ogg\""); tdm.End = true; timer(5000,"tdm.restart") end
	end
end

function tdm.restart()
parse('restart')
end

function tdm.update()
	if tdm.End == false then
		for i = 1,game('sv_maxplayers') do
			if player(i,'exists') and player(i,'team') == 1 then
				parse('hudtxt2 '..i..' 1 "©225050050T: '..tdm.Tscore..' / '..tdm.FinalScore..'" 320 15 2')
				parse('hudtxt2 '..i..' 2 "©065105225CT: '..tdm.CTscore..' / '..tdm.FinalScore..'" 320 30 2')
			end
			if player(i,'exists') and player(i,'team') == 2 then
				parse('hudtxt2 '..i..' 2 "©065105225CT: '..tdm.CTscore..' / '..tdm.FinalScore..'" 320 15 2')
				parse('hudtxt2 '..i..' 1 "©225050050T: '..tdm.Tscore..' / '..tdm.FinalScore..'" 320 30 2')
			end
			if player(i,'team') == 0 then
				parse('hudtxt2 '..i..' 1 "T: '..tdm.Tscore..' / '..tdm.FinalScore..'" 330 45 2')
				parse('hudtxt2 '..i..' 2 "CT: '..tdm.CTscore..' / '..tdm.FinalScore..'" 330 60 2')
			end
		end
	end
end

addhook('startround','tdm.startround')
function tdm.startround()
tdm.CTscore = 0
tdm.Tscore = 0
tdm.End = false
tdm.update()
end

addhook('team','tdm.team')
function tdm.team(id,team)
	if team == 1 then
		parse('hudtxt2 '..id..' 1 "©225050050T: '..tdm.Tscore..' / '..tdm.FinalScore..'" 320 15 2')
		parse('hudtxt2 '..id..' 2 "©065105225CT: '..tdm.CTscore..' / '..tdm.FinalScore..'" 320 30 2')
	end
	if team == 2 then
		parse('hudtxt2 '..id..' 2 "©065105225CT: '..tdm.CTscore..' / '..tdm.FinalScore..'" 320 15 2')
		parse('hudtxt2 '..id..' 1 "©225050050T: '..tdm.Tscore..' / '..tdm.FinalScore..'" 320 30 2')
	end
	if team == 0 then
		parse('hudtxt2 '..id..' 1 "T: '..tdm.Tscore..' / '..tdm.FinalScore..'" 330 45 2')
		parse('hudtxt2 '..id..' 2 "CT: '..tdm.CTscore..' / '..tdm.FinalScore..'" 330 60 2')
	end
end

old Re: Function Script

KimKat
GAME BANNED Off Offline

Quote
Can't keep scores as you restart... that's impossible I think. Unless you modify the Lua code in order to cache/store/save the previous values from last session and apply it to the new session. The values must be automaticly incremented aswell in order for the Lua script to be fully functional. That's my analysis of this Lua code and unfortunally I'm not really that much into Lua scripting at the moment, so perhaps someone else experienced with Lua might lend you a hand at fixing this problem but that is if they're willing too. Be patient.

I know just that you can write values into a text file and read from it. This method might come handy in your case.

old Re: Function Script

ViTalIty
User Off Offline

Quote
user KimKat has written
Can't keep scores as you restart... that's impossible I think. Unless you modify the Lua code in order to cache/store/save the previous values from last session and apply it to the new session. The values must be automaticly incremented aswell in order for the Lua script to be fully functional. That's my analysis of this Lua code and unfortunally I'm not really that much into Lua scripting at the moment, so perhaps someone else experienced with Lua might lend you a hand at fixing this problem but that is if they're willing too. Be patient.

I know just that you can write values into a text file and read from it. This method might come handy in your case.


thanx for the reply, are there any scripts similar to the one i showed but does saves the scores and doesn't restart the round but just add a score to the wining team? if so it would be really helpful
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview