Resource:Errorwindow: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 15: Line 15:
<section name="Server" class="server" show="true">
<section name="Server" class="server" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
exports.errorwindow: show ( player thePlayer, string text, [int time = 0, string toptext = "ERROR", bool disableByClick = true ] )
exports.errorwindow: show ( player thePlayer, string text, [ int time = 0, string toptext = "ERROR", bool disableByClick = true ] )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===
===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.
*'''thePlayer:''' Player to show the errorwindow to.
*'''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.
*'''text:''' Text to show in the errorwindow.
===Optional Arguments===  
===Optional Arguments===  
{{OptionalArg}}  
{{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.
*'''time:''' Time in milliseconds to show the window, before it disappears (if disableByClick is true and client clicks, timer is overridden).
{{New feature|3|1.0|
*'''disableByClick:''' Close window when client clicks somewhere ('''cursor must be enabled!''').
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.
}}


</section>
</section>
Line 33: Line 31:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool addCommandHandler ( string commandName, function handlerFunction, [bool caseSensitive = true] )
exports.errorwindow: show ( string text, [ int time = 0, string toptext = "ERROR", bool disableByClick = true ] )
</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===
===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.
*'''text:''' Text to show in the errorwindow.
*'''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===  
===Optional Arguments===  
{{OptionalArg}}  
{{OptionalArg}}  
{{New feature|3|1.0|
*'''time:''' Time in milliseconds to show the window, before it disappears (if disableByClick is true and client clicks, timer is overridden).
*'''caseSensitive:''' Specifies if the command handler will ignore the case for this command name.
*'''disableByClick:''' Close window when client clicks somewhere ('''cursor must be enabled!''').
}}
</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===
Returns ''true'' if the command handler was added successfully, ''false'' otherwise.
Returns ''true'' if the command handler was added successfully, ''false'' otherwise.

Revision as of 17:53, 28 May 2012

This resource provides a function that shows an errorwindow.

Example:

Errorwindow.png

In its settings, you can set the color of:

  • Top-background
  • Top-text
  • Text-background
  • Text

Syntax

Click to collapse [-]
Server
exports.errorwindow: show ( player thePlayer, string text, [ int time = 0, string toptext = "ERROR", bool disableByClick = true ] )

Required Arguments

  • thePlayer: Player to show the errorwindow to.
  • text: Text to show in the errorwindow.

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.

  • time: Time in milliseconds to show the window, before it disappears (if disableByClick is true and client clicks, timer is overridden).
  • disableByClick: Close window when client clicks somewhere (cursor must be enabled!).


<section name="Client" class="client" show="true">

exports.errorwindow: show ( string text, [ int time = 0, string toptext = "ERROR", bool disableByClick = true ] )

Required Arguments

  • text: Text to show in the errorwindow.

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.

  • time: Time in milliseconds to show the window, before it disappears (if disableByClick is true and client clicks, timer is overridden).
  • disableByClick: Close window when client clicks somewhere (cursor must be enabled!).

Returns

Returns true if the command handler was added successfully, false otherwise.