https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Maccer&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T08:50:43ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=SetGlitchEnabled&diff=40537SetGlitchEnabled2014-07-04T20:13:28Z<p>Maccer: Amended example.</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function enables or disables glitches that are found in the original Single Player game that can be used to gain an advantage in multiplayer. <br />
{{Note|By default all these glitches are disabled - use this function to '''enable''' them.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool setGlitchEnabled ( string glitchName, bool enable )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''glitchName:''' the name of the property to set. Possible values are:<br />
**'''quickreload''' - This is the glitch where switching weapons auto-reloads your weapon, without actually performing the reload animation.<br />
**'''fastmove''' - This is the glitch that can be achieved by a certain key combinations whilst standing up after crouching, which allows you to move quickly with slow weapons (e.g. deagle).<br />
**'''fastfire''' - This is the glitch that can be achieved by cancelling the full fire animation, allowing you to shoot with slow-fire weapons (e.g. deagle) much faster.<br />
**'''crouchbug''' - This is the glitch where the post shooting animation can be aborted by using the crouch key.<br />
**'''highcloserangedamage''' - Enabling this removes the extremely high damage guns inflict when fired at very close range.<br />
**'''hitanim''' - Enabling this allows 'hit by bullet' animations to interrupt player aiming.<br />
**{{New feature|3.0136|1.3.5-6277|'''fastsprint''' - Enabling fastsprint allows players to tap space with a macro to boost their speed beyond normal speeds of GTASA.}}<br />
**{{New feature|3.0136|1.3.5-6419|'''baddrivebyhitbox''' - This glitch leaves players invulnerable to gun fire when performing certain driveby animations. }}<br />
*'''enable:''' whether or not to enable the glitch..<br />
<br />
===Returns===<br />
Returns ''true'' if successful, ''false'' otherwise.<br />
<br />
==Example==<br />
This example enables all glitches in the server once the resource is loaded.<br />
<syntaxhighlight lang="lua"><br />
function resourceStart ()<br />
setGlitchEnabled ( "quickreload", true )<br />
setGlitchEnabled ( "fastmove", true )<br />
setGlitchEnabled ( "fastfire", true )<br />
setGlitchEnabled ( "crouchbug", true )<br />
setGlitchEnabled ( "highcloserangedamage", true )<br />
setGlitchEnabled ( "hitanim", true )<br />
setGlitchEnabled ( "fastsprint", true )<br />
setGlitchEnabled ( "baddrivebyhitbox", true )<br />
end<br />
addEventHandler ( "onResourceStart", getResourceRootElement ( ), resourceStart )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Server functions}}</div>Maccerhttps://wiki.multitheftauto.com/index.php?title=SetGlitchEnabled&diff=40536SetGlitchEnabled2014-07-04T20:12:24Z<p>Maccer: Documented 'baddrivebyhitbox' glitch.</p>
<hr />
<div>__NOTOC__<br />
{{Server function}}<br />
This function enables or disables glitches that are found in the original Single Player game that can be used to gain an advantage in multiplayer. <br />
{{Note|By default all these glitches are disabled - use this function to '''enable''' them.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool setGlitchEnabled ( string glitchName, bool enable )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''glitchName:''' the name of the property to set. Possible values are:<br />
**'''quickreload''' - This is the glitch where switching weapons auto-reloads your weapon, without actually performing the reload animation.<br />
**'''fastmove''' - This is the glitch that can be achieved by a certain key combinations whilst standing up after crouching, which allows you to move quickly with slow weapons (e.g. deagle).<br />
**'''fastfire''' - This is the glitch that can be achieved by cancelling the full fire animation, allowing you to shoot with slow-fire weapons (e.g. deagle) much faster.<br />
**'''crouchbug''' - This is the glitch where the post shooting animation can be aborted by using the crouch key.<br />
**'''highcloserangedamage''' - Enabling this removes the extremely high damage guns inflict when fired at very close range.<br />
**'''hitanim''' - Enabling this allows 'hit by bullet' animations to interrupt player aiming.<br />
**{{New feature|3.0136|1.3.5-6277|'''fastsprint''' - Enabling fastsprint allows players to tap space with a macro to boost their speed beyond normal speeds of GTASA.}}<br />
**{{New feature|3.0136|1.3.5-6419|'''baddrivebyhitbox''' - This glitch leaves players invulnerable to gun fire when performing certain driveby animations. }}<br />
*'''enable:''' whether or not to enable the glitch..<br />
<br />
===Returns===<br />
Returns ''true'' if successful, ''false'' otherwise.<br />
<br />
==Example==<br />
This example enables all glitches in the server once the resource is loaded.<br />
<syntaxhighlight lang="lua"><br />
function resourceStart ()<br />
setGlitchEnabled ( "quickreload", true )<br />
setGlitchEnabled ( "fastmove", true )<br />
setGlitchEnabled ( "fastfire", true )<br />
setGlitchEnabled ( "crouchbug", true )<br />
setGlitchEnabled ( "highcloserangedamage", true )<br />
setGlitchEnabled ( "hitanim", true )<br />
setGlitchEnabled ( "fastsprint", true )<br />
end<br />
addEventHandler ( "onResourceStart", getResourceRootElement ( ), resourceStart )<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Server functions}}</div>Maccerhttps://wiki.multitheftauto.com/index.php?title=Event_system&diff=35010Event system2013-02-24T00:06:42Z<p>Maccer: Documented the hidden 'client' variable</p>
<hr />
<div>__NOTOC__<br />
The event system is at the core of MTA scripting. Events work closely in conjunction with the element tree. Events are triggered when something happens - a player enters a marker, an element is clicked on etc. Each event has a source element, this is the element that performed the action.<br />
<br />
==Event handlers==<br />
To use the event system, you attach event handlers to elements in the element tree using [[addEventHandler]]. When you do this, your function will get triggered for all the events triggered on that element, it's parents (and their parents, etc.) and it's children (and their children). As such, an event handler attached to the ''root'' element will be triggered when an event occurs for any element. As a consequence you should generally use as specific a handler as you can. If you wish to just see when the player enters a specific marker, just attach the event handler to that marker.<br />
<br />
Each event handler has three 'hidden' variables:<br />
* '''source''': This is the element that the event originated from.<br />
* '''this''': This is the element that the handler is being triggered on (i.e. the one you attached it to with addEventHandler).<br />
* '''eventName''': This is the string of the name of the event that was called upon (i.e. the event name that was added with addEventHandler).<br />
<br />
Additionally, the server-side event system also has one more 'hidden' variable:<br />
* '''client''': This is the client that triggered the event using triggerServerEvent. This is not set if the event was not triggered from a client. <br />
<br />
The ''source'' variable is the most important one for most handlers. You almost always will want to reference this variable to tell what element triggered the event. The ''this'' variable has some uses for ensuring that an event was emitted by the element that you attached the handler to.<br />
<br />
It is ''important'' to note that events follow the element hierachy. All events are initially triggered on the ''source'' element, followed by all the parent and children elements. This has few important implications:<br />
<br />
* An event triggered on the root element will be triggered on every element in the element tree. This should be avoided where possible.<br />
* All events anywhere in the element tree will be triggered on the root element. This means you can easily catch every event of a type by attaching a handler to the root element. Only do this if you genuinely want every event of that type, otherwise attach it somewhere more specific in the element tree.<br />
* You can attach an event handler to your resource's root element to get all the events triggered by elements your resource contains.<br />
* You can create 'dummy' elements to catch events from a group of child elements<br />
* You can use dummy elements specified in a .map file (e.g. <flag>) and create 'real' representations for them (e.g. objects) and make these real elements children of the dummy element. Event handlers can then be attached to the dummy element and it will receive all the events of the real elements. This is useful for when one resource manages the representation of the element (creating the objects, for example), while another wants to handle special events. This could be a map resource that wants to handle a flag being captured in a specific way - the map resource would (generally) not be aware of the way the flag is represented. This doesn't matter as it can just attach handlers to it's dummy flag element while the other gamemode resource can handle the representation.<br />
<br />
The function you attached to an event gets called and passed a bunch of arguments. These arguments are event-specific. Each event has specific parameters, for instance [[onClientGUIClick]] has 4 parameters, which are:<br />
<syntaxhighlight lang="lua">string button, string state, int absoluteX, int absoluteY</syntaxhighlight><br />
The function you attached to this event will be passed these parameters as arguments. You must remember that each event has different parameters.<br />
<br />
==Built in events==<br />
MTA has a number of built in events. These are listed on the pages [[Client Scripting Events]] and [[Scripting Events]].<br />
<br />
==Custom events==<br />
You can create your own events that can be triggered across all resources. This is an important way to communicate with other resources and allow them to hook into your code. To add your own custom event, just call the [[addEvent]] function. You can then use the [[triggerEvent]] function to trigger that event any time you want - either using a timer, or based on a more general event. <br />
<br />
For example, you could be making a Capture the Flag game mode and want to trigger an event when a player captures the flag. You could do this by attaching a event handler to the standard MTA [[onMarkerHit]] event and checking that the player entering the marker has the flag. if they do, you can then trigger your more specific ''onFlagCaptured'' event and other resources could handle this as they please.<br />
<br />
==Canceling==<br />
Events can be canceled with [[cancelEvent]]. This can have a variety of effects, but in general this means that the server will not perform whatever action it would usually do. For example, canceling [[onPickupUse]] would prevent a player being given what they tried to pick up, canceling [[onVehicleStartEnter]] would prevent the player entering the vehicle. You can check if the currently active event has been canceled using [[wasEventCanceled]]. It's important to note that canceling event ''does not'' prevent other event handlers being triggered.<br />
<br />
[[Category:Scripting Concepts]]<br />
[[es:Sistema de eventos]]</div>Maccerhttps://wiki.multitheftauto.com/index.php?title=ToJSON&diff=28700ToJSON2011-12-19T02:10:36Z<p>Maccer: Labeled as a server-client function</p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
{{New feature/item|3.0120|1.2||<br />
Available client side in 1.2 and onwards<br />
}}<br />
This function converts one or more variables into a [[JSON]] encoded string. You can use this to store the data and then load it again using [[fromJSON]].<br />
<br />
==Syntax== <br />
<!-- NOTE: don't use 'special' names for variable names, e.g. you shouldn't be writing things like 'player player, vehicle vehicle', instead write something like 'player thePlayer, vehicle vehicleToGetInto'. This is less confusing and prevents the syntax highlighting being odd --><br />
<syntaxhighlight lang="lua"><br />
string toJSON( var arguments ... )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''arguments:''' A list of arguments of any type. Arguments that are elements will be stored as element IDs that are liable to change between sessions. As such, do not save elements across sessions as you will get unpredictable results.<br />
<br />
===Returns===<br />
Returns a JSON formatted string.<br />
<br />
==Example== <br />
This example shows how you can encode an array. The string json should equal ''"["cat", "mouse", {cat:"hungry",mouse:"food"}]" after executed.<br />
<syntaxhighlight lang="lua"><br />
local json = toJSON ( "cat", "mouse", {cat="hungry",mouse="food"} )<br />
</syntaxhighlight><br />
<br />
==Requirements==<br />
{{Requirements|1.0|1.1.1-9.03316|}}<br />
<br />
==See Also==<br />
{{Server_functions}}</div>Maccerhttps://wiki.multitheftauto.com/index.php?title=File:Filtering.jpg&diff=24400File:Filtering.jpg2010-08-27T19:23:18Z<p>Maccer: uploaded a new version of &quot;File:Filtering.jpg&quot;: Reduced the dimensions so the differences are more visible both by thumbnail and full screen.</p>
<hr />
<div></div>Maccer