Predefined variables list: Difference between revisions
Jump to navigation
Jump to search
CrosRoad95 (talk | contribs) (added missing `sourceTimer `) |
(Fix layout) |
||
Line 1: | Line 1: | ||
== Lua Predefined variables == | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
_G -- returns a table of all global variables | _G -- returns a table of all global variables | ||
Line 14: | Line 14: | ||
== MTA Predefined variables == | |||
=== Global === | |||
<section name="Shared" class="both" show="true"> | <section name="Shared" class="both" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 30: | Line 31: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
=== Event Handlers === | |||
[https://wiki.multitheftauto.com/wiki/AddEventHandler More details about hidden variables in functions and events] | |||
<section name="Shared" class="both" show="true"> | <section name="Shared" class="both" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 36: | Line 41: | ||
this -- Element, which was attached function-handler. | this -- Element, which was attached function-handler. | ||
eventName -- the name of the event ("onResourceStart", "onPlayerWasted" etc.) | eventName -- the name of the event ("onResourceStart", "onPlayerWasted" etc.) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 42: | Line 46: | ||
<section name="Server only" class="server" show="true"> | <section name="Server only" class="server" show="true"> | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
client -- the client that called the event | client -- the client that called the event | ||
sourceResourceRoot -- the root of the resource that called the event | |||
sourceResource -- the resource that called the event | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
=== Timer Callbacks === | |||
<section name="Shared" class="both" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
sourceTimer -- current timer in callback function. | |||
</syntaxhighlight> | |||
</section> | |||
List Predefined variables available in the HTTP files: | === HTTP === | ||
List Predefined variables available in the HTTP files [https://wiki.multitheftauto.com/wiki/Resource_Web_Access (more info about it)]: | |||
<syntaxhighlight lang="lua">[php] | <syntaxhighlight lang="lua">[php] | ||
requestHeaders -- table, contains all HTTP headlines current page. | requestHeaders -- table, contains all HTTP headlines current page. | ||
Line 65: | Line 72: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[ | |||
== See Also == | |||
[[Element_tree|Element Tree]] |
Revision as of 11:04, 11 February 2018
Lua Predefined variables
_G -- returns a table of all global variables coroutine -- returns a table containing functions for threads debug -- returns a table containing debug functions math -- returns a table that contains mathematical functions string -- returns a table containing functions for strings table -- returns a table that contains functions for tables _VERSION -- returns a string of the version of lua in format "Lua 5.1" self -- used in methods arg -- used in functions which use '...' as an argument (https://www.lua.org/pil/5.2.html)
MTA Predefined variables
Global
Click to collapse [-]
Sharedexports -- returns a table of resource names containing all export functions resource -- returns a resource element of the resource the snippet was executed in resourceRoot -- returns a resource root element of the resource the snippet was executed in root -- returns the root element of the server
Click to collapse [-]
Client onlyguiRoot -- returns the root element of all GUI elements. localPlayer -- returns the player element of the local player.
Event Handlers
More details about hidden variables in functions and events
Click to collapse [-]
Sharedsource -- The player or element the event was attached to this -- Element, which was attached function-handler. eventName -- the name of the event ("onResourceStart", "onPlayerWasted" etc.)
Click to collapse [-]
Server onlyclient -- the client that called the event sourceResourceRoot -- the root of the resource that called the event sourceResource -- the resource that called the event
Timer Callbacks
Click to collapse [-]
SharedsourceTimer -- current timer in callback function.
HTTP
List Predefined variables available in the HTTP files (more info about it):
[php] requestHeaders -- table, contains all HTTP headlines current page. form -- table, contains all POST and GET settings, transferred current page. cookies -- table, contains all COOKIE, transferred current page. hostname -- string, contains IP or name host, which requested current page. url -- string, URL current page. user -- element, account user, which requested current page.