Resource:Errorwindow: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This resource provides a function that shows an errorwindow.
{{Resource page}}
This resource provides a function that shows an dx-errorwindow. The window's size will fit the text that you put into it.


Example:
Example (top -> errorwindow, bottom -> infowindow):


[[Image:errorwindow.png]]
[[Image:errorwindow.png]]


In its settings, you can set the color of:
In its settings, you can set the color of:
* Top-background
* Top-background (red, green, blue, alpha) (0-255)
* Top-text
* Top-text (red, green, blue) (0-255)
* Text-background
* Text-background (red, green, blue, alpha) (0-255)
* Text
* Text (red, green, blue) (0-255)
 
 
==Download==
http://community.multitheftauto.com/index.php?p=resources&s=details&id=4921
 


==Syntax==  
==Syntax==  
Line 15: Line 21:
<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|
*'''toptext:''' Text in the top of the window ("Scumbag customer" in example-image above).
*'''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>
</section>
Line 33: Line 38:
<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.
*'''toptext:''' Text in the top of the window ("Scumbag customer" in example-image above).
}}
*'''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 ''true'' if the command handler was added successfully, ''false'' otherwise.

Latest revision as of 22:15, 21 February 2021

This resource provides a function that shows an dx-errorwindow. The window's size will fit the text that you put into it.

Example (top -> errorwindow, bottom -> infowindow):

Errorwindow.png

In its settings, you can set the color of:

  • Top-background (red, green, blue, alpha) (0-255)
  • Top-text (red, green, blue) (0-255)
  • Text-background (red, green, blue, alpha) (0-255)
  • Text (red, green, blue) (0-255)


Download

http://community.multitheftauto.com/index.php?p=resources&s=details&id=4921


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).
  • toptext: Text in the top of the window ("Scumbag customer" in example-image above).
  • 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).
  • toptext: Text in the top of the window ("Scumbag customer" in example-image above).
  • disableByClick: Close window when client clicks somewhere (cursor must be enabled!).