OnPlayerCommand: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{ScriptItem2 | ||
| | |name = OnPlayerCommand | ||
|side = server | |||
|type = event | |type = event | ||
| | |games = iii vc sa iv | ||
| | |desc = a player submits a chat command.<br>A chat command is different than a chat message; a chat command starts with the command character (a forward slash).<br>By default, chat commands (along with it's parameters, if applicable), are not displayed in the chat box.<br>By default, if there are spacing character(s) before the command character, then it is treated as a chat message instead and displayed in the chat box. | ||
| | |arg1 = Client client The client that submitted a command. | ||
|arg2 = string command The command name. | |||
|arg3 = string parameters The command parameters as a string. | |||
| | |cancel = true | ||
| | |||
|exampleJS = addEventHandler('OnPlayerCommand', (event, client, command, parameters) => { | |exampleJS = addEventHandler('OnPlayerCommand', (event, client, command, parameters) => { | ||
console.log(`(Command) ${client.name} has used the command '/${command} ${parameters}'.`); | console.log(`(Command) ${client.name} has used the command '/${command} ${parameters}'.`); |
Latest revision as of 03:35, 26 February 2024
Event
Server Only
Online and Offline
Cancellable
Available since Server 1.0.0
OnPlayerCommand(Event event, Client client, string command, string parameters)
The OnPlayerCommand event is invoked when a player submits a chat command.
A chat command is different than a chat message; a chat command starts with the command character (a forward slash).
By default, chat commands (along with it's parameters, if applicable), are not displayed in the chat box.
By default, if there are spacing character(s) before the command character, then it is treated as a chat message instead and displayed in the chat box.
A chat command is different than a chat message; a chat command starts with the command character (a forward slash).
By default, chat commands (along with it's parameters, if applicable), are not displayed in the chat box.
By default, if there are spacing character(s) before the command character, then it is treated as a chat message instead and displayed in the chat box.
Parameters
1) | Event | event | The event object for this event. |
2) | Client | client | The client that submitted a command. |
3) | string | command | The command name. |
4) | string | parameters | The command parameters as a string. |
Attributes
cancellable | This event can be cancelled, by using event.preventDefault. |
Notes
There aren't any notes for this event.
Examples
Example 1 - JavaScript:
addEventHandler('OnPlayerCommand', (event, client, command, parameters) => {
console.log(`(Command) ${client.name} has used the command '/${command} ${parameters}'.`);
});
Example 2 - Lua:
addEventHandler('OnPlayerCommand', function(event, client, command, parameters)
console.log(`(Command) ${client.name} has used the command '/${command} ${parameters}'.`);
end);
Compatibility
There isn't any compatibility information for this event.
Related
Server Related
OnPlayerCommand