Forum

> > CS2D > Scripts > Why doesn't it work?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Why doesn't it work?

47 Antworten
Seite
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang

alt Why doesn't it work?

Mami Tomoe
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
addhook("startround","_rp_startround")

function _rp_startround(id)
		for ids = 1,32 do
			local id=image("gfx/7hud/full.png",555,300,2)
				imagecolor(id,255,255,255)
			imagealpha(id,0.5)
		end
	end
end

There is no error.
The script should do the local id=image thing every round restart.

Thanks.

alt Re: Why doesn't it work?

GeoB99
Moderator Off Offline

Zitieren
Now it must shall work at least I hope and there was also an useless "end" in the 9 line. Here's the code.
1
2
3
4
5
6
7
8
9
addhook("startround","_rp_startround")

function _rp_startround(id)
          for ids = 1,32 do
               local hud_img = image("gfx/7hud/full.png",555,300,2)
                    imagecolor(id,255,255,255)
               imagealpha(id,0.5)
 		end
end

alt Re: Why doesn't it work?

Mami Tomoe
User Off Offline

Zitieren
@user GeoB99: Doesn't work... also it will only work if I use this code:

1
2
3
local hud_img = image("gfx/7hud/full.png",555,300,2)
imagecolor(id,255,255,255)
imagealpha(id,0.5)

But this code will remove the image on round start...

alt Re: Why doesn't it work?

Rainoth
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
addhook("startround","_rp_startround")

function _rp_startround(mode)
	for ids = 1,32 do
		local id=image("gfx/7hud/full.png",555,300,2)
		imagecolor(id,255,255,255)
		imagealpha(id,0.5)
	end
end

Notable mistakes:
1. Startround hook provides round mode, not player IDs
2. You're looping all player IDs yet you're not using them anywhere inside the loop
3. Despite running the loop 32 times, you create an image and place it at the same spot 32 times. What's the point of that?
4. You come to the forum and say 'Doesn't work' but don't explain what you're trying to achieve here.

What I would advise using my great powers of assumption:
1. Use a table to store images for players
2. Loop living players table instead of a static number 32 to decrease the amount of iterations
3. Do not try to recolor into RGB 255255255 cause that equals white which produces no effect on the image color whatsoever
4. Try to tab properly and put 'end's

Further speaking, by the file path, I'm assuming that the image is supposed to be like a hud element for each player so if that's true, say it so I could further help you out.

P.S. The title 'Why doesn't it work?' does not say anything useful. Please try choosing a more proper title.

alt Re: Why doesn't it work?

Mami Tomoe
User Off Offline

Zitieren
@user Rainoth: I tried the code but it didn't work... The image meant to show for all players no matter how many round starts there will be... also on the screen and not on the map.

alt Re: Why doesn't it work?

Rainoth
Moderator Off Offline

Zitieren
Of course it didn't work. I just made your code work. It works as it was written. At least it WORKS.
Unfortunately, because you didn't know how to make it work like you WANT TO, you got this. Don't worry, I already anticipated what you wanted in my previous post so I'll write it for ya. Wait some time.

//Aight. See if this works:
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
Milk = {}

addhook("leave","_leave")
function _leave(id)
	if Milk[id] ~= nil then
		freeimage(Milk[id])
		Milk[id] = nil
	end
end

addhook("startround","_startround")
function _startround(mode)
	for k,v in pairs (player(0,"tableliving")) do
		if Milk[v] == nil then
			Milk[v] = image("gfx/7hud/full.png",555,300,2)
			imagealpha(Milk[v],0.5)
		end
	end
end

addhook("endround","_endround")
function _endround(mode)
	for k,v in pairs (player(0,"table")) do
		if Milk[v] ~= nil then
			freeimage(Milk[v])
			Milk[v] = nil
		end
	end
end
4× editiert, zuletzt 19.09.15 21:54:19

alt Re: Why doesn't it work?

Rainoth
Moderator Off Offline

Zitieren
You're very vague. Maybe you don't need to decrease the alpha to 0.5 and should have it at full alpha (1) instead. I need more information before I can determine the problem.

alt Re: Why doesn't it work?

Rainoth
Moderator Off Offline

Zitieren
That shouldn't do anything wrong to this script. Can you explain more about how the image appears and disappears instantly..?

alt Re: Why doesn't it work?

Rainoth
Moderator Off Offline

Zitieren
'Yeah' as in "It works!"
or 'Yeah' as in 'Yeah, it still doesn't work.' ?

If it still doesn't work. Try using only this:
1
2
3
4
5
6
7
8
Milk = {}

addhook("startround","_startround")
function _startround(mode)
	for k,v in pairs (player(0,"tableliving")) do
		Milk[v] = image("gfx/7hud/full.png",555,300,2)
	end
end

alt Re: Why doesn't it work?

Rainoth
Moderator Off Offline

Zitieren
That doesn't make sense. It shouldn't even do anything but appear with the code I provided above. Unless you somehow, SOMEHOW wipe the images in other parts. If this continues, I might actually have to download the game and test myself >.>
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht