Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2184 185 186338 339 Next To the start

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
Trotskygrad has written
Quick question, how do you find the number of items in a list?

I know there's a command, I just forgot it, >.<

hi trot ( its chunks )
and :
on the console the command is items for gettin item ids
simple put
items
if you have rcon idk lol

old Re: Lua Scripts/Questions/Help

Trotskygrad
User Off Offline

Quote
Khaleed has written
Trotskygrad has written
Quick question, how do you find the number of items in a list?

I know there's a command, I just forgot it, >.<

hi trot ( its chunks )
and :
on the console the command is items for gettin item ids


mmmno...

I mean if you have a table of values,
1
items = {45,56,88}

as given by the playerweapons(id), how do you find now many values are in that table?

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
do you mean:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
health={}
count={}

addhook ("second","sec")
function sec()
for id=1,32 do

if (player(id,"exists")) then
health[id] = player(id,"health");
count[id] = "";
for a = 1,health[id],10 do
count[id] = (""..count[id].."|");
--use count[id] for your life display...
end
end
end
end

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
health={}
count={}

addhook ("second","sec")
function sec()
for id=1,32 do

if (player(id,"exists")) then
health[id] = player(id,"health");
count[id] = "";
for a = 1,health[id],10 do
count[id] = (""..count[id].."|");
--use count[id] for your life display...
end
end
end
end
Sry this dont work
I need hudtxt!! lol ... and one line = 10HP example:

HP: [||||| ] 52/100

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
Like this: (in use with schinkens code!)
1
parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ")
should work (not tested)

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Patasuss has written
Like this: (in use with schinkens code!)
1
parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ")
should work (not tested)


Where this write ? ... i really n00b in lua!...

/Edit/

Okay i know

/Edit2/

Why this dont work ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
health={}
count={}

addhook ("second","sec")
function sec()
	for id=1,32 do

		if (player(id,"exists")) then
			health[id] = player(id,"health");
			count[id] = "";
			for a = 1,health[id],10 do
		count[id] = (""..count[id].."|");	--use count[id] for your life display...
			end
		end
	end
end 

parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ")

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if health == nil then health = {}
health = {}

if count == nil then count = {}
count = {}

addhook ("second","sec")
function sec()
     for id=1,32 do

          if (player(id,"exists")) then
               health[id] = player(id,"health");
               count[id] = "";
               for a = 1,health[id],10 do
          count[id] = (""..count[id].."|");     --use count[id] for your life display...
parse("hudtxt2 "..id.." "..id.." \""..count[id].."\" 10 220 ") 
               end
          end
     end
end

lol just look to samples lua/samples...

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Try 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
function arr(s,v)
	t = {}
	for i=1, s do
		t[i] = v
	end
	return t
end

function hudtxt2(id,tid,text,x,y,align)
	align = align or ""
	parse([[hudtxt2 ]]..id..[[ ]]..tid..[[ "]]..text..[[" ]]..x..[[ ]]..y..[[ ]]..align)
end

count = arr(32,0)

addhook("spawn","initcount")
function initcount(id)
	count[id] = 10 --10*10 = 100 HP
	hudtxt2(id,1,"[ | | | | | | | | | | ]",10,10)
end

addhook("hit","hitcount")
function hitcount(id,src,wpn,hpdmg)
	count[id] = math.ceil((player(id,"health")-hpdmg)/10)
	local asd = "[ "
	for i=1,count[id] do asd = asd.."| " end --Bars
	for i=1,10-count[id] do asd = asd.."  " end
	asd = asd.."]" --Fill with whitespace
	hudtxt2(id,1,asd,10,10) --Show
end

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Yea this work , thx flacko!!!

/Edit/

Is bug , if i pick medic kit HP line dont load ...

/Edit2/

And how make this hudtxt red color ?

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
This code isn't tested!
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
function arr(s,v)
     t = {}
     for i=1, s do
          t[i] = v
     end
     return t
end

function hudtxt2(id,tid,text,x,y,align)
     align = align or ""
     parse([[hudtxt2 ]]..id..[[ ]]..tid..[[ "]]..text..[[" ]]..x..[[ ]]..y..[[ ]]..align)
end

count = arr(32,0)

addhook("spawn","initcount")
function initcount(id)
     count[id] = 10 --10*10 = 100 HP
     hudtxt2(id,1,"[ | | | | | | | | | | ]",10,10)
end

addhook("always","alh")
function alh()
     for id=1,32 do
       count[id] = math.ceil((player(id,"health")-hpdmg)/10)
       local asd = "[ "
       for i=1,count[id] do asd = asd.."| " end --Bars
       for i=1,10-count[id] do asd = asd.." " end
       asd = asd.."]" --Fill with whitespace
       hudtxt2(id,1,"©255000000"..asd,10,10) --Show
     end 
end
To the start Previous 1 2184 185 186338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview