Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clientside serverside-consolecommand autocompletion #2365

Open
BullyHunter32 opened this issue Apr 20, 2024 · 0 comments
Open

clientside serverside-consolecommand autocompletion #2365

BullyHunter32 opened this issue Apr 20, 2024 · 0 comments

Comments

@BullyHunter32
Copy link

BullyHunter32 commented Apr 20, 2024

Details

May we get a way to implement clientside console command autocompletion for a server-defined console command?

I think a nice solution for this would be to re-implement concommand.Run, maybe something like this?

function Run( player, command, arguments, args )

	local LowerCommand = string.lower( command )

	if ( CommandList[ LowerCommand ] != nil ) then
		CommandList[ LowerCommand ]( player, command, arguments, args )
		return true -- default behaviour
	else if ( AutoComplete[ LowerCommand ] != nil ) then
                return nil -- pass to the server and attempt to run command there
        end

	Msg( "Unknown command: " .. command .. "\n" )

	return false -- default behaviour
end

Which would allow you to define console commands as such:

if SERVER then
        concommand.Add("server_test", function(ply, scmd, tcmd)
                ply:ChatPrint("you said: " .. scmd)
        end)
else
        -- nil passed as command definition, pass to server, keep autocomplete on client
        conommand.Add("server_test", nil, function()
                return {"server_test autocomplete_param"}
        end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant