Forum

> > CS2D > Scripts > hudtxt2 doesn't work
Forums overviewCS2D overview Scripts overviewLog in to reply

English hudtxt2 doesn't work

4 replies
To the start Previous 1 Next To the start

old hudtxt2 doesn't work

Quattro
GAME BANNED Off Offline

Quote
function test is hooked to player join

text file contains this:
16283 1000
123 456

My usgn is the first number, and the script checks if my usgn is in the list. if it is, it sets hud as I want. It correctly detects player 1 info and sets HUD. Player 2 also gets correct info, but after it displays msg('id: '..id..'info: '..info[1]) nothing happens!! Why?


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
function test(id)
msg('hello!')
	info={}
	file = io.open("sys/standings.txt", "r")
		for line in io.lines("sys/standings.txt")do
		info = file:read("*l")
		info = parseline(info)
			if (player(id,"usgn")==info[1])then
			msg('id: '..id..'info: '..info[1])
			parse('hudtxt2 '..id..' 1 "©255255255hello"')
			end
		end
	file:close()

end

function parseline(line)
local index=1
local var={}
	for i in string.gmatch(line, "%S+") do
	var[index]=tonumber(i)
	index=index+1
	end
return var
end

old Re: hudtxt2 doesn't work

Yates
Reviewer Off Offline

Quote
This may not be the issue, but hooking things like cs2d cmd hudtxt2 on join will not always work. The player is sometimes still in progress of joining (like downloading files, or shitty Internet) and so the actual game hasn't started for them.

Try either a timer or hook it on the first team selection, I prefer the latter as the timer will not always work.

By the way, if you're working with individual player save files, consider saving the values in a Lua table as plain Lua code in a Lua file. This way you can dofile it. Much quicker and you will have immediate access to all the variables you store.

old Re: hudtxt2 doesn't work

Yates
Reviewer Off Offline

Quote
That's why we've been asking for the join hook to be renamed to connect and a new join hook that actually gets triggered on join for yeaarrss

old Re: hudtxt2 doesn't work

SQ
Moderator Off Offline

Quote
@user Yates: I'll change it as you said it. Never had proper response from DC about this behaviour. It seemed very annoying when I was developing mods as well. Also this change shouldn't break any already existing scripts. I think this join hook even caused a lot of my scripts to break and leading new players not able to join.

Probably execution of specific commands while player is joining (on join hook) ruined connection. For example sending hudtxt/msg commands while player is receiving servertransfer and other information. I didn't tested this, but always had a suspicion on that.

...after I finish a couple of features I'm working on.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview