<commit_before>local messages = { global = { }, client = { } }
local screenWidth, screenHeight = guiGetScreenSize( )
local messageWidth, messageHeight = 316, 152

function createMessage( message, messageType, messageGlobalID, hideButton, disableInput )
	destroyMessage( messageType )
	destroyMessage( nil, nil, messageGlobalID )

	local messageID = messageGlobalID or exports.common:nextIndex( messages )
	local messageRealm = messageGlobalID and "global" or "client"
	local messageHolder
	
	messages[ messageRealm ][ messageID ] = { messageType = messageType or "other", disableInput = disableInput }

	messageHolder = messages[ messageRealm ][ messageID ]
	
	local messageHeight = messageHeight - ( hideButton and 25 or 0 )
	
	messageHolder.window = guiCreateWindow( ( screenWidth - messageWidth ) / 2, ( screenHeight - messageHeight ) / 2, messageWidth, messageHeight, "Message", false )
	guiWindowSetSizable( messageHolder.window, false )
	guiSetProperty( messageHolder.window, "AlwaysOnTop", "True" )
	guiSetAlpha( messageHolder.window, 0.925 )
	
	setElementData( messageHolder.window, "messages:id", messageID, false )
	setElementData( messageHolder.window, "messages:type", messageHolder.messageType, false )
	setElementData( messageHolder.window, "messages:realm", messageRealm, false )
	setElementData( messageHolder.window, "messages:disableInput", disableInput, false )
	
	messageHolder.message = guiCreateLabel( 17, 35, 283, 60, message, false, messageHolder.window )
	guiLabelSetHorizontalAlign( messageHolder.message, "center", true )
	guiLabelSetVerticalAlign( messageHolder.message, "center" )

	showCursor( true )
	guiSetInputEnabled( disableInput or false )
	
	if ( not hideButton ) then
		messageHolder.button = guiCreateButton( 16, 109, 284, 25, "Continue", false, messageHolder.window )	
		
		addEventHandler( "onClientGUIClick", messageHolder.button,
			function( )
				destroyMessage( messageHolder.messageType )
			end, false
		)
	end
end
addEvent( "messages:create", true )
addEventHandler( "messages:create", root, createMessage )

