Forum

> > CS2D > Scripts > Gfx disappear
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Gfx disappear

1 Antwort
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Gfx disappear

NanuPlayer
User Off Offline

Zitieren
Hi us
sometimes hat disappear... im not sure if its because Worn Weapons script or because there is too much gfx in the server but someone help me please the problem is annoying

My hats script :
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
addhook("say","say_hat")
function say_hat(id,txt)
	if (txt=="!angel") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/angel.png",1,1,200+id)
	end
	if (txt=="!dangerous") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/dangerous.png",1,1,200+id) 
	end
	if (txt=="!devil") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/devil.png",1,1,200+id)
	end
	if (txt=="!headphones") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/headphones.png",1,1,200+id)
	end
	if (txt=="!nohat") then
		freeimage(id) 
	end
	if (txt=="!rock") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/rock.png",1,1,200+id) 
	end
	if (txt=="!santa") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/santa.png",1,1,200+id) 
	end
	if (txt=="!snowman") then
		freeimage(id) 
		id=image("gfx/~{Zombie}~/Hats/snowman.png",1,1,200+id) 
	end
end
1× editiert, zuletzt 22.05.21 16:22:05

alt Re: Gfx disappear

DC
Admin On Online

Zitieren
freeimage(id)

will try to remove the image which has the same ID as the player. This can work in some cases by coincidence but it's a bug in your script. "id" is always the player ID in this case because the cs2d lua hook say-hook sets it like this as it's the first parameter of the hooked function.

That you're assigning the result of cs2d lua cmd image to the "id"-variable has no effect for two reasons:
• it's just a local variable (value is lost as soon as the function ends) - see https://www.lua.org/pil/4.2.html
• as described above the hook sets the value to the player ID when opening the function

What you actually would have to do is creating a global array and saving the image ID of the hat image per player.

There are like 1000 hat scripts in the file archive. Take a look there.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht