Forum

> > CS2D > Scripts > Death-screen script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Death-screen script

4 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Death-screen script

D-D3ADxPro
User Off Offline

Zitieren
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?

alt Re: Death-screen script

Rainoth
Moderator Off Offline

Zitieren
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.

alt Re: Death-screen script

MikuAuahDark
User Off Offline

Zitieren
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
1× editiert, zuletzt 11.11.13 06:49:11

alt Re: Death-screen script

D-D3ADxPro
User Off Offline

Zitieren
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)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht