Forum

> > CS2D > Scripts > [Solved] Round score with hudtxtmove
Forums overviewCS2D overview Scripts overviewLog in to reply

English [Solved] Round score with hudtxtmove

2 replies
To the start Previous 1 Next To the start

old [Solved] Round score with hudtxtmove

Ishara
User Off Offline

Quote
Hello and sorry for this thread, I could not find a proper answer for this so here I go.

I was making a script to show the score everytime when a round starts again, and in fact it's working, but now I want to make if CT's have a higher score than T's, show the score over theirs and vice. (I think this sounds a little bit complicated to explain since I'm not english fluent)

1
2
3
4
5
6
7
8
9
10
11
addhook("startround","_startround")
function _startround()
     parse("hudtxt 0 \""..string.char(169).."050145255CT: "..game("score_ct").."\" -60 70")
     parse("hudtxt 1 \""..string.char(169).."255075075T: "..game("score_t").."\" 610 85")
     parse("hudtxtmove 0 0 400 235 70")
     timer(1000,"parse","hudtxtmove 0 0 200 235 70")
     timer(5000,"parse","hudtxtmove 0 0 200 640 70")
     parse("hudtxtmove 0 1 400 280 85")
     timer(1000,"parse","hudtxtmove 0 1 200 280 85")
     timer(5000,"parse","hudtxtmove 0 1 200 -80 85")
end

I'm aware that I have to use

1
if game("score_t")=>game("score_ct")

But I'm no sure how to apply this into the code, I'm not skilled to solve it.
edited 2×, last 17.06.16 02:29:33 pm

old Re: [Solved] Round score with hudtxtmove

GeoB99
Moderator Off Offline

Quote
The condition of the if statement returns a unexpected problem due to malformation of the relational comparison operator, hence a syntax error. Apparently you're assigning the first value type with the second one than compare them within the condition so to speak. Furthermore, each if or nested if ends with a "then" in the condition.

In this junction, your operator would be:
1
if ( game("score_t") >= game("score_ct") ) then
For your case, the script would be like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("startround","_startround")

function _startround()
	if ( game("score_t") >= game("score_ct") ) then
     	parse("hudtxt2 0 \"" .. string.char(169) .. "050145255CT: " .. game("score_ct") .. "\" -60 70")
     	parse("hudtxt 1 \"" .. string.char(169) .. "255075075T: " .. game("score_t") .. "\" 610 85")
     	parse("hudtxtmove 0 0 400 235 70")
     	timer(1000,"parse","hudtxtmove 0 0 200 235 70")
     	timer(5000,"parse","hudtxtmove 0 0 200 640 70")
     	parse("hudtxtmove 0 1 400 280 85")
     	timer(1000,"parse","hudtxtmove 0 1 200 280 85")
     	timer(5000,"parse","hudtxtmove 0 1 200 -80 85")
	elseif ( game("score_t") <= game("sore_ct") ) then
		-- Conditional code here
	end
end
To explain briefly what the first conditional test does and the second one in 13 line. If the score of Terrorists team is higher than those of Counter-Terrorists team, the HUD score text of Terrorists will be displayed globally whilst of CTs locally (note the cs2d cmd hudtxt2 in parser - 5 line). While in the second conditional test, if the score of Terrorists team is lower than of CTs team, the operation reverts.

Note that I've added a comment in 14 line as to warn you to replace the actual comment with the code. Your only task is by replacing hudtxt with hudtxt2 for Terrorists and let the HUD text global for CTs.

By the way: You might want to read the Lua pil manual to enlighten a bit with the conditional statements and relational operators in general. Here I shall gave you two links below:

> Relational Operators (Lua: Chapter 3.2)

> Conditional if statements (Lua: Chapter 4.3.1 - you might want also to read the whole Statements chapter to get a better overview in decision making in Lua and control flow)
edited 1×, last 17.06.16 08:55:59 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview