garrysmod-requests
garrysmod-requests copied to clipboard
clientside serverside-consolecommand autocompletion
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