Forum

> > CS2D > Scripts > Something wrong with hudtxt2
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Something wrong with hudtxt2

15 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Something wrong with hudtxt2

Masea
Super User Off Offline

Zitieren
Hello brothers, me again.
Today I met another interesting problem at lua.
I made a button, when you click on it, you will see your level, experience, etc.
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
addhook("attack","dead_attack")
function dead_attack(idt)
	if xe[idt] > 188 and ye[idt] > 229 and xe[idt] < 200 and ye[idt] < 240 and profile_b[idt] == 1 then
		freeimage(expmenuimageq[idt])
		expmenuimageq[idt] = 0
		freeimage(expmenuimagex[idt])
		expmenuimagex[idt] = 0
		profile_b[idt] = 0
		parse('hudtxt2 "..idt.." 20 "©255000000|\169255255255PROFILE" 20 140 0')
		parse('hudtxt2 "..idt.." 7 "" 20 240 0')
		parse('hudtxt2 "..idt.." 8 "" 20 260 0')
		parse('hudtxt2 "..idt.." 9 "" 60 280 1')
		freeimage(userbarimageb[idt])
		userbarimageb[idt] = 0
		freeimage(userbarimagesb[idt])
		userbarimagesb[idt] = 0
		freeimage(userbutton1[idt])
		userbutton1[idt] = 0
		freeimage(userbutton2[idt])
		userbutton2[idt] = 0
	elseif xe[idt] > 21 and ye[idt] > 141 and xe[idt] < 78 and ye[idt] < 151 and profile_b[idt] == 0 then
		parse('hudtxt2 "..idt.." 20 "" 20 140 0') 
		profile_b[idt] = 1
		expmenuimageq[idt] = image("gfx/dead_by_daylight/lua/exp_menu.png",100,265,2,idt)
		expmenuimagex[idt] = image("gfx/dead_by_daylight/lua/menu_x.png",195,236,2,idt)
		if player(idt,"team") == 2 then
			parse('hudtxt2 "..idt.." 7 "©255000000SURVIVOR PROFILE" 20 240 0')
			parse('hudtxt2 "..idt.." 8 "©255255255LEVEL \169255000000'..level_s[idt]..'" 20 260 0')
			parse('hudtxt2 "..idt.." 9 "©255255255'..exp_s[idt]..'/'..maxexp_s[idt]..'" 85 280 1')
			userbarimageb[idt] = image("gfx/dead_by_daylight/lua/hud.png",21,287,2,idt)
			userbarimagesb[idt] = image("gfx/dead_by_daylight/lua/bar.png",21,287,2,idt)
			imagescale(userbarimageb[idt],exp_s[idt]/maxexp_s[idt],1)
			userbutton1[idt] = image("gfx/dead_by_daylight/lua/inventory_but.png",45,319,2,idt)
			imagescale(userbutton1[idt],0.3,0.3)
			userbutton2[idt] = image("gfx/dead_by_daylight/lua/bloodweb_but.png",95,319,2,idt)
			imagescale(userbutton2[idt],0.3,0.3)
		elseif player(idt,"team") == 1 then
			parse('hudtxt2 "..idt.." 7 "©255000000KILLER PROFILE" 20 240 0')
			parse('hudtxt2 "..idt.." 8 "©255255255LEVEL \169255000000'..level[idt]..'" 20 260 0')
			parse('hudtxt2 "..idt.." 9 "©255255255'..exp[idt]..'/'..maxexp[idt]..'" 85 280 1')
			userbarimageb[idt] = image("gfx/dead_by_daylight/lua/hud.png",21,287,2,idt)
			userbarimagesb[idt] = image("gfx/dead_by_daylight/lua/bar.png",21,287,2,idt)
			imagescale(userbarimageb[idt],exp[idt]/maxexp[idt],1)
			userbutton1[idt] = image("gfx/dead_by_daylight/lua/inventory_but.png",45,319,2,idt)
			imagescale(userbutton1[idt],0.3,0.3)
			userbutton2[idt] = image("gfx/dead_by_daylight/lua/bloodweb_but.png",95,319,2,idt)
			imagescale(userbutton2[idt],0.3,0.3)
		end
	end
end

The problem is, when I click on button at first cs2d(ID 1), I can see texts on second cs2d(ID 2) too. But the images works well(I can see them only first cs2d(ID 1)). Probably, a lot of people will see this problem first time in their entire life. Maybe It does not work for because of a small mistake, idk.

Please, help me guys.
1× editiert, zuletzt 29.06.16 23:53:04

alt Re: Something wrong with hudtxt2

Nekomata
User Off Offline

Zitieren
I don't think the bug is restricted to this particular block of code. The hudtxt2 is being properly used, perhaps some issue with id handling in your script?

alt Re: Something wrong with hudtxt2

Nekomata
User Off Offline

Zitieren
Well, you never know. Throw in some
print(idt) or msg(idt)
before the hudtxt2.

• Edit: ayy first! I'd like to thank my parents, cat...
1× editiert, zuletzt 29.06.16 23:58:59

alt Re: Something wrong with hudtxt2

Yates
Reviewer Off Offline

Zitieren
print(idt)
and see what shows up in the console.

• Edit:
Oh! I was actually ninja'd holy crap. We have a winRAR over here.

alt Re: Something wrong with hudtxt2

Nekomata
User Off Offline

Zitieren
You have some user[id] handling issues. Probably wherever you construct/destruct the user arrays. (in join, leave, team, spawn, etc hooks). You're probably not setting userblah[idt] = 0 after a user leaves or something.
1× editiert, zuletzt 30.06.16 00:04:48

alt Re: Something wrong with hudtxt2

Yates
Reviewer Off Offline

Zitieren
user Masea hat geschrieben
So what now?

Make a function called whatever you want and trigger it when you have two clients on the server. Put this in it:

1
2
parse('hudtxt2 1 0 "This is a test" 100 100 0')
parse('hudtxt2 2 0 "This is another test" 100 100 0')

You can trigger it via the console like
lua myFunction()


Then we will know if it's truely a CS2D bug or not.

Also, check if you're using
idt
anywhere as a global variable. If so it will fuck with things. Change it to
myrandomidname
just in case and see if that works.

alt Re: Something wrong with hudtxt2

Masea
Super User Off Offline

Zitieren
@user Yates: It works fine.

Know that, I'm using "id" at almost everywhere because of that I did change it to "idt". I'm confusing at why the images works perfect but the hudtxts doesn't?

alt Re: Something wrong with hudtxt2

Yates
Reviewer Off Offline

Zitieren
Your code seems alright (other than it being messy). If no one else can see what we're not seeing (if there is anything to be seen) then I guess we'll need the whole code.

Can't help you any more I'm afraid, I'm off to sleep. I'll check in the morning if not solved by then.

alt Re: Something wrong with hudtxt2

Waldin
User Off Offline

Zitieren
Did you used hudtxt in your script? the ones that are visible for all.
Maybe u used a id twice or something like that. (cuz cs2d cmd hudtxt and cs2d cmd hudtxt2 uses same IDs.)
I suggest read all your script from start to end, what happen when i click this, when i spawn, ect.
1× editiert, zuletzt 30.06.16 00:41:44

alt Re: Something wrong with hudtxt2

Avo
User Off Offline

Zitieren
There's a huge mess with quotation marks, for example:
parse('hudtxt2 "..idt.." 7 "" 20 240 0')


How about:
parse('hudtxt2 '..idt..' 7 "your-text-here" 20 240 0')
?

I don't know if it changes anything but clearing up your code is the best way to deal with strange issues (that's why tabbing and comments exist).

By the way
CS2D.com hat geschrieben
Note: The texts/IDs are shared with the hudtxt command!
This can also be a reason.

alt Re: Something wrong with hudtxt2

Masea
Super User Off Offline

Zitieren
user Waldin hat geschrieben
Did you used hudtxt in your script? the ones that are visible for all.

Yes, I used hudtxt for 28 times.

user Waldin hat geschrieben
Maybe u used a id twice or something like that.

I check it out and hudtxts and hudtxt2s does not conflict.

@user Avo: I just tried to clear no. 7 hudtxt for player who did click "exit" button.

By the way, thank you guys so much!

EDIT: Guys, can anyone help me please? It's seriously awkward thing I've ever seen in cs2d past. We're waiting for you user DC.
4× editiert, zuletzt 30.06.16 03:22:43

alt Re: Something wrong with hudtxt2

Waldin
User Off Offline

Zitieren
As user Avo said, you have alot of misstakes with " and '.
Try using this:
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
addhook("attack","dead_attack")
function dead_attack(idt)
     if xe[idt] > 188 and ye[idt] > 229 and xe[idt] < 200 and ye[idt] < 240 and profile_b[idt] == 1 then
          freeimage(expmenuimageq[idt])
          expmenuimageq[idt] = 0
          freeimage(expmenuimagex[idt])
          expmenuimagex[idt] = 0
          profile_b[idt] = 0
          parse("hudtxt2 \""..idt.."\" 20 \"©255000000|\169255255255PROFILE\" 20 140 0")
          parse("hudtxt2 \""..idt.."\" 7 \"\" 20 240 0")
          parse("hudtxt2 \""..idt.."\" 8 \"\" 20 260 0")
          parse("hudtxt2 \""..idt.."\" 9 \"\" 60 280 1")
          freeimage(userbarimageb[idt])
          userbarimageb[idt] = 0
          freeimage(userbarimagesb[idt])
          userbarimagesb[idt] = 0
          freeimage(userbutton1[idt])
          userbutton1[idt] = 0
          freeimage(userbutton2[idt])
          userbutton2[idt] = 0
     elseif xe[idt] > 21 and ye[idt] > 141 and xe[idt] < 78 and ye[idt] < 151 and profile_b[idt] == 0 then
          parse("hudtxt2 \""..idt.."\" 20 \"\" 20 140 0") 
          profile_b[idt] = 1
          expmenuimageq[idt] = image("gfx/dead_by_daylight/lua/exp_menu.png",100,265,2,idt)
          expmenuimagex[idt] = image("gfx/dead_by_daylight/lua/menu_x.png",195,236,2,idt)
          if player(idt,"team") == 2 then
               parse("hudtxt2 \""..idt.."\" 7 \"©255000000SURVIVOR PROFILE\" 20 240 0")
               parse("hudtxt2 \""..idt.."\" 8 \"©255255255LEVEL \169255000000\""..level_s[idt].."\" 20 260 0")
               parse("hudtxt2 \""..idt.."\" 9 \"©255255255"..exp_s[idt].."/"..maxexp_s[idt].."\" 85 280 1")
               userbarimageb[idt] = image("gfx/dead_by_daylight/lua/hud.png",21,287,2,idt)
               userbarimagesb[idt] = image("gfx/dead_by_daylight/lua/bar.png",21,287,2,idt)
               imagescale(userbarimageb[idt],exp_s[idt]/maxexp_s[idt],1)
               userbutton1[idt] = image("gfx/dead_by_daylight/lua/inventory_but.png",45,319,2,idt)
               imagescale(userbutton1[idt],0.3,0.3)
               userbutton2[idt] = image("gfx/dead_by_daylight/lua/bloodweb_but.png",95,319,2,idt)
               imagescale(userbutton2[idt],0.3,0.3)
          elseif player(idt,"team") == 1 then
               parse("hudtxt2 \""..idt.."\" 7 \"©255000000KILLER PROFILE\" 20 240 0")
               parse("hudtxt2 \""..idt.."\" 8 \"©255255255LEVEL \169255000000"..level[idt].."\" 20 260 0")
               parse("hudtxt2 \""..idt.."\" 9 \"©255255255"..exp[idt].."/"..maxexp[idt].."\" 85 280 1")
               userbarimageb[idt] = image("gfx/dead_by_daylight/lua/hud.png",21,287,2,idt)
               userbarimagesb[idt] = image("gfx/dead_by_daylight/lua/bar.png",21,287,2,idt)
               imagescale(userbarimageb[idt],exp[idt]/maxexp[idt],1)
               userbutton1[idt] = image("gfx/dead_by_daylight/lua/inventory_but.png",45,319,2,idt)
               imagescale(userbutton1[idt],0.3,0.3)
               userbutton2[idt] = image("gfx/dead_by_daylight/lua/bloodweb_but.png",95,319,2,idt)
               imagescale(userbutton2[idt],0.3,0.3)
          end
     end
end

We used \ before some " cuz we want to parse them.
Try using an editor like notepad++ that show u strings with colors.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht