Forum

> > CS2D > Scripts > about huds ct and tt
Forums overviewCS2D overview Scripts overviewLog in to reply

English about huds ct and tt

11 replies
To the start Previous 1 Next To the start

old about huds ct and tt

maninja
User Off Offline

Quote
Hello guys, I have a new topic to unite about, or rather something I need an help on in it
I want to make this be for ct and tt It is a circle surrounded players and it is now a yellow circle and I want to make it blue relative to for counter terrorism and red for terrorist

exapmle
IMG:https://prnt.sc/qpwtnu
and IMG:https://prnt.sc/qpwtyw


This is code
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
if sample==nil then sample={} end
sample.glowing={}

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

-- Glow Function
function sample.glowing.makeallglow()
	for i=1,32,1 do
		id=image("gfx/sprites/flare2.bmp",1,1,100+i)	-- Create image @ Player
		imagecolor(id,200,200,0)						-- Make image yellow
		imageblend(id,1)								-- Make image glow
		imagealpha(id,0.5)								-- Decrease Glow Strength
	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: about huds ct and tt

Mora
User Off Offline

Quote
1
2
3
4
5
if player(i,"team")==1 then
  imagecolor(id, 255,0,0)
elseif player(i,"team")==2 then
  imagecolor(id, 0,0,255)
end

old Re: about huds ct and tt

maninja
User Off Offline

Quote
I right blade i did harder than that but now i didn't even know this things are easier anyway thx you

But how do to paste it?
edited 1×, last 19.01.20 09:19:48 pm

old Re: about huds ct and tt

Masea
Super User Off Offline

Quote
@user Mami Tomoe: More like he asks where to paste it.

Here:
1
2
3
4
5
6
7
8
9
10
11
12
function sample.glowing.makeallglow()
     for i=1,32,1 do
          id=image("gfx/sprites/flare2.bmp",1,1,100+i)     -- Create image @ Player
          if player(i,"team")==1 then
  		 imagecolor(id, 255,0,0)
	 elseif player(i,"team")==2 then
  		 imagecolor(id, 0,0,255)
	 end
          imageblend(id,1)                                        -- Make image glow
          imagealpha(id,0.5)                                        -- Decrease Glow Strength
     end
end
Replace the function with this one and it's done.

old Re: about huds ct and tt

MikuAuahDark
User Off Offline

Quote
Small changes, but somewhat important if you're running larger scripts is in line 11 if your original code (line 3 in user Masea's code) is this.
local id=image("gfx/sprites/flare2.bmp",1,1,100+i)

This ensure the variable is in local scope and doesn't leak into globals. It's good practice to do so.

old Re: about huds ct and tt

maninja
User Off Offline

Quote
i find error

This is error
1
LUA ERROR: sys/lua/autorun/glowingplayers.lua:1: attempt to index field 'glowing' (a nil value)


and this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function sample.glowing.makeallglow()
     for i=1,32,1 do
          local id=image("gfx/sprites/flare2.bmp",1,1,100+i)     -- Create image @ Player
          if player(i,"team")==1 then
             imagecolor(id, 255,0,0)
      elseif player(i,"team")==2 then
             imagecolor(id, 0,0,255)
      end
          imageblend(id,1)                                        -- Make image glow
          imagealpha(id,0.5)                                        -- Decrease Glow Strength
     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: about huds ct and tt

TrialAndError
User Off Offline

Quote
You forgot the beginning part

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
if sample==nil then sample={} end
sample.glowing={}

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

-- Glow Function
function sample.glowing.makeallglow()
  for i = 1, 32 do
    -- Create image @ Player
    local img = image('gfx/sprites/flare2.bmp', 1, 1, 100 + i)
    local team = player(i, 'team');
    if team == 1 then
      imagecolor(img, 255, 0, 0)
    elseif team == 2 then
      imagecolor(img, 0, 0, 255)
    end
    -- Make image glow
    imageblend(img, 1)
    -- Decrease Glow Strength
    imagealpha(img, 0.5)
  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: about huds ct and tt

TrialAndError
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
31
32
33
34
35
36
37
38
39
if sample==nil then sample={} end
sample.glowing={}

-- Glow Function
function sample.glowing.makeglow(id)
  -- Create image @ Player
  sample.glowing.images[id] = image('gfx/sprites/flare2.bmp', 1, 1, 100 + id)
  -- Make image glow
  imageblend(sample.glowing.images[id], 1)
  -- Decrease Glow Strength
  imagealpha(sample.glowing.images[id], 0.5)
end

-- Make Glow after roundstart (because images are deleted on roundstart!)
addhook('startround', 'sample.glowing.startround')
function sample.glowing.startround()
  local players = player(0, "tableliving");
  for i = 1, #players do
    sample.glowing.makeglow(players[i])
  end
end

addhook('spawn', 'sample.glowing.spawn')
function sample.glowing.spawn(id)
  if (not sample.glowing.images[id]) then
    sample.glowing.makeglow(id);
  end
  local team = player(id, 'team');
  if team == 1 then
    imagecolor(sample.glowing.images[id], 255, 0, 0)
  elseif team == 2 then
    imagecolor(sample.glowing.images[id], 0, 0, 255)
  end
end

addhook('leave', 'sample.glowing.leave')
function sample.glowing.leave(id)
  sample.glowing.images[id] = nil
end

old Re: about huds ct and tt

maninja
User Off Offline

Quote
again error

1
Error: sys/lua/autorun/glowingplayers.lua:25: attempt to index field 'images' (a nil value)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview