Resource:Errorwindow: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
* Text-background | * Text-background | ||
* Text | * Text | ||
==Syntax== | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
exports.errorwindow: show ( player thePlayer, string text, [int time = 0, string toptext = "ERROR", bool disableByClick = true ] ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function. | |||
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional. | |||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
*'''restricted:''' Specify whether or not this command should be restricted by default. Use this on commands that should be inaccessible to everyone as default except special users specified in the ACL (Access Control List). This is to make sure admin commands such as ie. 'punish' won't be available to everyone if a server administrator forgets masking it in ACL. Make sure to add the command to your ACL under the proper group for it to be usefull (i.e <right name="command.killEveryone" access="true"></right>). This argument defaults to false if nothing is specified. | |||
{{New feature|3|1.0| | |||
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name. | |||
}} | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
bool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''commandName:''' This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function. | |||
*'''handlerFunction:''' This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional. | |||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
{{New feature|3|1.0| | |||
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name. | |||
}} | |||
</section> | |||
====Handler function parameters==== | |||
These are the parameters for the handler function that is called when the command is used. | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua">player playerSource, string commandName, [string arg1, string arg2, ...] </syntaxhighlight> | |||
* '''playerSource:''' The player who triggered the command. If not triggered by a player (e.g. by admin), this will be ''false''. | |||
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function. | |||
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below. | |||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> string commandName, [string arg1, string arg2, ...] </syntaxhighlight> | |||
* '''commandName:''' The name of the command triggered. This is useful if multiple commands go through one function. | |||
* '''arg1, arg2, ...:''' Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain [[nil]]. You can deal with a variable number of arguments using the vararg expression, as shown in '''Server Example 2''' below. | |||
</section> | |||
===Returns=== | |||
Returns ''true'' if the command handler was added successfully, ''false'' otherwise. |
Revision as of 17:49, 28 May 2012
This resource provides a function that shows an errorwindow.
Example:
In its settings, you can set the color of:
- Top-background
- Top-text
- Text-background
- Text
Syntax
Click to collapse [-]
Serverexports.errorwindow: show ( player thePlayer, string text, [int time = 0, string toptext = "ERROR", bool disableByClick = true ] )
Required Arguments
- commandName: This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.
- handlerFunction: This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- restricted: Specify whether or not this command should be restricted by default. Use this on commands that should be inaccessible to everyone as default except special users specified in the ACL (Access Control List). This is to make sure admin commands such as ie. 'punish' won't be available to everyone if a server administrator forgets masking it in ACL. Make sure to add the command to your ACL under the proper group for it to be usefull (i.e <right name="command.killEveryone" access="true"></right>). This argument defaults to false if nothing is specified.
- caseSensitive: Specifies if the command handler will ignore the case for this command name.
Click to collapse [-]
Clientbool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] )
Required Arguments
- commandName: This is the name of the command you wish to attach a handler to. This is what must be typed into the console to trigger the function.
- handlerFunction: This is the function that you want the command to trigger, which has to be defined before you add the handler. This function can take two parameters, playerSource and commandName, followed by as many parameters you expect after your command (see below). These are all optional.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- caseSensitive: Specifies if the command handler will ignore the case for this command name.
Handler function parameters
These are the parameters for the handler function that is called when the command is used.
Click to collapse [-]
Serverplayer playerSource, string commandName, [string arg1, string arg2, ...]
- playerSource: The player who triggered the command. If not triggered by a player (e.g. by admin), this will be false.
- commandName: The name of the command triggered. This is useful if multiple commands go through one function.
- arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below.
Click to collapse [-]
Clientstring commandName, [string arg1, string arg2, ...]
- commandName: The name of the command triggered. This is useful if multiple commands go through one function.
- arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below.
Returns
Returns true if the command handler was added successfully, false otherwise.