SetConsoleCommand Bug

Hello guys,

i am using a function where it creates a button in the Q-Menu-Panel

This is the code for it:



function cl_PProtect.addbtn( plist, text, cmd, args )

	local btn = vgui.Create( "DButton" )

	btn:Center()
	btn:SetText( text )
	btn:SetDark( true )

	btn:SetConsoleCommand( "btn_" .. cmd )

	plist:AddItem( btn )

end


Everything worked nice until my last code snippet.

I am simply adding a button and run a custom console command. This is the code:



cl_PProtect.addbtn(Panel, "Save", "save_b")


In another file I have this code:



function cl_PProtect.Save_B( ply, cmd, args )

	print("SAVED!")

end
concommand.Add("btn_save_b", cl_PProtect.Save_B )


So. it looks very simple, but when i press the button, it says

Unknown Command: ‘btn_save_b’

insteat of showing “SAVED” in the client console.

So, I tried to find the problem and found out this:
If you type ANY command into the client console it says

Unknown command: anycommand

The strange thing is, that there are no apostrophes. Only my command has these strange apostrophes.
Something goes really wrong here -.-

Can you type btn_save_b into console and have it print “SAVED”. If so it’s not an issue with SetConsoleCommand but more likely your file isn’t even being run.

No, it was not printed to the console, but I already solved the problem.

It was just a little spelling mistake. I wrote the function wrong -.-

But thank you anyway :slight_smile: