How to make (Hover Image)!
and Image is Mode HUD 2!
Thanks !
#SorryForMyEnglish.
Admin/mod comment
§2.4 - Use tags sparingly and only when they add value
Scripts
Hover Image
Hover Image
1

§2.4 - Use tags sparingly and only when they add value
ms100,
second, etc) to call the
reqcld function (in mode 0), which calls the
clientdata's hook function. So, in the
clientdata function you will have to ask where the cursor is, and if it's at the image's position, then you swap images. Then you would want to ask for when the cursor leaves the image so you change it back to the original.
second hook, though it may look very unresponsive.
Serigala's code works but on the 23 line it triggers an error due of an unfinished string. It can be fixed very easily by just removing the unnecessary quote. -- You need to specify the position of the button manually
local buttonx, buttony = 320, 240 -- on the center of the screen
-- You need to specify the size of the button manually (based on the image)
local buttonwidth, buttonheight = 100, 50
local buttonexists, buttonimage, buttonhovered, mousepos = {}, {}, {}, {}
for id = 1, 32 do
	buttonexists[id] = false
	buttonimage[id] = 0
	buttonhovered[id] = false
	mousepos[id] = {0, 0}
end
addhook("spawn", "spawnhook")
addhook("clientdata", "clientdatahook")
addhook("ms100", "ms100hook")
addhook("die", "diehook")
function spawnhook(id)
	-- Button will appear and hoverable when spawning
	buttonexists[id] = true
	buttonimage[id] = image("path/to/your/button/image.png", buttonx, buttony, 2, id)
end
function clientdatahook(id, mode, data1, data2)
	if (mode == 0) then
		mousepos[id] = {data1, data2}
	end
end
function ms100hook()
	for index, id in ipairs(player(0, "tableliving")) do
		if (buttonexists[id]) then
			reqcld(id, 0)
			
			local x, y = unpack(mousepos[id])
			
			if ((x >= buttonx and x <= buttonx + buttonwidth) and (y >= buttony and y <= buttony + buttonheight)) then
				if (not buttonhovered[id]) then
					freeimage(buttonimage[id])
					
					buttonimage[id] = image("path/to/your/button/hovered/image.png", buttonx, buttony, 2, id)
					buttonhovered[id] = true
				end
			else
				if (buttonhovered[id]) then
					freeimage(buttonimage[id])
					
					buttonimage[id] = image("path/to/your/button/image.png", buttonx, buttony, 2, id)
					buttonhovered[id] = false
				end
			end
		end
	end
end
function diehook()
	-- Button will disappear when you die
	buttonexists[id] = false
	
	freeimage(buttonimage[id])
	
	buttonimage[id] = 0
	buttonhovered[id] = false
end
1
