Forum

> > CS2D > Scripts > Death-screen script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Death-screen script

4 replies
To the start Previous 1 Next To the start

old Death-screen script

D-D3ADxPro
User Off Offline

Quote
By using this thread

http://unrealsoftware.de/forum_posts.php?post=361647#jn

I wanted to make a deathscreen script that will show a image when you are dead.

Heres the full code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
deathscreen = {"gfx/minecraft_health/Death Screen/Deathscreen.png"}

addhook("die","deathscreen")
function deathscreen(id)
	if player(id, 'team') ~= 0 and player(id, 'health') > 0 then
	if healthimage[id] then freeimage(healthimage[id]) end
	deathscreen[id] = image("gfx/minecraft_health/Death Screen/Deathscreen.png",320,200,2,id)
	end
end

addhook("spawn","respawn")
function respawn(id)
	if deathscreen[id] then freeimage(deathscreen[id]) end
end

Line 208 is:
1
if deathscreen[id] then freeimage(deathscreen[id])

And then in console, it shows this
1
LUA ERROR: maps/as_mars.lua:208: attempt to index global 'deathscreen' (a function value)

Can anyone help?

old Re: Death-screen script

Rainoth
Moderator Off Offline

Quote
Yes. You have a function and a table named the same. When you call the table you get the function. The error says it quite obviously, Change table or function name.

old Re: Death-screen script

MikuAuahDark
User Off Offline

Quote
The deathscreen table should be this
1
deathscreen={}
then, add this to your code
1
2
3
4
5
6
7
for i=1,32 do deathscreen[i]=0 end

addhook("join","huh")
function huh(id)
	freeimage(deathscreen[id])
	deathscreen[id]=0
end
also, on hook cs2d lua hook die you shouldn't give the function name deathscreen because there is a table called deathscreen
edited 1×, last 11.11.13 06:49:11 am

old Re: Death-screen script

D-D3ADxPro
User Off Offline

Quote
1
for i=1,32 do deathscreen[i]=0 end

Turns into this:

1
LUA ERROR: maps/as_mars.lua:198: attempt to index global 'deathscreen' (a nil value)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview