Forum

> > CS2D > Scripts > HP Hudtxt Error
Forums overviewCS2D overview Scripts overviewLog in to reply

English HP Hudtxt Error

10 replies
To the start Previous 1 Next To the start

old HP Hudtxt Error

SeanHoca
User Off Offline

Quote
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

old Re: HP Hudtxt Error

Rainoth
Moderator Off Offline

Quote
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.

old Re: HP Hudtxt Error

Hajt
User Off Offline

Quote
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")

old Re: HP Hudtxt Error

Waldin
User Off Offline

Quote
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

old Re: HP Hudtxt Error

SeanHoca
User Off Offline

Quote
@user Waldin:

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

Thanks, it's fixed.

old Re: HP Hudtxt Error

QuakeR
BANNED Off Offline

Quote
@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

old Re: HP Hudtxt Error

Rainoth
Moderator Off Offline

Quote
@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.

old Re: HP Hudtxt Error

Rainoth
Moderator Off Offline

Quote
@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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview