Custom Notification Message

Hello FacePunch community,

I have come looking for help about having a custom notification system. Where is comes up in different parts of the screen, etc.

Thanks for any help,

Myles.

So, what exactly do you want to know?

Essentials:

  1. Make a function that will create your notification and randomize the position. This function will throw the notification ( a table with settings ) into another table.
  2. Make a renderer for your notifications using the surface or draw libraries, it will iterate through your main table, and use the info from it to draw the notifications.

Could you give an example of this please?



local t = {}
function Hax( name ,time )
	table.insert(t, {
		name = name,
		time = time,
		start = CurTime(),
		x = math.random(0, ScrW()), 
		y = math.random(0, ScrH())
	})
end


hook.Add("HUDPaint", "mynotif",function()
	for id, tab in pairs( t ) do
		if ( tab.start + tab.time < CurTime() ) then continue end
		// Draw here
		draw.RoundedBox(tab.x, tab.y, 200, 20, Color(0, 0, 0))
		draw.SimpleText( tab, "Default", tab.x, tab.y, Color(255, 255, 255) )
	end
end)


Hax( "test1", 1 )
Hax( "test5", 5 )
Hax( "test10", 10 )


Here’s a base foundation, I trust you can take it from here.

Code is untested, but should work.

What should happen is a few random boxes with text should appear

Nope, didn’t work for me. :c

Robots will work if you auto-refresh; the messages may be disappearing before you’re fully in the game.

Here’s an example of a rewrite of the default notification system: https://dl.dropboxusercontent.com/u/26074909/tutoring/classes/class_notify.lua.html

What changed: Reversed the order of notifications, made it so notifications don’t skip in line any longer, removed the Think hook running when notifications aren’t being displayed, notifications that start with # use my language system rewrite which adds multilingual dictionary support to the default language system ( https://dl.dropboxusercontent.com/u/26074909/tutoring/classes/class_language.lua.html ) but if it isn’t installed / being used, it’ll use en as default language…