Forum

> > CS2D > Scripts > HP Hudtxt Error
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch HP Hudtxt Error

10 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt HP Hudtxt Error

SeanHoca
User Off Offline

Zitieren
Hey guys.

I was trying to code a basic HP Hudtxt for testing.
But I got some sort of error that pops up with/without any other lua. (i can't give ss right now)

1
2
3
4
5
addhook("ms100","hudstuff")
function hudstuff(id)
	parse('hudtxt2 '..id..' 28 "©255000000'..player(id,"health")..'" 555 285 1')
	parse('hudtxt2 '..id..' 20 "©034139034'..player(id,"armor")..'" 555 305 1')
end

Pls fix

alt Re: HP Hudtxt Error

Rainoth
Moderator Off Offline

Zitieren
Time hooks do not provide any kind of id (whose id would they provide anyways xd ?)

As such, you need to get it yourself.
1
for _,id in pairs (player(0,"tableliving")) do

It makes no sense to use ms100 hook for displaying those, though.
It would make more sense to parse those commands on hit hook rather than ms100.

Anyways, your error is that you're trying to concatenate 'id' when it's nil. You can solve it by adding the loop I wrote above.

alt Re: HP Hudtxt Error

Hajt
User Off Offline

Zitieren
1. Hook ms100 doesn't have parameters
2. Use \169 instead of copyright symbol

1
parse("hudtxt2 "..id.." 28 \"\169255000000"..player(id,"health").."\" 555 285 1")

alt Re: HP Hudtxt Error

Waldin
User Off Offline

Zitieren
If in that error says something like "in hook ms100 with parameters '' " bla bla bla
then maybe you writed wrong the function in cs2d lua cmd addhook
Use this code:
1
2
3
4
5
6
7
addhook("ms100","hudstuff")
function hudstuff()
	for _,id in ipairs(player(0,"tableliving")) do
		parse("hudtxt2 "..id.." 28 \"\169255000000"..player(id,"health").."\" 555 285 1")
		parse("hudtxt2 "..id.." 20 \"\169034139034"..player(id,"armor").."\" 555 305 1")
	end
end

alt Re: HP Hudtxt Error

SeanHoca
User Off Offline

Zitieren
@user Waldin:

Yeah man, you're right.
Seems like I changed the function's name after posting this thread.

Thanks, it's fixed.

alt Re: HP Hudtxt Error

QuakeR
BANNED Off Offline

Zitieren
@user SeanHoca:Try this , @user Rainoth: why hard ? simple please.

1
2
3
4
5
6
7
8
9
10
addhook("ms100","JustHook")
function JustHook()

for i = 1,32 do
if (player(id,exists)) then
parse("hudtxt2 "..id.." 28 \"\169255000000"..player(id,"health").."\" 555 285 1")
parse("hudtxt2 "..id.." 20 \"\169034139034"..player(id,"armor").."\" 555 305 1")
end
   end
      end

alt Re: HP Hudtxt Error

Rainoth
Moderator Off Offline

Zitieren
@user QuakeR: Because it's actually easier and more efficient to use pairs instead of looping 32 times every 0.1 second and then adding an additional 'if' check just to not screw up.

Just because you don't understand it doesn't mean it's hard.
I gave him what I think is the most efficient way.

P.S. You revived a thread that was already solved.

alt Re: HP Hudtxt Error

Rainoth
Moderator Off Offline

Zitieren
@user QuakeR: What I wrote is actually really simple. Also it's more efficient. user SeanHoca didn't seem to be puzzled over my version so it seems to have posed no problems for him. If it's good for him, it's good for me.
Feel free to use your 'simple' version in your own code ^.o
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht