Forum

> > CS2D > Scripts > hudtxt2 help
Forums overviewCS2D overview Scripts overviewLog in to reply

English hudtxt2 help

5 replies
To the start Previous 1 Next To the start

old hudtxt2 help

Blighted Song
User Off Offline

Quote
Heres how it is;

I need to draw a fair lot of text on the screen, but hudtxt2 only lets you draw 49 strings, I potentially need a lot more.

So here the question, is there a function that does similar(draw text ANYWARE on the window) without a cap,
or is there a command for going to the next line(html has </br> and lua has /n for example).

old Re: hudtxt2 help

archmage
User Off Offline

Quote
Hudtext and hudtext2 allow you to draw 50 strings (not 49). That should be enough, but if you do need more you could create an image for each letter, number, and other characters. Use the images to create hud text.

pseudocode:
1
2
3
4
5
6
7
8
9
10
function text_to_images(str, t, x, y)
	t = t or {}
	for i = 1, string.len(str) do
		local sub = str.substr(i,i)
		if ( image_exists("gfx/chars/"..sub..".bmp") ) then
			t:insert(image("gfx/chars/"..sub..".bmp",x+i*image_width(sub),y))
		end
	end
	return t
end

old Re: hudtxt2 help

Blighted Song
User Off Offline

Quote
Oh yea, I for got about 0, but 50 is still not enough, I need about 10 for each player, so 320, so its not enough.

I was worrying that I might have to use images instead, thanks for the help.

old Re: hudtxt2 help

DC
Admin Off Offline

Quote
you got something wrong there.
it's true that the IDs of cs2d cmd hudtxt2 are shared with the cs2d cmd hudtxt IDs but the IDs are not shared between players.

this means that you can create up to 50 texts PER PLAYER which really should be more than enough.

example:
1
2
3
hudtxt2 1 0 "pl. 1 will see this" 0 0 0
hudtxt2 2 0 "and pl. 2 will see this" 0 0 0
hudtxt2 3 0 "pl. 3 will see that" 0 0 0
all 3 players will see their own text. even though you always used ID 0.

but note that:
1
hudtxt 0 "same for all" 0 0 0
would now set that text to the same text for each player.

I hope that helps to understand how the hudtxt stuff works.

old Re: hudtxt2 help

KimKat
GAME BANNED Off Offline

Quote
I find that very useful information. Thanks for clarifying.
But I have a question, would it be possible to assign a variable with a specific parameter value?

Like so...
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
-- Player ID's
authorized_players[id] = 0
unauthorized_players[id] = 0
guest_players[id] = 0

-- Text ID's
authorized_players[txt_id] = 0
unauthorized_players[txt_id] = 0
guest_players[txt_id] = 0

-- HUD text positions
authorized_players[x] = 0
authorized_players[y] = 0
unauthorized_players[x] = 0
unauthorized_players[y] = 0
guest_players[x] = 0
guest_players[y] = 0

-- Text ID's (-1 = right, 0 = center, 1 = left)
authorized_players[align] = 0
unauthorized_players[align] = 0
guest_players[align] = 0

addhook("spawn","hudtexts")
function hudtexts(id)
	hudtxt2 authorized_players[id] authorized_players[txt_id] "Authorized players will see this." authorized_players[x] authorized_players[y] authorized_players[align]
	hudtxt2 unathorized_players[id] unauthorized_players[txt_id] "Players with Unreal Software ID will see this." unauthorized_players[x] unauthorized_players[y] unauthorized_players[align]
	hudtxt2 guest_players[id] guest_players[txt_id] "Guest players will see this." guest_players[x] guest_players[y] guest_players[align]
end
I'm just trying to find a way to easily build a way to set up parameters of the cs2d cmd hudtxt2 strings and applying them within the function. I know the script will fail pretty bad but anyways I hope you get my idea.

old Re: hudtxt2 help

DC
Admin Off Offline

Quote
I don't get the idea because that's too long and f*cked up for an example...
you can basically do everything with it. but that's not about hudtxt2 anymore but general Lua scripting technique...
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview