hats bug/glitch/error :/
6 replies



24.03.17 04:56:48 am
do any one have a fix for those f**king hats, i tried freeimage(id) but didn't work, can any one fix it for me

Admin/mod comment:
Removed useless symbols in the topic title. /
We have no idea what code you're talking about and can't help.
That's how you've asked us:
That's how you've asked us:
Code:
i have problem with math but i hate math, i tried solving it, but i can't. can anyone fix math for me?

We have no idea what code you're talking about and can't help.
That's how you've asked us:
That's how you've asked us:
Code:
i have problem with math but i hate math, i tried solving it, but i can't. can anyone fix math for me?
in all codes free image not work, idk why, i will give you an example, i get 2 hats :S
edited 2×, last 24.03.17 05:57:09 am

All codes work for me, I don't know what you're talking about. Show us your code.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","anything")
function anything(id,txt)
if (txt=="!hat") then
freeimage(id)
id=image("gfx/hats_menu/hat1.png",1,1,200+id)
return 1
end
if (txt=="!hat2") then
freeimage(id)
id=image("gfx/hats_menu/hat2.png",1,1,200+id)
return 1
end
end
function anything(id,txt)
if (txt=="!hat") then
freeimage(id)
id=image("gfx/hats_menu/hat1.png",1,1,200+id)
return 1
end
if (txt=="!hat2") then
freeimage(id)
id=image("gfx/hats_menu/hat2.png",1,1,200+id)
return 1
end
end
i have to say for you before, some times its work and some times not, idk what is the problem
Your code doesn't work because you're not freeing the image's ID but the player's ID which makes no sense.
You need to read the help pages first so you know what you're doing:
image
freeimage.
The
image function returns the image's ID, which is the argument for the
freeimage function. At the end of the
freeimage function's help page it says that you must set the variable where you've stored the image's ID to nil (after freeing the image) for your code to work properly.
Code:
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
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
function new_players_array()
local players = {}
for id=1,32 do
players[id] = {image = nil} -- player's "properties"
end
return players
end
players = new_players_array()
addhook("say","anything")
function anything(id, txt)
local player = players[id]
if (txt=="!hat") then
if player.image then
freeimage(player.image)
player.image = nil
end
player.image = image("gfx/hats_menu/hat1.png",1,1,200+id)
return 1
end
if (txt=="!hat2") then
if player.image then
freeimage(player.image)
player.image = nil
end
player.image = image("gfx/hats_menu/hat2.png",1,1,200+id)
return 1
end
end
local players = {}
for id=1,32 do
players[id] = {image = nil} -- player's "properties"
end
return players
end
players = new_players_array()
addhook("say","anything")
function anything(id, txt)
local player = players[id]
if (txt=="!hat") then
if player.image then
freeimage(player.image)
player.image = nil
end
player.image = image("gfx/hats_menu/hat1.png",1,1,200+id)
return 1
end
if (txt=="!hat2") then
if player.image then
freeimage(player.image)
player.image = nil
end
player.image = image("gfx/hats_menu/hat2.png",1,1,200+id)
return 1
end
end
You need to read the help pages first so you know what you're doing:


The



edited 1×, last 24.03.17 07:04:25 am
In addition to what
Zeik said, copy this code below and paste it after the 34 line in
Zeik's code.
This will save us from problems with images when a player leaves the server or gets killed.


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function FadeImageLeave(id)
if ( player.image ) then
freeimage(player.image)
player.image = nil
end
end
function FadeImageDie(victim)
if ( player.image ) then
freeimage(player.image)
player.image = nil
end
end
addhook('leave', 'FadeImageLeave')
addhook('die', 'FadeImageDie')
if ( player.image ) then
freeimage(player.image)
player.image = nil
end
end
function FadeImageDie(victim)
if ( player.image ) then
freeimage(player.image)
player.image = nil
end
end
addhook('leave', 'FadeImageLeave')
addhook('die', 'FadeImageDie')
This will save us from problems with images when a player leaves the server or gets killed.



