Forum

> > CS2D > Scripts > Image in Menu hook
Forums overviewCS2D overview Scripts overviewLog in to reply

English Image in Menu hook

1 reply
To the start Previous 1 Next To the start

old Image in Menu hook

Nknz1
User Off Offline

Quote
Good evening everyone, I would like to know if it is possible to put an image in the menu line?
Using the hook menu

Example:

Menu line: Name_player Image Kills

old Re: Image in Menu hook

Bowlinghead
User Off Offline

Quote
You can "cheat" it by using an invisible menu and then drawing the complete menu using images/hudtxts.
This example uses a 1x1 black pixel.png to recreate the default menu border:
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
35
36
37
38
-- save the background image somewhere
bg = {}

function superMenu(pid)
	menu(pid,"My Image Menu@i,1,2,3,4,5,6,7,8,9")
	local img  = image("pixel.png", 0, 0, 2, pid)
	imagescale(img, 2000, 2000) -- fill whole screen
	imagecolor(img, 0, 0, 0) -- gray looking
	imagealpha(img, 0.9) -- kinda transparent
	bg[pid] = img -- save image so we can delete it later

	--[[
		Draw Stuff for each button
	]]--
end

function superMenuClose(pid)
	local img = bg[pid]
	if (img) then freeimage(img); bg[pid] = nil; end
	--[[
		Freeimage Stuff for each button
	]]

end

addhook("menu","Hmenu")
function Hmenu(pid, t, b)
	if (t=="My Image Menu") then
		--[[
		 	For each button press code
		]]
		msg2(pid,"You pressed "..b.." in my super menu :D")
		superMenuClose(pid)
	end
end

-- Open Menu for player pid=1
superMenu(1)


In my testings, HUD images are covered by the menu itself, so using a normal or big menu and drawing stuff over it doesnt work.

You can use a small menu and draw stuff next to it. It depends on what exactly you want to archieve.
In this forum thread you can see a beatiful custom menu (in the Youtube Link) https://unrealsoftware.de/forum_posts.php?post=431875

In your menu string you can use empty buttons (like: ,,,,) to prevent the user from pressing them.
cs2d lua cmd menu
cs2d lua hook menu
cs2d lua cmd image
cs2d cmd hudtxt2
edited 1×, last 07.01.24 10:33:39 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview