OnConsoleInput: Difference between revisions

From Onset Developer Wiki
(Created page with "{{Info|Event|Server|1.2.1}} {{FuncDescription|Called when a new input in the console happened.}} {{FuncSyntax|OnConsoleInput(input)}} {{FuncParameters}} {{FuncParam|input|T...")
 
No edit summary
Line 1: Line 1:
{{Info|Event|Server|1.2.1}}
{{Info|Event|Server & Client|1.2.1}}


{{FuncDescription|Called when a new input in the console happened.}}
{{FuncDescription|Called when a new input in the console happened.}}
Line 9: Line 9:


== Example ==
== Example ==
'''Server'''
<syntaxhighlight lang="Lua">
<syntaxhighlight lang="Lua">
AddEvent("OnConsoleInput", function(input)
AddEvent("OnConsoleInput", function(input)
Line 16: Line 17:
         ServerExit("Exiting via console command")
         ServerExit("Exiting via console command")
     end
     end
end)
</syntaxhighlight>
'''Client'''
<syntaxhighlight lang="Lua">
AddEvent("OnConsoleInput", function(input)
    print("OnConsoleInput "..input)
end)
end)
</syntaxhighlight>
</syntaxhighlight>

Revision as of 09:37, 7 October 2020

OnConsoleInput

Type: Event
Context: Server & Client
Introduced: v1.2.1

Description

Called when a new input in the console happened.

Syntax

OnConsoleInput(input)

Parameters

  • input
    The text that was typed in the console.

Example

Server

AddEvent("OnConsoleInput", function(input)
    print("OnConsoleInput "..input)

    if input == "quit" or input == "exit" then
        ServerExit("Exiting via console command")
    end
end)

Client

AddEvent("OnConsoleInput", function(input)
    print("OnConsoleInput "..input)
end)

See also