Death-screen script
4 replies



10.11.13 06:09:54 pm
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:
Line 208 is:
And then in console, it shows this
Can anyone help?
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:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
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:
Code:
1
if deathscreen[id] then freeimage(deathscreen[id])
And then in console, it shows this
Code:
1
LUA ERROR: maps/as_mars.lua:208: attempt to index global 'deathscreen' (a function value)
Can anyone help?
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.
The deathscreen table should be this
then, add this to your code
also, on hook
die you shouldn't give the function name deathscreen because there is a table called deathscreen
Code:
1
deathscreen={}
then, add this to your code
Code:
1
2
3
4
5
6
7
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
addhook("join","huh")
function huh(id)
freeimage(deathscreen[id])
deathscreen[id]=0
end
also, on hook

edited 1×, last 11.11.13 06:49:11 am


Code:
1
for i=1,32 do deathscreen[i]=0 end
Turns into this:
Code:
1
LUA ERROR: maps/as_mars.lua:198: attempt to index global 'deathscreen' (a nil value)
make sure that you put the loop code after
Code:
1
deathscreen={}





