Forum

> > CS2D > General > Moving the position of a Script
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Moving the position of a Script

10 replies
To the start Previous 1 Next To the start

old Moving the position of a Script

ViTalIty
User Off Offline

Quote
hi i have a "timelimit" script for my server(it's dedicated) but im not so well educated with LUA. i wanna put the time limit's position on the bottom middle part of the game(where the default timer is). can someone look at this script and tell me which part to edit to get the script into tht position?

Also I take no copyright of this sript all credits go to the owner

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
-------------------
-- Mod by HaRe   --
-- Time For TDM  --
-------------------

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

timer=0
time=600 -- Change it to your time (OPS this is for Second) so if you want 1 min then type 60
playerdeath = Array(32)
playerscore = Array(32)

addhook("startround","time_start")
function time_start()
timer=0
	for id = 1,32 do
		if (player(id,"exists")) then
			parse("setdeaths "..id.." "..playerdeath[id])
			parse("setscore "..id.." "..playerscore[id])
		end
	end
end

addhook("second","time_go")
function time_go()
timer=timer+1
	if timer==time then
		parse("restart 3")
		msg("©255255255Round has ended, Get ready for another round!@C")
	end
end

addhook("ms100","time_savescore")
function time_savescore()
	for id = 1,32 do
		if (player(id,"exists")) then
			playerscore[id]=player(id,"score")
			playerdeath[id]=player(id,"deaths")
		end
	end
end

addhook("ms100","time_hud")
function time_hud()
	parse('hudtxt 1 "©000500000Time: ('..timer..'/'..time..') "100 70')
	if timer==time then
		parse('hudtxt 1 "©500000000Time: Round Ended "100 70')
	elseif timer>time then
		parse('hudtxt 1 "©500000000Time: Round Ended "100 70')
	end
end

old Re: Moving the position of a Script

Yates
Reviewer Off Offline

Quote
user ViTalIty has written
1
2
3
4
5
6
7
8
9
addhook("ms100","time_hud")
function time_hud()
	parse('hudtxt 1 "©000500000Time: ('..timer..'/'..time..') "100 70')
	if timer==time then
		parse('hudtxt 1 "©500000000Time: Round Ended "100 70')
	elseif timer>time then
		parse('hudtxt 1 "©500000000Time: Round Ended "100 70')
	end
end

This part. Edit the two "100 70"s The middle bottom of the screen should probably be 255 200. If not you must try yourself.

old Re: Moving the position of a Script

ViTalIty
User Off Offline

Quote
user Yates has written
user ViTalIty has written
1
2
3
4
5
6
7
8
9
addhook("ms100","time_hud")
function time_hud()
	parse('hudtxt 1 "©000500000Time: ('..timer..'/'..time..') "100 70')
	if timer==time then
		parse('hudtxt 1 "©500000000Time: Round Ended "100 70')
	elseif timer>time then
		parse('hudtxt 1 "©500000000Time: Round Ended "100 70')
	end
end

This part. Edit the two "100 70"s The middle bottom of the screen should probably be 255 200. If not you must try yourself.


Thanx for the quick reply but i didn't make a difference

old Re: Moving the position of a Script

Bowlinghead
User Off Offline

Quote
Maybe the marked numbers are wrong?
Every Hudtxt has his own ID.
"hudtxt <id> "<text>" <position 1-x> <position 2-y>"
So you have to change the ids

user ViTalIty has written
addhook("ms100","time_hud")
function time_hud()
     parse('hudtxt 1 "©000500000Time: ('..timer..'/'..time..') "100 70')
     if timer==time then
          parse('hudtxt 2 "©500000000Time: Round Ended "100 70')
     elseif timer>time then
          parse('hudtxt 3 "©500000000Time: Round Ended "100 70')
     end
end

btw= >= means if something is same or higher. So you can make it a littlebit shorter!

old Re: Moving the position of a Script

ViTalIty
User Off Offline

Quote
user Bowlinghead has written
Oh, I forget it.
EDIT:
If you want to do it in the middle, watch this!
cs2d cmd hudtxt

Perfect middle is:
X 320; Y 240; Align 1

thanks guys hey by any chance can you put that in a code format? i don't really get it so much

old Re: Moving the position of a Script

Bowlinghead
User Off Offline

Quote
Sure

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
-------------------
-- Mod by HaRe --
-- Time For TDM --
-------------------

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

timer=0
time=600 -- Change it to your time (OPS this is for Second) so if you want 1 min then type 60
playerdeath = Array(32)
playerscore = Array(32)

addhook("startround","time_start")
function time_start()
timer=0
     for id = 1,32 do
          if (player(id,"exists")) then
               parse("setdeaths "..id.." "..playerdeath[id])
               parse("setscore "..id.." "..playerscore[id])
          end
     end
end

addhook("second","time_go")
function time_go()
timer=timer+1
     if timer==time then
          parse("restart 3")
          msg("©255255255Round has ended, Get ready for another round!@C")
     end
end

addhook("ms100","time_savescore")
function time_savescore()
     for id = 1,32 do
          if (player(id,"exists")) then
               playerscore[id]=player(id,"score")
               playerdeath[id]=player(id,"deaths")
          end
     end
end

addhook("ms100","time_hud")
function time_hud()
     parse('hudtxt 1 "©000500000Time: ('..timer..'/'..time..') "320 240')
     if timer==time then
          parse('hudtxt 1 "©500000000Time: Round Ended "320 240')
     elseif timer>time then
          parse('hudtxt 1 "©500000000Time: Round Ended "320 240')
     end
end

-- Now its perfect

old Re: Moving the position of a Script

ViTalIty
User Off Offline

Quote
user Bowlinghead has written
Sure

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
-------------------
-- Mod by HaRe --
-- Time For TDM --
-------------------

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

timer=0
time=600 -- Change it to your time (OPS this is for Second) so if you want 1 min then type 60
playerdeath = Array(32)
playerscore = Array(32)

addhook("startround","time_start")
function time_start()
timer=0
     for id = 1,32 do
          if (player(id,"exists")) then
               parse("setdeaths "..id.." "..playerdeath[id])
               parse("setscore "..id.." "..playerscore[id])
          end
     end
end

addhook("second","time_go")
function time_go()
timer=timer+1
     if timer==time then
          parse("restart 3")
          msg("©255255255Round has ended, Get ready for another round!@C")
     end
end

addhook("ms100","time_savescore")
function time_savescore()
     for id = 1,32 do
          if (player(id,"exists")) then
               playerscore[id]=player(id,"score")
               playerdeath[id]=player(id,"deaths")
          end
     end
end

addhook("ms100","time_hud")
function time_hud()
     parse('hudtxt 1 "©000500000Time: ('..timer..'/'..time..') "320 240')
     if timer==time then
          parse('hudtxt 1 "©500000000Time: Round Ended "320 240')
     elseif timer>time then
          parse('hudtxt 1 "©500000000Time: Round Ended "320 240')
     end
end

-- Now its perfect


Thanks alot except now its pretty much in the middle of the screen i want it down on the bottom

old Re: Moving the position of a Script

ViTalIty
User Off Offline

Quote
user Bowlinghead has written
On what button?

well i see how you changed position of the text but it's in the middle of the screen and quite annoying i want it down at the bottom like where the timer is in original cs
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview