Unhandled Usermessage

Hai,

I keep receiving this error (in my console):


Warning: Unhandled usermessage 'SFColouredChat'

What I’m trying to do is print coloured text to the client. In autorun/client/SF_ColourMods.lua I have this:
[lua]
/*

SparkFlare
SF_ColourMods.

	YAYAYAY COLOUR OLOL YAYAYAY WOAH AHAHAHAHQ-wo10i10 [.. you what?

*/

// Echo some awesome chat text.
function ChatReallyCoolText( message )

// Get the colour.
local Colour = Color( message:ReadShort(), message:ReadShort(), message:ReadShort() );

// Get the text.
local Text	 = message:ReadString();

// Check that the text isn't destroyed.
if ( Text && Text ~= "" && Text ~= nil ) then
	
	// If the text is sexy then add it to the chat.
	chat.AddText( Colour, Text );
	
	// Play teh chat sound.
	chat.PlaySound();
	
end

end
usermessage.Hook( “ReallyCoolText”, ChatReallyCoolText );[/lua]

Then in SparkFlare\SF\SF_CoolChat.lua I have this:
[lua]
/*

SparkFlare
SF_ColourMods.

	YAYAYAY COLOUR OLOL YAYAYAY WOAH AHAHAHAHQ-wo10i10 [.. you what?

*/

// Send cool chat.
function SF.ColouredChat( Message )

// Randomize colours.
Colour = {  };
Colour.Red 		= math.random( 0, 255 );
Colour.Blue 	= math.random( 0, 255 );
Colour.Green 	= math.random( 0, 255 );

// Start the usermessage.
umsg.Start( "SFColouredChat" );
	
	// Send the colours.
	umsg.Short( Colour.Red );
	umsg.Short( Colour.Blue );
	umsg.Short( Colour.Green );
	
	// Send the string.
	umsg.String( Message );
	
umsg.End();

end[/lua]

In another file (SF_Resource.lua) I attempt to add the client-side file:
[lua]
/*

SparkFlare
Resources.

	For without my resource of chocolate you would not be seeing this.

*/

// Add the client umsg file.
AddCSLuaFile( “autorun/client/SF_ColourMods.lua” );[/lua]

I can’t quite work out why it’s giving an unhandled usermessage. I’m simply using
[lua]SF.ColouredChat( Text );[/lua]
to call it but every time I get the same console error. There’s no console errors.

Thanks for any suggestions!

Regards,
Elf.

You probably have an error in your clientside file which is causing your usermessage from being hooked, check the console for client errors.

I can’t see an error, anywhere, though thanks for the suggestion. There’s none in console.log or my client console (apart from unhandled usermessage whenever I try to call the function).

can you post your client side script?

It’s there. First code block.

You may need to include the clientside file somewhere on the client, if this is for a gamemode you can do it in cl_init.lua.

It’s an addon. Isn’t it automatically included though, being in lua/autorun/client?

Right, that’s why I said you may need to include it.

Make sure you are sending the file to the client with
[lua]AddCSLuaFile( “autorun/client/SF_ColourMods.lua” )[/lua]

Hmm. I have already done that, but thinking about it the way the script works is it’s all included via autorun/. So technically it’s loading SF_Resource.lua on the client & server; bearing in mind that AddCSLuaFile is server only would this affect this?

Do you have a suggestion as to where I could place the AddCSLuaFile to test this?

None of you noticed that usermessages on client and server have different names?

:regd09:

Oh, stump. Must of happened after I got angry and rebuilt the files.

God dammit, I hate programming in such a way that I love it.