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 2185 186 187338 339 Next To the start

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

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Use collect hook as Schinken said (I hope you can atleast do that by yourself) and for making it red you have to concatenate "©255000000" to asd as patasuss did.
Don't use always hook because concatenations are slow and what patasuss did would execute really slow.

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
2
3
4
5
6
7
function arr([b]s[/b],[b]v[/b])
     [b]t[/b] = {}
     for i=1, [b]s[/b] do
          [b]t[/b][i] = [b]v[/b]
     end
     return [b]t[/b]
end

or

1
2
3
4
5
6
7
function initArray([b]m[/b])
	local array = {}
	for i = 1, [b]m[/b] do
		array[i]=0
	end
	return array
end

What are that letters?

old Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Quote
DRoNe has written
1
2
3
4
5
6
7
function arr([b]s[/b],[b]v[/b])
     [b]t[/b] = {}
     for i=1, [b]s[/b] do
          [b]t[/b][i] = [b]v[/b]
     end
     return [b]t[/b]
end

or

1
2
3
4
5
6
7
8
function initArray([b]m[/b]) --define a function that 
                                           --creates a table with m entries
	local array = {}          -- create an empty table
	for i = 1, [b]m[/b] do  -- fill m entries with 0
		array[i]=0
	end
	return array               -- return the table
end

What are that letters?


So basically what it returns is a table filled with m zero's,


array = {0,0,0......}

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
The first function uses s for the size of the table and v for the value of each index

The second one just makes a table with the size given by m and fills it with 0 on each index.

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
and how about this?
Spoiler >

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
Spoiler >

Some1 help i need to make it just for terrorists

old Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

Quote
Khaleed has written
Spoiler >

Some1 help i need to make it just for terrorists

Maybe this will help (I am a noob...)

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
--------------------------------------------------
-- Glowing Players Script by Unreal Software    --
-- 08.11.2009 - www.UnrealSoftware.de           --
--------------------------------------------------

if sample==nil then sample={} end
sample.glowing={}

-- I won't be using the samples table if I were you...

--------------------------------------
-- GLOW                             --
--------------------------------------

-- Glow Function
function sample.glowing.makeallglow()
	if (team==1) then
		for i=1,32,1 do
			id=image("gfx/sprites/flare2.bmp",0,0,100+i)	-- Create image @ Player
			imagecolor(id,255,255,0)				-- Make image yellow
			imageblend(id,1)						-- Make image glow
			imagealpha(id,0.5)					-- Decrease Glow Strength
		end
	end
end

-- Make Glow instantly after starting server
sample.glowing.makeallglow()

-- Make Glow after roundstart (because images are deleted on roundstart!)
addhook("startround","sample.glowing.startround")
function sample.glowing.startround()
	sample.glowing.makeallglow()
end

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
Flacko has written
DRoNe has written
@Flacko and Yellowbanana

How many letters are ?
Where i find explanatories to all letters ?


You have to download common_sense.exe from www.use_your_brain.com/


omg ...
you dont understand me ...

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
2
3
4
5
6
7
function arr(s,v)
t = {}
for i=1, s do
t[i] = v
end
return t
end

like 's' as Flacko sayd is size and 'v' is value ...
- is something else ?
- if is, then can you explain it ?

old Re: Lua Scripts/Questions/Help

YellowBanana
BANNED Off Offline

Quote
Pikachu_Lv85 has written
Khaleed has written
Spoiler >

Some1 help i need to make it just for terrorists

Maybe this will help (I am a noob...)

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
--------------------------------------------------
-- Glowing Players Script by Unreal Software    --
-- 08.11.2009 - www.UnrealSoftware.de           --
--------------------------------------------------

if sample==nil then sample={} end
sample.glowing={}

-- I won't be using the samples table if I were you...

--------------------------------------
-- GLOW                             --
--------------------------------------

-- Glow Function
function sample.glowing.makeallglow()
	if (team==1) then
		for i=1,32,1 do
			id=image("gfx/sprites/flare2.bmp",0,0,100+i)	-- Create image @ Player
			imagecolor(id,255,255,0)				-- Make image yellow
			imageblend(id,1)						-- Make image glow
			imagealpha(id,0.5)					-- Decrease Glow Strength
		end
	end
end

-- Make Glow instantly after starting server
sample.glowing.makeallglow()

-- Make Glow after roundstart (because images are deleted on roundstart!)
addhook("startround","sample.glowing.startround")
function sample.glowing.startround()
	sample.glowing.makeallglow()
end


seriously, learn to script..
What is "team" in your script?
This is how it should be.

Spoiler >

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
Patasuss has written
and how about this?
Spoiler >


"-hpdmg"a nil value. /error in console/

if enemy hit line [ | | | | | | | | | | ] dont move .... (sry for my english lol)
To the start Previous 1 2185 186 187338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview