OnPlayerCommand

From GTA Connected
Revision as of 20:28, 19 November 2022 by Mex (talk | contribs)
Jump to navigation Jump to search

Event Server Only icon-iii.png icon-vc.png icon-sa.png icon-iv.png 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 command starts with a forward slash (the command character), and the command is not 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

icon-iii.png icon-vc.png icon-sa.png icon-iv.png OnPlayerCommand