function destroyMessage( messageType, messageGlobalID )
	if ( messageType ) then
		for messageIndex, messageID in ipairs( exports.common:findByValue( messages.client, messageType, true ) ) do
			local message = messages.client[ messageID ]
			
			if ( isElement( message.window ) ) then
				destroyElement( message.window )
			end
			
			triggerEvent( "messages:onContinue", localPlayer, messageID, message.messageType, "client", message.disableInput )
			
			messages.client[ messageIndex ] = nil
		end
	else
		if ( messageGlobalID ) then
			local message = messages.global[ messageGlobalID ]

			if ( message ) then
				if ( isElement( message.window ) ) then
					destroyElement( message.window )
				end
				
				triggerEvent( "messages:onContinue", localPlayer, messageID, message.messageType, "global", message.disableInput )
				
				messages.global[ messageGlobalID ] = nil
			end
		end
	end
	
	if ( #messages.client == 0 ) and ( #messages.global == 0 ) then
		showCursor( false )
		guiSetInputEnabled( false )
	end
end
addEvent( "messages:destroy", true )
addEventHandler( "messages:destroy", root, destroyMessage )

addEvent( "messages:onContinue", true )
addEventHandler( "messages:onContinue", root,<commit_msg>messages: fixed non-working messages again<commit_after>local messages = { global = { }, client = { } }
local screenWidth, screenHeight = guiGetScreenSize( )
local messageWidth, messageHeight = 316, 152

function createMessage( message, messageType, messageGlobalID, hideButton, disableInput )
	destroyMessage( messageType )
	destroyMessage( nil, nil, messageGlobalID )

	local messageRealm = messageGlobalID and "global" or "client"
	local messageID = messageGlobalID or exports.common:nextIndex( messages[ messageRealm ] )
	
	messages[ messageRealm ][ messageID ] = { messageType = messageType or "other", disableInput = disableInput }
	
	local messageHeight = messageHeight - ( hideButton and 25 or 0 )
	
	messages[ messageRealm ][ messageID ].window = guiCreateWindow( ( screenWidth - messageWidth ) / 2, ( screenHeight - messageHeight ) / 2, messageWidth, messageHeight, "Message", false )
	guiWindowSetSizable( messages[ messageRealm ][ messageID ].window, false )
	guiSetProperty( messages[ messageRealm ][ messageID ].window, "AlwaysOnTop", "True" )
	guiSetAlpha( messages[ messageRealm ][ messageID ].window, 0.925 )
	
	setElementData( messages[ messageRealm ][ messageID ].window, "messages:id", messageID, false )
	setElementData( messages[ messageRealm ][ messageID ].window, "messages:type", messages[ messageRealm ][ messageID ].messageType, false )
	setElementData( messages[ messageRealm ][ messageID ].window, "messages:realm", messageRealm, false )
	setElementData( messages[ messageRealm ][ messageID ].window, "messages:disableInput", disableInput, false )
	
	if ( messageRealm == "global" ) then
		setElementData( messages[ messageRealm ][ messageID ].window, "messages:globalID", messageGlobalID, false )
	end
	
	messages[ messageRealm ][ messageID ].message = guiCreateLabel( 17, 35, 283, 60, message, false, messages[ messageRealm ][ messageID ].window )
	guiLabelSetHorizontalAlign( messages[ messageRealm ][ messageID ].message, "center", true )
	guiLabelSetVerticalAlign( messages[ messageRealm ][ messageID ].message, "center" )

	showCursor( true )
	guiSetInputEnabled( disableInput or false )
	
	if ( not hideButton ) then
		messages[ messageRealm ][ messageID ].button = guiCreateButton( 16, 109, 284, 25, "Continue", false, messages[ messageRealm ][ messageID ].window )	
		
		addEventHandler( "onClientGUIClick", messages[ messageRealm ][ messageID ].button,
			function( )
				local type = getElementData( getElementParent( source ), "messages:type" )
				local globalID = getElementData( getElementParent( source ), "messages:globalID" )
				
				destroyMessage( type, globalID or nil )
			end, false
		)
	end
end
addEvent( "messages:create", true )
addEventHandler( "messages:create", root, createMessage )

function destroyMessage( messageType, messageGlobalID )
	if ( not messageGlobalID ) then
		for index, data in pairs( messages.client ) do
			if ( data.messageType == messageType ) then
				if ( isElement( messages.client[ index ].window ) ) then
					destroyElement( messages.client[ index ].window )
				end
				
				triggerEvent( "messages:onContinue", localPlayer, index, data.messageType, "client", data.disableInput )
				
				messages.client[ index ] = nil
			end
		end
	else
		if ( messages.global[ messageGlobalID ] ) then
			if ( isElement( messages.global[ messageGlobalID ].window ) ) then
				destroyElement( messages.global[ messageGlobalID ].window )
			end
			
			triggerEvent( "messages:onContinue", localPlayer, messageID, messages.global[ messageGlobalID ].messageType, "global", messages.global[ messageGlobalID ].disableInput )
			
			messages.global[ messageGlobalID ] = nil
		end
	end
	
	if ( exports.common:count( messages.client ) == 0 ) and ( exports.common:count( messages.global ) == 0 ) then
		showCursor( false )
		guiSetInputEnabled( false )
	end
end
addEvent( "messages:destroy", true )
addEventHandler( "messages:destroy", root, destroyMessage )

addEvent( "messages:onContinue", true )
addEventHandler( "messages:onContinue", root,
{'fraction_non_alphanumeric': 0.10536424749622719, 'fraction_numerical': 0.0098778982027713, 'mean_word_length': 5.029776674937965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7031026', 'n_tokens_mistral': 2310, 'n_tokens_neox': 2053, 'n_words': 584}