https://wiki.multitheftauto.com/api.php?action=feedcontributions&user=Arran+Fortuna&feedformat=atomMulti Theft Auto: Wiki - User contributions [en]2024-03-29T00:08:17ZUser contributionsMediaWiki 1.39.3https://wiki.multitheftauto.com/index.php?title=OnPlayerScreenShot&diff=78752OnPlayerScreenShot2024-01-04T22:23:06Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__ <br />
{{Server event}}<br />
This event is triggered when the screen capture requested by [[takePlayerScreenShot]] has completed.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
resource theResource, string status, string imageData, int timestamp, string tag<br />
</syntaxhighlight> <br />
<br />
*'''theResource''': the [[resource]] which called [[takePlayerScreenShot]].<br />
*'''status''': a [[string]] containing the status of the event which can be one of these values:<br />
**''"ok"'' - the image capture was successful and imageData will contain a JPEG image.<br />
**''"disabled"'' - the image capture failed because the player has disabled screen uploads.<br />
**''"minimized"'' - the image capture failed because the player has minimized the screen (i.e. alt-tabbed).<br />
**''"error"'' - the image capture failed because of an unspecified error.<br />
*'''imageData''': a [[string]] which contains the JPEG image data. This can be saved with the [[Server_Scripting_Functions#File_functions|file functions]], or sent to players with [[triggerClientEvent]] or even uploaded to a web site.<br />
*'''timestamp''': an [[int]] representing the server tick count when the capture was taken.<br />
*'''tag''': a [[string]] passed to [[takePlayerScreenShot]].<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]]<br />
<br />
==Example== <br />
This example captures the screen of a random player every 2 seconds and shows it to everyone:<br />
<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
--------------------------------------------------<br />
-- Take screen shot every 2 seconds<br />
function doTakeScreenShot()<br />
takePlayerScreenShot( getRandomPlayer(), 320, 200 )<br />
end<br />
setTimer(doTakeScreenShot, 2000, 0)<br />
<br />
--------------------------------------------------<br />
-- Receive screen shot result<br />
addEventHandler( "onPlayerScreenShot", root,<br />
function ( theResource, status, pixels, timestamp, tag )<br />
triggerClientEvent( root, "onMyClientScreenShot", resourceRoot, pixels ) -- Relay to all players<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
--------------------------------------------------<br />
-- Turn image data into a texture at the client<br />
addEvent("onMyClientScreenShot",true)<br />
addEventHandler( "onMyClientScreenShot", resourceRoot,<br />
function( pixels )<br />
if image then<br />
destroyElement(image)<br />
end<br />
image = dxCreateTexture( pixels )<br />
end<br />
)<br />
<br />
--------------------------------------------------<br />
-- Show image<br />
addEventHandler( "onClientRender", root,<br />
function()<br />
if image then<br />
dxDrawImage( 100, 250, 320, 200, image )<br />
end<br />
end<br />
)<br />
</syntaxhighlight><br />
</section><br />
<br />
<br />
==Requirements==<br />
{{Requirements|1.3|n/a|}}<br />
<br />
{{See also/Server event|Player events}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Split&diff=78593Split2023-11-15T16:59:40Z<p>Arran Fortuna: Added splitMultiple info to split</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function splits a string into substrings. You specify a character that will act as a separating character; this will determine where to split the sub-strings. For example, it can split the string "Hello World" into two strings containing the two words, by spliting using a space as a separator.<br />
<br />
'''Note:''' You can use the function [[gettok]] to retrieve a single token from the string at a specific index. This may be faster for one-off lookups, but considerably slower if you are going to check each token in a long string.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">table split ( string stringToSplit, string / int separatingChar )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''stringToSplit''' The string you wish to split into parts.<br />
* '''separatingChar''' A string of the character you want to split, or the [[ASCII|ASCII number]] representing the character you want to use to split. If you want to split a string at multiple characters see [[splitMultiple]]<br />
<br />
===Returns===<br />
Returns a ''table'' of substrings split from the original string if successful, ''false'' otherwise.<br />
<br />
{{note|Unicode characters work but when combined with others do not. E.g: #split("a€cb†", "€") returns 3 but #split("a€cb", "€") returns 2.<br />
}}<br />
<br />
<br />
{{note|You can't use same char twice as a separator. Eg.: ||, ||| are the same as |.<br />
}}<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example gives the specified weapons to the given player, while the weapons are a string in the form: 'weaponId,ammo;weaponId2,ammo2;weaponId3,ammo3;..'. This is especially for data read from a .map file attribute.<br />
<syntaxhighlight lang="lua"><br />
function giveWeapons(player, weaponsString)<br />
local weaponsTable = split(weaponsString, ';') --split the string by the semi colon<br />
for k,v in ipairs(weaponsTable) do --for all the split values do<br />
weaponId = gettok(v, 1, string.byte(',')) --get the weapon ID using gettok, retrieve the first token<br />
weaponAmmo = gettok(v, 2, ",") --get the ammo using gettok, retrieve the second token<br />
if (weaponId and weaponAmmo) then --if neither of them is invalid<br />
giveWeapon(player, weaponId, weaponAmmo) --give the player the weapons<br />
end<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Utility functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Template:Useful_Functions&diff=78592Template:Useful Functions2023-11-15T16:58:09Z<p>Arran Fortuna: Added splitMultiple</p>
<hr />
<div>__NOTOC__<br />
=== Table functions ===<br />
*[[addTableChangeHandler]] <span style="color:gray; font-size:smaller;">» This function monitors the changes of a table.</span><br />
*[[getTableFromSql]] <span style="color:gray; font-size:smaller;">» This functionality is used to obtain saved tables using the function ([https://wiki.multitheftauto.com/wiki/SetTableToSql SetTableToSql ]).</span><br />
*[[isValueInTable]] <span style="color:gray; font-size:smaller;">» This function returns true if the value exists in the table, false if the value does not exist in the table.</span><br />
*[[pairsByKeys]] <span style="color:gray; font-size:smaller;">» This function sort pairs table.</span><br />
*[[rangeToTable]] <span style="color:gray; font-size:smaller;">» This function converts a string range to a table containing number values.</span><br />
*[[setTableProtected]] <span style="color:gray; font-size:smaller;">» This function protects a table and makes it read-only.</span><br />
*[[setTableToSql]] <span style="color:gray; font-size:smaller;">» This function is used to save the table in the database (sql).</span><br />
*[[Sort_Functions]] <span style="color:gray; font-size:smaller;">» These functions are able to sort your tables by a key.</span><br />
*[[table.compare]] <span style="color:gray; font-size:smaller;">» This function checks whether two given tables are equal.</span><br />
*[[table.copy]] <span style="color:gray; font-size:smaller;">» This function copies a whole table and all the tables in that table.</span><br />
*[[table.deepmerge]] <span style="color:gray; font-size:smaller;">» This function deep merges two tables. Every nested table will be correspondingly merged.</span><br />
*[[table.element]] <span style="color:gray; font-size:smaller;">» This function returns a new table with only userdata content.</span><br />
*[[table.flip]] <span style="color:gray; font-size:smaller;">» This function returns the table from the last value to the first value, such as reflection.</span><br />
*[[table.fromString]] <span style="color:gray; font-size:smaller;">» This function converts string to a table.</span><br />
*[[table.getRandomRows]] <span style="color:gray; font-size:smaller;">» This function returns random rows from table.</span><br />
*[[table.map]] <span style="color:gray; font-size:smaller;">» This function goes through a table and replaces every field with the return of the passed function, where the field's value is passed as first argument and optionally more arguments.</span><br />
*[[table.merge]] <span style="color:gray; font-size:smaller;">» This function merges two or more tables together.</span><br />
*[[table.random]] <span style="color:gray; font-size:smaller;">» This function retrieves a random value from a table.</span><br />
*[[table.removeValue]] <span style="color:gray; font-size:smaller;">» This function removes a specified value from a table.</span><br />
*[[table.size]] <span style="color:gray; font-size:smaller;">» This function returns the absolute size of a table.</span><br />
<br />
=== ACL functions ===<br />
*[[aclGroupClone]] <span style="color:gray; font-size:smaller;">» This function clone a group to another group with/without ACLs and/or objects.</span><br />
*[[getPlayerAcls]] <span style="color:gray; font-size:smaller;">» This function returns a table of all ACL groups on a player.</span><br />
*[[getPlayersInACLGroup]] <span style="color:gray; font-size:smaller;">» This function returns all players in an ACL group.</span><br />
*[[isPlayerInACL]] <span style="color:gray; font-size:smaller;">» This function checks if a player element is in an ACL group.</span><br />
*[[renameAclGroup]] <span style="color:gray; font-size:smaller;">» This function gives an existing ACL group a new name.</span><br />
<br />
=== Account functions ===<br />
*[[getPlayerFromAccountName]] <span style="color:gray; font-size:smaller;">» This function is used to obtain a player by the name of his account.</span><br />
<br />
=== Camera functions ===<br />
*[[smoothMoveCamera]] <span style="color:gray; font-size:smaller;">» This function allows you to create a cinematic camera flight.</span><br />
<br />
=== Colshape functions ===<br />
*[[createGarageColShape]] <span style="color:gray; font-size:smaller;">» This function creates a collision shape from the specified garage.</span><br />
<br />
=== Cursor functions ===<br />
*[[getCursorMovedOn]] <span style="color:gray; font-size:smaller;">» This function checks in which way the cursor is currently moving.</span><br />
*[[setCursorCenteredOnRectangle]] <span style="color:gray; font-size:smaller;">» This functions will center the cursor inside a rectangle.</span><br />
<br />
=== Drawing functions ===<br />
*[[dxDrawAnimWindow]] <span style="color:gray; font-size:smaller;">» This function draws an animated 2D window on the screen.</span><br />
*[[dxDrawBorderedRectangle]] <span style="color:gray; font-size:smaller;">» This is a function that will create a bordered rectangle.</span><br />
*[[dxDrawBorderedText]] <span style="color:gray; font-size:smaller;">» This is a function that will create a bordered text.</span><br />
*[[dxDrawDashedLine]] <span style="color:gray; font-size:smaller;">» This function draws a line with dashes.</span><br />
*[[dxDrawEditbox]] <span style="color:gray; font-size:smaller;">» This function draws a edit box across the screen - rendered for one frame. This should be used in conjunction with '''onClientRender''' in order to display continuously.</span><br />
*[[dxDrawGifImage]] <span style="color:gray; font-size:smaller;">» This function simulates the effect of a GIF image by using image sprites in 2D.</span><br />
*[[dxDrawImage3D]] <span style="color:gray; font-size:smaller;">» This function draws a 3D image in GTA world.</span><br />
*[[dxDrawImageOnElement]] <span style="color:gray; font-size:smaller;">» This function draws an image on any element.</span><br />
*[[dxDrawLinedRectangle]] <span style="color:gray; font-size:smaller;">» This is a function that will create a rectangle outline with dx lines.</span><br />
*[[dxDrawLoading]] <span style="color:gray; font-size:smaller;">» This function draws a loading bar on the screen.</span><br />
*[[dxDrawOctagon3D]] <span style="color:gray; font-size:smaller;">» This function creates a 3D Octagon</span><br />
*[[dxDrawPolygon]] <span style="color:gray; font-size:smaller;">» This function draws a custom polygon on the screen.</span><br />
*[[dxDrawProgressBar]] <span style="color:gray; font-size:smaller;">» This function simulates a progress bar drawed using DirectDraw.</span><br />
*[[dxDrawRectangle3D]] <span style="color:gray; font-size:smaller;">» This function draws a 3D rectangle in GTA world.</span><br />
*[[dxDrawRectangleOnPlayer]] <span style="color:gray; font-size:smaller;">» This function draws a 3D rectangle above the player.</span><br />
*[[dxDrawRing]] <span style="color:gray; font-size:smaller;">» This function draws a ring with dx lines.</span><br />
*[[dxDrawRombo]] <span style="color:gray; font-size:smaller;">» This function creates a Rhombus.</span><br />
*[[dxDrawSprite]] <span style="color:gray; font-size:smaller;">» This function draw a sprite in the 3D world.</span><br />
*[[dxDrawTextOnElement]] <span style="color:gray; font-size:smaller;">» This function draws a text on any element.</span><br />
*[[dxDrawTextOnRectangle]] <span style="color:gray; font-size:smaller;">» Esta funcion crea un rectangle con un texto dentro.</span><br />
*[[dxDrawTriangle]] <span style="color:gray; font-size:smaller;">» This is a function that will create a triangle with dx lines.</span><br />
*[[dxFade]] <span style="color:gray; font-size:smaller;">» This function fade-in or fade-out any dxDraw by gradually changing its alpha value.</span><br />
*[[dxGetFontSizeFromHeight]] <span style="color:gray; font-size:smaller;">» This function calculates the font size from given height.</span><br />
*[[dxGetRealFontHeight]] <span style="color:gray; font-size:smaller;">» This function calculates the height of a font.</span><br />
*[[getScreenStartPositionFromBox]] <span style="color:gray; font-size:smaller;">» This function helps with getting the correct position for your dx-effects.</span><br />
*[[wordWrap]] <span style="color:gray; font-size:smaller;">» This function breaks a long string into a table of separate lines limited to a specific length in pixels, for drawing separately.</span><br />
*[[CreateRectangle3D]] <span style="color:gray; font-size:smaller;">» This is a function that will create a 3d rectangle on the player screen.</span><br />
*[[DxDrawBordered3DLine]] <span style="color:gray; font-size:smaller;">»This function creates a bordered area with 3D dx lines.</span><br />
<br />
=== Effects functions ===<br />
*[[attachEffect]] <span style="color:gray; font-size:smaller;">» This function allows you attach an effect to an element.</span><br />
*[[setScreenFlash]] <span style="color:gray; font-size:smaller;">» This function will make the screen flash(like a screenshot).</span><br />
<br />
=== Element functions === <br />
*[[autoAttach]] <span style="color:gray; font-size:smaller;">» This function attaches one element into another at the same position and rotation they are.</span><br />
*[[attachElementToBone]] <span style="color:gray; font-size:smaller;">» This function allows you to attach an element to ped bone accurately using new bone functions.</span><br />
*[[getElementDirectionCardialPoint]] <span style="color:gray; font-size:smaller;">» This function returns the direction of the element according to the ''wind rose''.</span><br />
*[[getElementSpeed]] <span style="color:gray; font-size:smaller;">» This function returns the specified element's speed in m/s, km/h or mph.</span><br />
*[[getElementUsingData]] <span style="color:gray; font-size:smaller;">» This function returns table elements that contains the elements data with the given key and value.</span><br />
*[[getElementZoneFullName]] <span style="color:gray; font-size:smaller;">» This function allows you to retrieve the zone full name of a element.</span><br />
*[[getElementsInDimension]] <span style="color:gray; font-size:smaller;">» This function returns a table of elements that are in the specified dimension.</span><br />
*[[getElementsWithinMarker]] <span style="color:gray; font-size:smaller;">» This function returns a table of elements that are within a marker's collision shape.</span><br />
*[[getNearestElement]] <span style="color:gray; font-size:smaller;">» This function returns the nearest element (of a specific type) to a player.</span><br />
*[[isElementInAir]] <span style="color:gray; font-size:smaller;">» This function checks if an element is in air or not.</span><br />
*[[isElementInPhotograph]] <span style="color:gray; font-size:smaller;">» This function checks if an element is in the player's camera picture area.</span><br />
*[[isElementInRange]] <span style="color:gray; font-size:smaller;">» This function allows you to check if an element's range to a main point is within the maximum range.</span><br />
*[[isElementMoving]] <span style="color:gray; font-size:smaller;">» This function checks if an element is moving.</span><br />
*[[isElementPlayer]] <span style="color:gray; font-size:smaller;">» This function checks whether the element is a player or not.</span><br />
*[[isElementWithinAColShape]] <span style="color:gray; font-size:smaller;">» This function checks if an element is within a collision shape element.</span><br />
*[[multi_check]] <span style="color:gray; font-size:smaller;">» This function checks one element to many, handy and clean.</span><br />
*[[setElementSpeed]] <span style="color:gray; font-size:smaller;">» This function allows you to set the speed of an element in kph or mph units.</span><br />
*[[getPositionInFrontOfElement]] <span style="color:gray; font-size:smaller;">» This function returns position in provided distance away from element, including element's rotation.</span><br />
<br />
=== Events ===<br />
*[[onClientPlayerTimeChange]] <span style="color:gray; font-size:smaller;">» This code implements an event that is triggered when the player's real time change.</span><br />
*[[onPlayerZoneChange]] <span style="color:gray; font-size:smaller;">» This code implements an event that is triggered when the player enters a new area on the map.</span><br />
*[[onVehicleWeaponFire]] <span style="color:gray; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicle's weapon.</span><br />
<br />
=== Input functions ===<br />
*[[bindControlKeys]] <span style="color:gray; font-size:smaller;">» This function allows you to bind each key bound to a control individually. Doing this bypasses a little MTA restriction.</span><br />
*[[getBoundControls]] <span style="color:gray; font-size:smaller;">» This function returns a table of control names that are bound to the specified key.</span><br />
*[[unbindControlKeys]] <span style="color:gray; font-size:smaller;">» This function allows you to unbind each key bound to a control individually. Use this function with [[bindControlKeys]].</span><br />
*[[isCommandHandlerAdded]] <span style="color:gray; font-size:smaller;">» This function allows you to check if a command is added or not in the respective resource.</span><br />
<br />
=== Data functions === <br />
*[[byte2human]] <span style="color:gray; font-size:smaller;">» This function converts an integer (number of bytes) into a human-readable unit.</span><br />
*[[capitalize]] <span style="color:gray; font-size:smaller;">» This function capitalizes a given string.</span><br />
*[[convertDate]] <span style="color:gray; font-size:smaller;">» This function converts date to another look.</span><br />
*[[convertServerTickToTimeStamp]] <span style="color:gray; font-size:smaller;">» This function converts server ticks to a unix timestamp.</span><br />
*[[convertTextToSpeech]] <span style="color:gray; font-size:smaller;">» This function converts the provided text to a speech in the provided language which players can hear.</span><br />
*[[findRotation3D]] <span style="color:gray; font-size:smaller;">» This function takes two sets of XYZ coordinates. It returns the 3D direction from point A to point B.</span><br />
*[[findRotation]] <span style="color:gray; font-size:smaller;">» This function takes two points and returns the direction from point A to point B.</span><br />
*[[formatDate]] <span style="color:gray; font-size:smaller;">» This function formats a date on the basis of a format string and returns it.</span><br />
*[[formatNumber]] <span style="color:gray; font-size:smaller;">» This function formats large numbers by adding commas.</span><br />
*[[generateRandomASCIIString]] <span style="color:gray; font-size:smaller;">» This function returns a random string which uses ASCII characters. </span><br />
*[[generateString]] <span style="color:gray; font-size:smaller;">» This function generates a random string with any characters.</span><br />
*[[getAge]] <span style="color:gray; font-size:smaller;">» This function calculates the age of a given birthday.</span><br />
*[[getDistanceBetweenElements]] <span style="color:gray; font-size:smaller;">» Returns the distance between two elements.</span><br />
*[[getDistanceBetweenPointAndSegment2D]] <span style="color:gray; font-size:smaller;">» This function takes point coordinates and line (a segment) starting and ending coordinates. It returns the shortest distance between the point and the line.</span><br />
*[[getEasterDate]] <span style="color:gray; font-size:smaller;">» This function returns easter date monthday and month for a given year.</span><br />
*[[getElementRelatedAngle]] <span style="color:gray; font-size:smaller;">» This function returns the related angle between one element to another. This is useful to check which side an element is to another.</span><br />
*[[getFreeDimension]] <span style="color:gray; font-size:smaller;">» This function get free dimension.</span><br />
*[[getKeyFromValueInTable]] <span style="color:gray; font-size:smaller;">» This function returns the key of the specified value in a table.</span><br />
*[[getOffsetFromXYZ]] <span style="color:gray; font-size:smaller;">» This function allows you to take an entity and a position and calculate the relative offset between them accounting for rotations.</span><br />
*[[getPointFromDistanceRotation]] <span style="color:gray; font-size:smaller;">» This function finds a point based on a starting point, direction and distance.</span><br />
*[[getRealMonth]] <span style="color:gray; font-size:smaller;">» This function returns the current month name</span><br />
*[[getRGColorFromPercentage]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">»This function returns two integers representing red and green colors according to the specified percentage.</span><br />
*[[getScreenRotationFromWorldPosition]] <span style="color:gray; font-size:smaller;">» This function returns a screen relative rotation to a world position.</span><br />
*[[getTimestamp]] <span style="color:gray; font-size:smaller;">» This function returns the UNIX timestamp of a specified date and time.</span><br />
*[[gradientString]] <span style="color:gray; font-size:smaller;">» This function transforms a string in a new coloured gradient string.</span><br />
*[[hex2rgb]] <span style="color:gray; font-size:smaller;">» This function convert hex to rgb.</span><br />
*[[hexColorToRGB]] <span style="color:gray; font-size:smaller;">» This function convert hex string/number to RGBA values.</span><br />
*[[isLeapYear]] <span style="color:gray; font-size:smaller;">» This function returns a boolean representing if a given year is a leap year.</span><br />
*[[isValidMail]] <span style="color:gray; font-size:smaller;">» This function checks whether a provided e-mail string is valid.</span><br />
*[[removeHex]] <span style="color:gray; font-size:smaller;">» This function is used to remove hexadecimal numbers (colors, for example) from strings.<br />
*[[RGBToHex]] <span style="color:gray; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span><br />
*[[RGBToHSV]] <span style="color:gray; font-size:smaller;">» This function convert RGB to HSV color space.</span><br />
*[[RGBToDecimal]] <span style="color:gray; font-size:smaller;">» This function convert RGB to Decimal color.</span><br />
*[[secondsToTimeDesc]] <span style="color:gray; font-size:smaller;">» This function converts a plain seconds-integer into a user-friendly time description.</span><br />
*[[string.count]] <span style="color:gray; font-size:smaller;">» This function counts the amount of occurences of a string in a string.</span><br />
*[[string.explode]] <span style="color:gray; font-size:smaller;">» This function splits a string at a given separator pattern and returns a table with the pieces.</span><br />
*[[string.insert]] <span style="color:gray; font-size:smaller;">» This function inserts a string within another string at a given position.</span><br />
*[[splitMultiple]] <span style="color:gray; font-size:smaller;">» This function improves the split function so that multiple characters can be used as the split at character.</span><br />
*[[switch]] <span style="color:gray; font-size:smaller;">» This function allows the value of a variable or expression to control the flow of program execution via a multiway branch.</span><br />
*[[tocolor2rgba]] <span style="color:gray; font-size:smaller;">» This function convert tocolor to rgba.</span><br />
*[[toHex]] <span style="color:gray; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used client-side.</span><br />
*[[var dump]] <span style="color:gray; font-size:smaller;">» This function outputs information about one or more variables using outputConsole.</span><br />
*[[wavelengthToRGBA]] <span style="color:gray; font-size:smaller;">» This function converts a physical wavelength of light to a RGBA color.</span><br />
<br />
=== GUI functions === <br />
*[[centerWindow]] <span style="color:gray; font-size:smaller;">» This function centers a CEGUI window element responsively in any resolution.</span><br />
*[[guiMoveElement]] <span style="color:gray; font-size:smaller;">» This function moves guiElement by/like using moveObject.</span><br />
*[[guiSetStaticImageMovable]] <span style="color:gray; font-size:smaller;">» This function allows you to move a static image like a gui window.</span><br />
*[[isMouseOnGUICloseButton]] <span style="color:gray; font-size:smaller;">» This function allows you to check whether the mouse cursor/pointer is within a gui-window's native close button.</span><br />
*[[isMouseOnGuiElement]] <span style="color:gray; font-size:smaller;">» This function allows you to check whether or not your mouse is over a specific gui element, this is especially useful if the gui element has a parent. </span><br />
=====Comboboxes=====<br />
*[[guiComboBoxAdjustHeight]] <span style="color:gray; font-size:smaller;">» This function adjusts a CEGUI combobox element to have the correct height.</span><br />
<br />
=====Gridlists=====<br />
*[[convertGridListToText]] <span style="color:gray; font-size:smaller;">» This function converts grid list contents to text.</span><br />
*[[getGridListRowIndexFromText]] <span style="color:gray; font-size:smaller;">» This function returns the GridList row index from the specified text.</span><br />
*[[guiGridListAddPlayers]] <span style="color:gray; font-size:smaller;">» This function add all online players to a grid list.</span><br />
*[[guiGridListGetColumnIDFromTitle]] <span style="color:gray; font-size:smaller;">» This function gets a gridlist's column ID from the column title.</span><br />
*[[guiGridListGetSelectedText]] <span style="color:gray; font-size:smaller;">» This function returns a string containing the inner text of a selected gridlist item.</span><br />
*[[guiGridListSetColumnNonSortable]] <span style="color:gray; font-size:smaller;">» This function makes a gridlist column become non-sortable.</span><br />
*[[isTextInGridList]] <span style="color:gray; font-size:smaller;">» This function checks if some text exist or not in the GridList.</span><br />
<br />
=====Labels=====<br />
*[[guiLabelAddEffect]] <span style="color:gray; font-size:smaller;">» This function add an effects to the gui-label like (shadow, outline).</span><br />
<br />
=== Marker functions ===<br />
*[[createMarkerAttachedTo]] <span style="color:gray; font-size:smaller;">» This function creates a marker that is attached to an element.</span><br />
<br />
=== Math functions ===<br />
*[[math.clamp]] <span style="color:gray; font-size:smaller;">» This function returns the number between range of numbers or it's minimum or maximum.</span><br />
*[[math.getBezierPoint]] <span style="color:gray; font-size:smaller;">» Get N-th order bezier point.</span><br />
*[[math.hypot]] <span style="color:gray; font-size:smaller;">» This function returns the Hypotenuse of the triangle given by sides x and y.</span><br />
*[[math.isPointInPolygon]] <span style="color:gray; font-size:smaller;">» Check if point is inside polygon or not.</span><br />
*[[math.lerp]] <span style="color:gray; font-size:smaller;">» Get val between two integer.</span><br />
*[[math.percent]] <span style="color:gray; font-size:smaller;">» This function returns a percentage from two number values.</span><br />
*[[math.polygonArea]] <span style="color:gray; font-size:smaller;">» Compute area of any polygon.</span><br />
*[[math.randomDiff]] <span style="color:gray; font-size:smaller;">» Generates a pseudo-random integer that's always different from the last random number generated.</span><br />
*[[math.rotVecToEulerAngle]] <span style="color:gray; font-size:smaller;">» Rotation Vector To Euler Angle</span><br />
*[[math.round]] <span style="color:gray; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span><br />
*[[mathNumber]] <span style="color:gray; font-size:smaller;">» This function is a workaround for the client-side floating-point precision of 24-bits.</span><br />
*[[reMap]] <span style="color:gray; font-size:smaller;">» Re-maps a number from one range to another.</span><br />
*[[Math.percentProgress|math.percentProgress]] <span style="color:gray; font-size:smaller;">» Returns a percentage progress from two specific values.</span><br />
*[[math.average]] <span style="color:gray; font-size:smaller;">» This function returns the simple arithmetic mean of multiple numbers.</span><br />
<br />
=== Map functions ===<br />
*[[assignLod]] <span style="color:gray; font-size:smaller;">» This function lets you conveniently generate and apply a LOD model to a mapping object.</span><br />
*[[getWorldPositionFromMapPosition]] <span style="color:gray; font-size:smaller;">» This function converts an F11 map position to world position.</span><br />
<br />
=== Ped functions ===<br />
*[[getAlivePlayersInTeam]] <span style="color:gray; font-size:smaller;">» This function returns a table of the alive players in a team.</span><br />
*[[getGuestPlayers]] <span style="color:gray; font-size:smaller;">» This function gets a players not login or players Guest .</span><br />
*[[getOnlineAdmins]] <span style="color:gray; font-size:smaller;">» This function returns a table of all logged-in administrators.</span><br />
*[[getPedEyesPosition]] <span style="color:gray; font-size:smaller;">» This function allows you to get peds eyes position.</span><br />
*[[getPedGender]] <span style="color:gray; font-size:smaller;">» This function allows you to get peds their gender.</span><br />
*[[getPedMaxHealth]] <span style="color:gray; font-size:smaller;">» This function returns a pedestrians's maximum health by converting it from their maximum health stat.</span><br />
*[[getPedMaxOxygenLevel]] <span style="color:gray; font-size:smaller;">» This function returns a ped's maximum oxygen level by converting it from their maximum underwater stamina stat.</span><br />
*[[getPedWeaponSkill]] <span style="color:gray; font-size:smaller;">» This function returns a ped's corresponding weapon skill level name.</span><br />
*[[getPedHitBone]] <span style="color:gray; font-size:smaller;">» This function gets the approximate number of the bone where the ped is hit.</span><br />
*[[getPlayerFromNamePart]] <span style="color:gray; font-size:smaller;">» This function returns a player from partial name.</span><br />
*[[getPlayerFromSerial]] <span style="color:gray; font-size:smaller;">» This function returns a player from their serial.</span><br />
*[[getPlayersByData]] <span style="color:gray; font-size:smaller;">» This function returns a table of players that have the specified data name.</span><br />
*[[getPlayersInPhotograph]] <span style="color:gray; font-size:smaller;">» This function returns a table of all players in photograph.</span><br />
*[[getPlayersInVehicles]] <span style="color:gray; font-size:smaller;">» This function returns a table of the players insides vehicles from a specified dimension.</span><br />
*[[isPedAiming]]<span style="color:gray; font-size:smaller;">» This function checks if a pedestrian is aiming their weapon.</span><br />
*[[isPedAimingNearPed]] <span style="color:gray; font-size:smaller;">» This is similar to isPedAiming but uses a colshape to be more precise.</span><br />
*[[isPedDiving]] <span style="color:gray; font-size:smaller;">» This feature checks that pedestrian is diving in the water.</span><br />
*[[isPedDrivingVehicle]] <span style="color:gray; font-size:smaller;">» This function checks if a specified pedestrian is driving a vehicle.</span><br />
*[[isPedNearbyWall]] <span style="color:gray; font-size:smaller;">» This function checks if player/ped is nearby a objects like buildings or walls.</span><br />
*[[isPlayerInTeam]] <span style="color:gray; font-size:smaller;">» This function checks if a player is in a specified team.</span><br />
*[[setPedAttack]] <span style="color:gray; font-size:smaller;">» This function will make a ped attack a specified target.</span><br />
*[[setPedFollow]] <span style="color:gray; font-size:smaller;">» This function will make a ped follow a specified target.</span><br />
*[[getPlayerNameFromID]] <span style="color:gray; font-size:smaller;">» This function will get the player name from the ID element data.</span><br />
<br />
=== Player functions ===<br />
*[[countPlayersInRange]] <span style="color:gray; font-size:smaller;">» This function returns the number of players that are within a certain range of the specified coordinates.</span><br />
*[[getPlayerPreviousAndNextWeapon]] <span style="color:gray; font-size:smaller;">» This function returns the player previous and next weapon.</span><br />
*[[getPlayersInRange]] <span style="color:gray; font-size:smaller;">» This function make a table of players within certain range.</span><br />
*[[isPlayerActuallyInVehicle]] <span style="color:gray; font-size:smaller;">» This function checks if a player is actually in a vehicle instead of just in the process of entering.</span><br />
*[[isPlayerHitByVehicle]] <span style="color:gray; font-size:smaller;">» This function cancels event when a element is hit by a vehicle.</span><br />
<br />
=== Resource functions ===<br />
*[[getFilesInResourceFolder]] <span style="color:gray; font-size:smaller;">» This function gets a list of files that are inside a folder of a resource.</span><br />
*[[getResourceScripts]] <span style="color:gray; font-size:smaller;">» This function returns a table of the resource scripts.</span><br />
*[[getResourceSettings]] <span style="color:gray; font-size:smaller;">» This function returns a table of the resource settings.</span><br />
*[[getResourceSize]] <span style="color:gray; font-size:smaller;">» This function returns the size of a specified resource in kB(kilobyte)</span><br />
*[[refreshResource]] <span style="color:gray; font-size:smaller;">» This function refreshes your resource if you changed any of the files<br />
*[[setResourcePriority]] <span style="color:gray; font-size:smaller;">» This function set resource download priority group.</span><br />
<br />
=== Sound functions ===<br />
*[[isSoundFinished]] <span style="color:gray; font-size:smaller;">» This function checks if a sound element has finished.</span><br />
*[[isSoundPlaying]] <span style="color:gray; font-size:smaller;">» This function checks if a sound element is playing or not.</span><br />
*[[stopSoundSlowly]] <span style="color:gray; font-size:smaller;">» This function stop your sound element slowly.</span><br />
<br />
=== Browser functions ===<br />
*[[playVideo]] <span style="color:gray; font-size:smaller;">» This function plays a video on the screen.</span><br />
<br />
=== Team functions ===<br />
*[[getTeamFromColor]] <span style="color:gray; font-size:smaller;">» This function returns a team element by the specified color.</span><br />
*[[getTeamWithFewestPlayers]] <span style="color:gray; font-size:smaller;">» This function returns a team element with least players of all the specified teams.</span><br />
<br />
=== Vehicle functions ===<br />
*[[findEmptyCarSeat]] <span style="color:gray; font-size:smaller;">» This function finds you the first empty seat in a vehicle.</span><br />
*[[getNearestVehicle]] <span style="color:gray; font-size:smaller;">» This function gets the nearest vehicle to the specified player in a specified distance.</span><br />
*[[getRandomVehicle]] <span style="color:gray; font-size:smaller;">» This function gets a random vehicle.</span><br />
*[[getValidVehicleModels]] <span style="color:gray; font-size:smaller;">» This function returns a table of all valid vehicle models.</span><br />
*[[getVehiclesCountByType]] <span style="color:gray; font-size:smaller;">» This function returns the amount of vehicles by the given type as an integer value.</span><br />
*[[getVehicleTurnVelocityCenterOfMass]]<span style="color:gray; font-size:smaller;">» This function gets a vehicle's turn velocity relative to the vehicle's center or mass.</span><br />
*[[isVehicleDoubleExhaust]] <span style="color:gray; font-size:smaller;">» This function checks is exhaust vehicle double.</span><br />
*[[isVehicleEmpty]] <span style="color:gray; font-size:smaller;">» This function checks whether a vehicle is empty.</span><br />
*[[isVehicleOccupied]] <span style="color:gray; font-size:smaller;">» This function checks if a specified vehicle is occupied.</span><br />
*[[isVehicleOnRoof]] <span style="color:gray; font-size:smaller;">» This function checks whether vehicle is on roof.</span><br />
*[[isVehicleOnFire]] <span style="color:gray; font-size:smaller;">» This function checks if the vehicle is on fire or not.</span><br />
*[[isVehicleReversing]] <span style="color:gray; font-size:smaller;">» This function checks if a specified vehicle is moving backwards.</span><br />
*[[isVehicleUpgraded]] <span style="color:gray; font-size:smaller;">» This function checks is vehicle upgraded by upgrade ID.</span><br />
*[[setVehicleGravityPoint]] <span style="color:gray; font-size:smaller;">» This function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.</span><br />
*[[setVehicleTurnVelocityCenterOfMass]] <span style="color:gray; font-size:smaller;">» This function sets a vehicle's turn velocity relative to the vehicle's center or mass.</span><br />
*[[setVehicleHandlingFromText]] <span style="color:gray; font-size:smaller;">» This function sets a vehicle's handling from text.</span><br />
*[[setVehicleWheelModel]] <span style="color:gray; font-size:smaller;">» This function changes the wheel model of the informed vehicle.</span><br />
<br />
=== Weapon functions === <br />
*[[getJetpackWeaponsEnabled]] <span style="color:gray; font-size:smaller;">» This function returns a table of enabled weapons usable on a jetpack.</span><br />
<br />
=== Object functions ===<br />
*[[getDynamicDoorObjectOpenRatio]] <span style="color:gray; font-size:smaller;">» This function tells you how open a dynamic door is in a range from 0 to 1.</span><br />
*[[isElementObject]] <span style="color:gray; font-size:smaller;">» This function tells you if an element is an object or no.</span><br />
<br />
=== XML functions ===<br />
*[[getXMLNodes]] <span style="color:gray; font-size:smaller;">» This function returns all children of a XML node.</span><br />
<br />
=== Engine functions ===<br />
*[[engineGetCOLsFromLibrary]] <span style="color:gray; font-size:smaller;">» This function gets the collision data from the col library.</span><br />
*[[engineLoadIMGContainer]] <span style="color:gray; font-size:smaller;">» This function loads the IMG container.</span><br />
<br />
=== Utility ===<br />
*[[animate]] <span style="color:gray; font-size:smaller;">» This function allows you to use interpolateBetween without render event and easily used.</span><br />
*[[callClientFunction]] <span style="color:gray; font-size:smaller;">» This function allows you to call any client-side function from the server's side.</span><br />
*[[callServerFunction]] <span style="color:gray; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span><br />
*[[check]] <span style="color:gray; font-size:smaller;">» This function checks if its arguments are of the right type and calls the error-function if one is not.</span><br />
*[[checkPassiveTimer]] <span style="color:gray; font-size:smaller;">» This function allows you to use passive timers in your conditions. For example you want to prevent players repeatedly using a command.</span><br />
*[[coroutine.resume]] <span style="color:gray; font-size:smaller;">» This function applies a fix for hidden coroutine error messages.</span><br />
*[[compact]] <span style="color:gray; font-size:smaller;">» This function create table containing variables and their values.</span><br />
*[[getBanFromName]] <span style="color:gray; font-size:smaller;">» This functions returns the ban of the given playername.</span><br />
*[[getCurrentFPS]] <span style="color:gray; font-size:smaller;">» This function returns the frames per second at which GTA: SA is running.</span><br />
*[[getSkinNameFromID]] <span style="color:gray; font-size:smaller;">» This function returns the name of the skin from the given id.</span><br />
*[[IfElse]] <span style="color:gray; font-size:smaller;">» This function returns one of two values based on a boolean expression.</span><br />
*[[isCharInString]] <span style="color:gray; font-size:smaller;">» This shared function allows you to check if a char specified is in a string value.</span><br />
*[[isLastExecuteInTimer]] <span style="color:gray; font-size:smaller;">» This function check if the execute is the last execute in the timer.</span><br />
*[[isMouseInCircle]] <span style="color:gray; font-size:smaller;">» This function checks if a cursor position is in circular area or not.</span><br />
*[[isMouseInPosition]] <span style="color:gray; font-size:smaller;">» This function allows you to check whether the mouse cursor/pointer is within a rectangular position.</span><br />
*[[iterElements]] <span style="color:gray; font-size:smaller;">» This function returns ''a time-saving'' iterator for your for-loops.</span><br />
*[[PlotTrajectoryAtTime]] <span style="color:gray; font-size:smaller;">» Calculate projectile/water trajectory.</span><br />
*[[preprocessor]] <span style="color:gray; font-size:smaller;">» This function allow you to use gcc macros.</span><br />
*[[vector3:compare]] <span style="color:gray; font-size:smaller;">» This method checks whether two vectors match, with optional precision.</span><br />
*[[svgCreateRoundedRectangle]] <span style="color:gray; font-size:smaller;">» This function creates a rectangle with rounded edges.</span><br />
*[[debounce]] <span style="color:gray; font-size:smaller;">» This function is removing unwanted input noise.</span><br />
<br />
<noinclude>[[Category:Useful Functions]]</noinclude></div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=SplitMultiple&diff=78591SplitMultiple2023-11-15T16:55:29Z<p>Arran Fortuna: </p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function splits a string into a table when the specified character(s) are detected.<br/><br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">table splitMultiple( string str, string chars )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''str''': The string to split.<br />
* '''chars''': The characters to detect and split the string at.<br />
<br />
===Returns===<br />
Returns a table containing the pieces of the split string.<br />
<br />
==Code==<br />
<section name="Server- and/or clientside Script" class="both" show="true"><br />
<syntaxhighlight lang="lua"><br />
function splitMultiple(str, word)<br />
local result = {}<br />
local pattern = "(.-)" .. word<br />
<br />
for match in string.gmatch(str, pattern) do<br />
table.insert(result, match)<br />
end<br />
<br />
-- Add the remaining part of the string, if any<br />
local lastPart = string.match(str, word .. "(.*)")<br />
if lastPart then<br />
table.insert(result, lastPart)<br />
end<br />
<br />
return result<br />
end<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight><br />
local text = "This is an example string with some words to split."<br />
local word = "word"<br />
local parts = splitStringByWord(text, word)<br />
<br />
for i, part in ipairs(parts) do<br />
print("Part " .. i .. ": " .. part)<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: ChatGPT-4<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=SplitMultiple&diff=78590SplitMultiple2023-11-15T16:55:10Z<p>Arran Fortuna: Created page with "{{Useful Function}} <lowercasetitle></lowercasetitle> __NOTOC__ This function splits a string into a table when the specified character(s) are detected.<br/> ==Syntax== <syntaxhighlight lang="lua">table splitMultiple( string str )</syntaxhighlight> ===Required Arguments=== * '''str''': The string to split. * '''chars''': The characters to detect and split the string at. ===Returns=== Returns a table containing the pieces of the split string. ==Code== <section name="S..."</p>
<hr />
<div>{{Useful Function}}<br />
<lowercasetitle></lowercasetitle><br />
__NOTOC__<br />
This function splits a string into a table when the specified character(s) are detected.<br/><br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">table splitMultiple( string str )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
* '''str''': The string to split.<br />
* '''chars''': The characters to detect and split the string at.<br />
<br />
===Returns===<br />
Returns a table containing the pieces of the split string.<br />
<br />
==Code==<br />
<section name="Server- and/or clientside Script" class="both" show="true"><br />
<syntaxhighlight lang="lua"><br />
function splitMultiple(str, word)<br />
local result = {}<br />
local pattern = "(.-)" .. word<br />
<br />
for match in string.gmatch(str, pattern) do<br />
table.insert(result, match)<br />
end<br />
<br />
-- Add the remaining part of the string, if any<br />
local lastPart = string.match(str, word .. "(.*)")<br />
if lastPart then<br />
table.insert(result, lastPart)<br />
end<br />
<br />
return result<br />
end<br />
<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight><br />
local text = "This is an example string with some words to split."<br />
local word = "word"<br />
local parts = splitStringByWord(text, word)<br />
<br />
for i, part in ipairs(parts) do<br />
print("Part " .. i .. ": " .. part)<br />
end<br />
</syntaxhighlight><br />
</section><br />
<br />
Author: ChatGPT-4<br />
<br />
==See Also==<br />
{{Useful_Functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Math.clamp&diff=77242Math.clamp2023-08-02T17:43:49Z<p>Arran Fortuna: </p>
<hr />
<div>{{Useful_Function}}<br />
This function returns the number between range of numbers or it's minimum or maximum. Alternatively if you can remember "min max min max" do math.min(math.max(x, min), max)<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">float math.clamp( float number, float min, float max )</syntaxhighlight><br />
<br />
===Required arguments===<br />
* '''number''': Number that will be compared with range.<br />
* '''min''': Minimum of range.<br />
* '''max''': Maximum of range.<br />
<br />
==Code==<br />
<syntaxhighlight lang="lua"><br />
function math.clamp(number, min, max)<br />
if number < min then<br />
return min<br />
elseif number > max then<br />
return max <br />
end<br />
return number<br />
end<br />
</syntaxhighlight><br />
'''Author''': Olez14<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
local num = math.clamp(50, 1, 100)<br />
print(num)<br />
-- This prints 50.0<br />
<br />
local num = math.clamp(-10, 1, 100)<br />
print(num)<br />
-- This prints 1.0<br />
<br />
local num = math.clamp(225, 1, 100)<br />
print(num)<br />
-- This prints 100.0<br />
</syntaxhighlight><br />
<br />
==See also==<br />
{{Useful_Functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Scripting_Tips&diff=77241Scripting Tips2023-08-02T17:30:14Z<p>Arran Fortuna: /* General Lua */</p>
<hr />
<div>This page contains a variety of things that knowing, make life easier for MTA scripters.<br />
<br />
== General Lua ==<br />
* The ''infinite loop / too long execution error'' which aborts execution can be disabled with ''debug.sethook(nil)''<br />
* Be careful when looping a table where you intend to delete multiple rows, if 2 of them are in a row the 2nd one will get skipped! You must loop the table backwards (reverse ipairs). For example: ''for i = #table, 1, -1 do''<br />
* Rather than having if checks inside if checks inside if checks, consider using ''return'' for example ''if (not ready) then return false end''<br />
* A quick way to clamp a number between a lower and upper value: math.min(math.max(x, min), max) and easy to remember, just think: "min max min max"<br />
<br />
== MTA Scripting ==<br />
* Remember that 'false' boolean has a value - If you want to delete a variable or element/account data, use 'nil' instead - this will reduce memory and disk usage (minuscule optimization, only notable on larger servers)<br />
* Remember that 99% of the time it's a bug in your script, not an MTA bug! Don't report something to GitHub Issues until you're absolutely certain the bug can be reproduced with a small piece of script.<br />
* As MTA already has so many functions and events virtually everything you want to do is already possible, as long as you're willing to do the work! You'll find better solutions to problems as there are many ways to achieve the same thing as long as you know all the functions and events.<br />
* If a script is getting too complicated, try putting back-end stuff in another file so the main script calls the functions in the 2nd one. For example rather than having meaningless things like ''vehicleTable[vehicle][7]'' in the main file, put that in a function in the 2nd file and have the main file call a meaningfully named function so rather than seeing a useless ''7'' you'd see something like ''getFuel'' and although this might take longer to set-up you'll save time in the long run as you'll spend less time being confused when you come back to it in a weeks time to debug a problem.<br />
* Your client side scripts can cause desync if you're not careful, try to keep the psychical world equal with every player. For example if your script creates a client side object make sure your script will create it for everyone nearby, else people will be wondering why a player appears to be constantly floating and falling.<br />
* Instead of using ''onClientResourceStart'' or ''onResourceStart'' events attached to ''resourceRoot'' like this:<br />
<syntaxhighlight lang="lua">function warnPeopleThatThisResourceStarted()<br />
outputChatBox("The resource " .. getResourceName(resource) .. " has just started!", 0, 255, 0)<br />
end<br />
addEventHandler("onClientResourceStart", resourceRoot, warnPeopleThatThisResourceStarted)</syntaxhighlight><br />
You can also use this outside of any function:<br />
<syntaxhighlight lang="lua">outputChatBox("The resource " .. getResourceName(resource) .. " has just started!", 0, 255, 0)</syntaxhighlight><br />
And the result will be the same, because Lua executes every instruction in every script file of a resource when it starts.<br />
* string.dump produces unsigned compiled Lua code which is not allowed for security reasons. The only way to transport code now is by using the source code. e.g.:<br />
<syntaxhighlight lang="lua">exampleFunction = [===[<br />
return param<br />
]===]<br />
<br />
local loadedFunction = loadstring(exampleFunction)</syntaxhighlight><br />
<br />
== MTA Scripting - Element IDs Being Reused ==<br />
* If your script is covered in [[isTimer]] and [[isElement]] checks to hide debug warnings from deleted elements not being dereferenced (making the variable nil) you will regret it when that element ID or timer pointer has to be re-used by MTA in a weeks time and your script starts acting strangely and you won't have a clue why. Dereference destroyed elements and disconnected players!<br />
* Why would MTA reuse it in a weeks time? Everything has a userdata value whether it's a function or an element, there is a limited amount of these available meaning that eventually the server will be forced to use the same userdata value twice, as long as whatever that userdata value was for is no longer valid. This could happen within hours, weeks or even never depending on how many elements are being created and destroyed by your scripts.<br />
* For example if you have a race server that has 100 objects in every map and the map was changing every 5 minutes your server would go through at least 1200 an hour, 28,800 a day, 201,600 a week in userdata values, it can't keep going up and up though eventually it will have to reuse the same userdata values and as long as you're dereferencing in your scripts, it won't be a problem.<br />
<br />
The is an example of a script which fails to dereference, because when the player quits their userdata value remains in the table, but what if in a weeks time another player joins and they get assigned the same userdata value?<br />
<syntaxhighlight lang="lua"><br />
<br />
local admins = {}<br />
local secretPasswordOnlyAdminsShouldKnow = "12345678"<br />
<br />
function adminLogin()<br />
if (hasObjectPermissionTo(source, "command.ban", false)) then<br />
admins[source] = true<br />
end<br />
end<br />
addEventHandler("onPlayerLogin", root, adminLogin)<br />
<br />
function cmdGetSecretPassword(plr)<br />
if (not admins[plr]) then<br />
return false<br />
end<br />
outputChatBox("The secret password is "..secretPasswordOnlyAdminsShouldKnow, plr)<br />
end<br />
addCommandHandler("getsecretpass", cmdGetSecretPassword)<br />
</syntaxhighlight><br />
<br />
Some random player who joins in a weeks time gets the same userdata value as an admin, that player can now use "getsecretpass". Solution? De-reference on destruction!<br />
<syntaxhighlight lang="lua"><br />
<br />
function onQuit()<br />
admins[source] = nil<br />
end<br />
addEventHandler("onPlayerQuit", root, onQuit)<br />
</syntaxhighlight><br />
<br />
== Server Performance ==<br />
* Server lagging? Check [[Debugging#Debugging_Performance_Issues|this page of debugging performance issues]]<br />
* Using resourceRoot in event handlers for events from clients is much more efficient than using root.<br />
* Try to be efficient, but if what you're doing is too time consuming or complex, is it really efficient?<br />
* It's much more efficient to [[SetElementHealth]] and [[setElementRotation]] on a player client side, consider a client event all your server scripts can call to set a players health.<br />
* Unless you have hundreds of players, don't worry about making little optimizations, check ''performancebrowser'' or ''ipb'' (ingame performancebrowser) and make sure no resource is using significantly more than the others.<br />
<br />
== Client Performance ==<br />
* The biggest cause of client script CPU usage is anything done in onClient/Pre/Hud/Render because it is called so often. For example if you have a script which calls dxDrawLine3D 20 times, 60 times a second, if those lines are only in 1 part of the map, consider adding a [[getDistanceBetweenPoints3D]] check between the local player and the general area that those lines are in and if they're no where near the player, don't draw the lines.<br />
* Another thing that gets called a lot and could therefore be quite consuming if not careful are events like [[onClientPlayerWeaponFire]] and [[onClientPlayerDamage]] so any scripts that use these should only be bound to the necessary elements (such as localPlayer instead of root) and run the simplest if statements for example if you wanted to handle a certain weapon being fired in a certain dimension it's better to check weapon first as that's a simple weaponID == x rather than getElementDimension(source) == y.<br />
<br />
== Speed comparison between local and global variables ==<br />
<br />
=== Slower ===<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
start = getTickCount()<br />
a = 1<br />
for i=1,10000000 do<br />
a = 1<br />
end<br />
stop = getTickCount()<br />
print("global", stop - start ) -- more than 500ms<br />
</syntaxhighlight><br />
=== Faster ===<br />
<syntaxhighlight lang="lua"><br />
start = getTickCount()<br />
local b = 1<br />
for i=1,10000000 do<br />
b = 1<br />
end<br />
stop = getTickCount()<br />
print("local", stop - start ) -- less than 200ms<br />
</syntaxhighlight><br />
<br />
== Speed comparison between structural and OOP scripting ==<br />
=== Slower ===<br />
<syntaxhighlight lang="lua"><br />
start = getTickCount()<br />
a = 1<br />
for i=1,1000000 do<br />
a = localPlayer.position<br />
end<br />
stop = getTickCount()<br />
print("variable", stop - start ) -- more than 1500ms<br />
</syntaxhighlight><br />
=== Faster ===<br />
<syntaxhighlight lang="lua"><br />
start = getTickCount()<br />
b = nil<br />
for i=1,1000000 do<br />
b = getElementPosition(localPlayer)<br />
end<br />
stop = getTickCount()<br />
print("structural", stop - start ) -- less than 200ms<br />
</syntaxhighlight></div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=77220GetLocalization2023-07-27T18:00:07Z<p>Arran Fortuna: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar_SA"] = "Arabic",<br />
["az_AZ"] = "Azerbaijani",<br />
["bg_BG"] = "Bulgarian",<br />
["bs_BA"] = "Bosnian",<br />
["cs_CZ"] = "Czech",<br />
["da_DK"] = "Danish",<br />
["de_DE"] = "German",<br />
["en_US"] = "English",<br />
["el_GR"] = "Greek",<br />
["es_ES"] = "Spanish",<br />
["et_EE"] = "Estonian",<br />
["fa_IR"] = "Persian",<br />
["fi_FI"] = "Finnish",<br />
["fil_PH"] = "Filipino",<br />
["fr_FR"] = "French",<br />
["he_IL"] = "Hebrew",<br />
["hi_IN"] = "Hindi",<br />
["hr_HR"] = "Croatian",<br />
["hu_HU"] = "Hungarian",<br />
["id_ID"] = "Indonesian",<br />
["it_IT"] = "Italian",<br />
["ja_JP"] = "Japanese",<br />
["ka_GE"] = "Georgian",<br />
["ko_KR"] = "Korean",<br />
["lt_LT"] = "Lithuanian",<br />
["lv_LV"] = "Latvian",<br />
["mk_MK"] = "Macedonian",<br />
["nb_NO"] = "Norwegian",<br />
["nl_NL"] = "Dutch",<br />
["pt_BR"] = "Portuguese, Brazilian",<br />
["pt_PT"] = "Portuguese",<br />
["pl_PL"] = "Polish",<br />
["ru_RU"] = "Russian",<br />
["ro_RO"] = "Romanian",<br />
["sl_SL"] = "Slovenian",<br />
["sv_SE"] = "Swedish",<br />
["sk_SK"] = "Slovak",<br />
["srp"] = "Serbian",<br />
["tr_TR"] = "Turkish",<br />
["uk_UA"] = "Ukrainian",<br />
["vi_VN"] = "Vietnamese",<br />
["zh_CN"] = "Chinese Simplified",<br />
["zh_TW"] = "Chinese Traditional",<br />
<br />
}<br />
</syntaxhighlight><br />
<!-- Or... just update the scripts? Why complicate everything? --><br />
This function is useful for fixing any scripts that were made before MTA 1.6 as some of the language codes were changed.<br />
<syntaxhighlight lang="lua"><br />
<br />
function getLanguageCode(c)<br />
if (c == "fr_FR") then<br />
return "fr"<br />
elseif (c == "ru_RU") then<br />
return "ru"<br />
elseif (c == "pt_PT") then<br />
return "pt_BR"<br />
elseif (c == "pl_PL") then<br />
return "pl"<br />
elseif (c == "tr_TR") then<br />
return "tr"<br />
elseif (c == "es_ES") then<br />
return "es"<br />
elseif (c == "de_DE") then<br />
return "de"<br />
elseif (c == "vi_VN") then<br />
return "vi"<br />
elseif (c == "ar_SA") then<br />
return "ar"<br />
elseif (c == "bg_BG") then<br />
return "bg"<br />
elseif (c == "hu_HU") then<br />
return "hu"<br />
elseif (c == "ro_RO") then<br />
return "ro"<br />
elseif (c == "sv_SE") then<br />
return "sv"<br />
elseif (c == "hr_HR") then<br />
return "hr"<br />
elseif (c == "uk_UA") then<br />
return "uk"<br />
elseif (c == "sl_SL") then<br />
return "sl"<br />
elseif (c == "id_ID") then<br />
return "id"<br />
elseif (c == "nl_NL") then<br />
return "nl"<br />
elseif (c == "it_IT") then<br />
return "it"<br />
elseif (c == "nb_NO") then<br />
return "nb"<br />
elseif (c == "el_GR") then<br />
return "el"<br />
elseif (c == "lt_LT") then<br />
return "lt"<br />
elseif (c == "da_DK") then<br />
return "da"<br />
end<br />
return c<br />
end<br />
<br />
code = getLanguageCode(getLocalization().code)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=77219GetLocalization2023-07-27T17:51:51Z<p>Arran Fortuna: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar_SA"] = "Arabic",<br />
["az_AZ"] = "Azerbaijani",<br />
["bg_BG"] = "Bulgarian",<br />
["bs_BA"] = "Bosnian",<br />
["cs_CZ"] = "Czech",<br />
["da_DK"] = "Danish",<br />
["de_DE"] = "German",<br />
["en_US"] = "English",<br />
["el_GR"] = "Greek",<br />
["es_ES"] = "Spanish",<br />
["et_EE"] = "Estonian",<br />
["fa_IR"] = "Persian",<br />
["fi_FI"] = "Finnish",<br />
["fil_PH"] = "Filipino",<br />
["fr_FR"] = "French",<br />
["he_IL"] = "Hebrew",<br />
["hi_IN"] = "Hindi",<br />
["hr_HR"] = "Croatian",<br />
["hu_HU"] = "Hungarian",<br />
["id_ID"] = "Indonesian",<br />
["it_IT"] = "Italian",<br />
["ja_JP"] = "Japanese",<br />
["ka_GE"] = "Georgian",<br />
["ko_KR"] = "Korean",<br />
["lt_LT"] = "Lithuanian",<br />
["lv_LV"] = "Latvian",<br />
["mk_MK"] = "Macedonian",<br />
["nb_NO"] = "Norwegian",<br />
["nl_NL"] = "Dutch",<br />
["pt_BR"] = "Portuguese, Brazilian",<br />
["pt_PT"] = "Portuguese",<br />
["pl_PL"] = "Polish",<br />
["ru_RU"] = "Russian",<br />
["ro_RO"] = "Romanian",<br />
["sl_SL"] = "Slovenian",<br />
["sv_SE"] = "Swedish",<br />
["sk_SK"] = "Slovak",<br />
["srp"] = "Serbian",<br />
["tr_TR"] = "Turkish",<br />
["uk_UA"] = "Ukrainian",<br />
["vi_VN"] = "Vietnamese",<br />
["zh_CN"] = "Chinese Simplified",<br />
["zh_TW"] = "Chinese Traditional",<br />
<br />
}<br />
</syntaxhighlight><br />
<!-- Or... just update the scripts? Why complicate everything? --><br />
This function is useful for fixing any scripts that were made before MTA 1.6 as some of the language codes were changed.<br />
<syntaxhighlight lang="lua"><br />
<br />
function getLanguageCode(c)<br />
if (c == "fr_FR") then<br />
return "fr"<br />
elseif (c == "ru_RU") then<br />
return "ru"<br />
elseif (c == "pt_PT") then<br />
return "pt_BR"<br />
elseif (c == "pl_PL") then<br />
return "pl"<br />
elseif (c == "tr_TR") then<br />
return "tr"<br />
elseif (c == "es_ES") then<br />
return "es"<br />
elseif (c == "de_DE") then<br />
return "de"<br />
elseif (c == "vi_VN") then<br />
return "vi"<br />
elseif (c == "ar_SA") then<br />
return "ar"<br />
elseif (c == "bg_BG") then<br />
return "bg"<br />
elseif (c == "hu_HU") then<br />
return "hu"<br />
elseif (c == "ro_RO") then<br />
return "ro"<br />
elseif (c == "sv_SE") then<br />
return "sv"<br />
elseif (c == "hr_HR") then<br />
return "hr"<br />
elseif (c == "uk_UA") then<br />
return "uk"<br />
elseif (c == "sl_SL") then<br />
return "sl"<br />
end<br />
return c<br />
end<br />
<br />
code = getLanguageCode(getLocalization().code)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=77143GetLocalization2023-07-03T12:51:43Z<p>Arran Fortuna: /* Example */</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar_SA"] = "Arabic",<br />
["az_AZ"] = "Azerbaijani",<br />
["bg_BG"] = "Bulgarian",<br />
["bs_BA"] = "Bosnian",<br />
["cs_CZ"] = "Czech",<br />
["da_DK"] = "Danish",<br />
["de_DE"] = "German",<br />
["en_US"] = "English",<br />
["el_GR"] = "Greek",<br />
["es_ES"] = "Spanish",<br />
["et_EE"] = "Estonian",<br />
["fa_IR"] = "Persian",<br />
["fi_FI"] = "Finnish",<br />
["fil_PH"] = "Filipino",<br />
["fr_FR"] = "French",<br />
["he_IL"] = "Hebrew",<br />
["hi_IN"] = "Hindi",<br />
["hr_HR"] = "Croatian",<br />
["hu_HU"] = "Hungarian",<br />
["id_ID"] = "Indonesian",<br />
["it_IT"] = "Italian",<br />
["ja_JP"] = "Japanese",<br />
["ka_GE"] = "Georgian",<br />
["ko_KR"] = "Korean",<br />
["lt_LT"] = "Lithuanian",<br />
["lv_LV"] = "Latvian",<br />
["mk_MK"] = "Macedonian",<br />
["nb_NO"] = "Norwegian",<br />
["nl_NL"] = "Dutch",<br />
["pt_BR"] = "Portuguese, Brazilian",<br />
["pt_PT"] = "Portuguese",<br />
["pl_PL"] = "Polish",<br />
["ru_RU"] = "Russian",<br />
["ro_RO"] = "Romanian",<br />
["sl_SL"] = "Slovenian",<br />
["sv_SE"] = "Swedish",<br />
["sk_SK"] = "Slovak",<br />
["srp"] = "Serbian",<br />
["tr_TR"] = "Turkish",<br />
["uk_UA"] = "Ukrainian",<br />
["vi_VN"] = "Vietnamese",<br />
["zh_CN"] = "Chinese Simplified",<br />
["zh_TW"] = "Chinese Traditional",<br />
<br />
}<br />
</syntaxhighlight><br />
<!-- Or... just update the scripts? Why complicate everything? --><br />
This function is useful for fixing any scripts that were made before MTA 1.6 as some of the language codes were changed.<br />
<syntaxhighlight lang="lua"><br />
<br />
function getLanguageCode(c)<br />
if (c == "fr_FR") then<br />
return "fr"<br />
elseif (c == "ru_RU") then<br />
return "ru"<br />
elseif (c == "pt_PT") then<br />
return "pt_BR"<br />
elseif (c == "pl_PL") then<br />
return "pl"<br />
elseif (c == "tr_TR") then<br />
return "tr"<br />
elseif (c == "es_ES") then<br />
return "es"<br />
elseif (c == "de_DE") then<br />
return "de"<br />
elseif (c == "vi_VN") then<br />
return "vi"<br />
elseif (c == "ar_SA") then<br />
return "ar"<br />
elseif (c == "bg_BG") then<br />
return "bg"<br />
elseif (c == "hu_HU") then<br />
return "hu"<br />
elseif (c == "ro_RO") then<br />
return "ro"<br />
elseif (c == "sv_SE") then<br />
return "sv"<br />
elseif (c == "hr_HR") then<br />
return "hr"<br />
elseif (c == "uk_UA") then<br />
return "uk"<br />
end<br />
return c<br />
end<br />
<br />
code = getLanguageCode(getLocalization().code)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=77142GetLocalization2023-07-03T12:51:16Z<p>Arran Fortuna: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar_SA"] = "Arabic",<br />
["az_AZ"] = "Azerbaijani",<br />
["bg_BG"] = "Bulgarian",<br />
["bs_BA"] = "Bosnian",<br />
["cs_CZ= "Czech",<br />
["da_DK"] = "Danish",<br />
["de_DE"] = "German",<br />
["en_US"] = "English",<br />
["el_GR"] = "Greek",<br />
["es_ES"] = "Spanish",<br />
["et_EE"] = "Estonian",<br />
["fa_IR"] = "Persian",<br />
["fi_FI"] = "Finnish",<br />
["fil_PH"] = "Filipino",<br />
["fr_FR"] = "French",<br />
["he_IL"] = "Hebrew",<br />
["hi_IN"] = "Hindi",<br />
["hr_HR"] = "Croatian",<br />
["hu_HU"] = "Hungarian",<br />
["id_ID"] = "Indonesian",<br />
["it_IT"] = "Italian",<br />
["ja_JP"] = "Japanese",<br />
["ka_GE"] = "Georgian",<br />
["ko_KR"] = "Korean",<br />
["lt_LT"] = "Lithuanian",<br />
["lv_LV"] = "Latvian",<br />
["mk_MK"] = "Macedonian",<br />
["nb_NO"] = "Norwegian",<br />
["nl_NL"] = "Dutch",<br />
["pt_BR"] = "Portuguese, Brazilian",<br />
["pt_PT"] = "Portuguese",<br />
["pl_PL"] = "Polish",<br />
["ru_RU"] = "Russian",<br />
["ro_RO"] = "Romanian",<br />
["sl_SL"] = "Slovenian",<br />
["sv_SE"] = "Swedish",<br />
["sk_SK"] = "Slovak",<br />
["srp"] = "Serbian",<br />
["tr_TR"] = "Turkish",<br />
["uk_UA"] = "Ukrainian",<br />
["vi_VN"] = "Vietnamese",<br />
["zh_CN"] = "Chinese Simplified",<br />
["zh_TW"] = "Chinese Traditional",<br />
<br />
}<br />
</syntaxhighlight><br />
<!-- Or... just update the scripts? Why complicate everything? --><br />
This function is useful for fixing any scripts that were made before MTA 1.6 as some of the language codes were changed.<br />
<syntaxhighlight lang="lua"><br />
<br />
function getLanguageCode(c)<br />
if (c == "fr_FR") then<br />
return "fr"<br />
elseif (c == "ru_RU") then<br />
return "ru"<br />
elseif (c == "pt_PT") then<br />
return "pt_BR"<br />
elseif (c == "pl_PL") then<br />
return "pl"<br />
elseif (c == "tr_TR") then<br />
return "tr"<br />
elseif (c == "es_ES") then<br />
return "es"<br />
elseif (c == "de_DE") then<br />
return "de"<br />
elseif (c == "vi_VN") then<br />
return "vi"<br />
elseif (c == "ar_SA") then<br />
return "ar"<br />
elseif (c == "bg_BG") then<br />
return "bg"<br />
elseif (c == "hu_HU") then<br />
return "hu"<br />
elseif (c == "ro_RO") then<br />
return "ro"<br />
elseif (c == "sv_SE") then<br />
return "sv"<br />
elseif (c == "hr_HR") then<br />
return "hr"<br />
elseif (c == "uk_UA") then<br />
return "uk"<br />
end<br />
return c<br />
end<br />
<br />
code = getLanguageCode(getLocalization().code)<br />
</syntaxhighlight><br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=77120GetLocalization2023-06-26T19:44:23Z<p>Arran Fortuna: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all (probably all) the language codes used in MTA in a table with the full name of the language. Note that when MTA 1.6 was released some of these have changed.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar"] = "Arabic",<br />
["bg"] = "Bulgarian",<br />
["cs"] = "Czech",<br />
["da"] = "Danish",<br />
["de"] = "German",<br />
["en_US"] = "English",<br />
["el"] = "Greek",<br />
["es"] = "Spanish",<br />
["et"] = "Estonian",<br />
["fr"] = "French",<br />
["hr"] = "Croatian",<br />
["hu"] = "Hungarian",<br />
["id"] = "Indonesian",<br />
["it"] = "Italian",<br />
["ja"] = "Japanese",<br />
["lt"] = "Lithuanian",<br />
["lv"] = "Latvian",<br />
["mk"] = "Macedonian",<br />
["nb"] = "Norwegian",<br />
["nl"] = "Dutch",<br />
["pt_BR"] = "Brazilian",<br />
["pl"] = "Polish",<br />
["ru"] = "Russian",<br />
["ro"] = "Romanian",<br />
["sl"] = "Slovenian",<br />
["sv"] = "Swedish",<br />
["sk"] = "Slovak",<br />
["tr"] = "Turkish",<br />
["uk"] = "Ukrainian",<br />
["vi"] = "Vietnamese",<br />
["zh_CN"] = "Chinese",<br />
["zh_TW"] = "Taiwanese",<br />
<br />
}<br />
</syntaxhighlight><br />
This function is useful for fixing any scripts that were made before MTA 1.6 as some of the language codes were changed.<br />
<syntaxhighlight lang="lua"><br />
<br />
function getLanguageCode(c)<br />
if (c == "fr_FR") then<br />
return "fr"<br />
elseif (c == "ru_RU") then<br />
return "ru"<br />
elseif (c == "pt_PT") then<br />
return "pt_BR"<br />
elseif (c == "pl_PL") then<br />
return "pl"<br />
elseif (c == "tr_TR") then<br />
return "tr"<br />
elseif (c == "es_ES") then<br />
return "es"<br />
elseif (c == "de_DE") then<br />
return "de"<br />
elseif (c == "vi_VN") then<br />
return "vi"<br />
elseif (c == "ar_SA") then<br />
return "ar"<br />
elseif (c == "bg_BG") then<br />
return "bg"<br />
elseif (c == "hu_HU") then<br />
return "hu"<br />
elseif (c == "ro_RO") then<br />
return "ro"<br />
elseif (c == "sv_SE") then<br />
return "sv"<br />
elseif (c == "hr_HR") then<br />
return "hr"<br />
elseif (c == "uk_UA") then<br />
return "uk"<br />
end<br />
return c<br />
end<br />
<br />
code = getLanguageCode(getLocalization().code)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=77119GetLocalization2023-06-26T19:26:25Z<p>Arran Fortuna: </p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all (probably all) the language codes used in MTA in a table with the full name of the language. Note that when MTA 1.6 was released some of these have changed.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar"] = "Arabic",<br />
["bg"] = "Bulgarian",<br />
["cs"] = "Czech",<br />
["da"] = "Danish",<br />
["de"] = "German",<br />
["en_US"] = "English",<br />
["el"] = "Greek",<br />
["es"] = "Spanish",<br />
["et"] = "Estonian",<br />
["fr"] = "French",<br />
["hr"] = "Croatian",<br />
["hu"] = "Hungarian",<br />
["id"] = "Indonesian",<br />
["it"] = "Italian",<br />
["ja"] = "Japanese",<br />
["lt"] = "Lithuanian",<br />
["lv"] = "Latvian",<br />
["mk"] = "Macedonian",<br />
["nb"] = "Norwegian",<br />
["nl"] = "Dutch",<br />
["pt_BR"] = "Brazilian",<br />
["pl"] = "Polish",<br />
["ru"] = "Russian",<br />
["ro"] = "Romanian",<br />
["sl"] = "Slovenian",<br />
["sv"] = "Swedish",<br />
["sk"] = "Slovak",<br />
["tr"] = "Turkish",<br />
["uk"] = "Ukrainian",<br />
["vi"] = "Vietnamese",<br />
["zh_CN"] = "Chinese",<br />
["zh_TW"] = "Taiwanese",<br />
<br />
}<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Scripting_Tips&diff=75635Scripting Tips2022-10-31T17:22:08Z<p>Arran Fortuna: </p>
<hr />
<div>This page contains a variety of things that knowing, make life easier for MTA scripters.<br />
<br />
== General Lua ==<br />
* The ''infinite loop / too long execution error'' which aborts execution can be disabled with ''debug.sethook(nil)''<br />
* Be careful when looping a table where you intend to delete multiple rows, if 2 of them are in a row the 2nd one will get skipped! You must loop the table backwards (reverse ipairs). For example: ''for i = #table, 1, -1 do''<br />
* Rather than having if checks inside if checks inside if checks, consider using ''return'' for example ''if (not ready) then return false end''<br />
<br />
== MTA Scripting ==<br />
* Remember that 'false' boolean has a value - If you want to delete a variable or element/account data, use 'nil' instead - this will reduce memory and disk usage (minuscule optimization, only notable on larger servers)<br />
* Remember that 99% of the time it's a bug in your script, not an MTA bug! Don't report something to GitHub Issues until you're absolutely certain the bug can be reproduced with a small piece of script.<br />
* As MTA already has so many functions and events virtually everything you want to do is already possible, as long as you're willing to do the work! You'll find better solutions to problems as there are many ways to achieve the same thing as long as you know all the functions and events.<br />
* If a script is getting too complicated, try putting back-end stuff in another file so the main script calls the functions in the 2nd one. For example rather than having meaningless things like ''vehicleTable[vehicle][7]'' in the main file, put that in a function in the 2nd file and have the main file call a meaningfully named function so rather than seeing a useless ''7'' you'd see something like ''getFuel'' and although this might take longer to set-up you'll save time in the long run as you'll spend less time being confused when you come back to it in a weeks time to debug a problem.<br />
* Your client side scripts can cause desync if you're not careful, try to keep the psychical world equal with every player. For example if your script creates a client side object make sure your script will create it for everyone nearby, else people will be wondering why a player appears to be constantly floating and falling.<br />
* Instead of using ''onClientResourceStart'' or ''onResourceStart'' events attached to ''resourceRoot'' like this:<br />
<syntaxhighlight lang="lua">function warnPeopleThatThisResourceStarted()<br />
outputChatBox("The resource " .. getResourceName(resource) .. " has just started!", 0, 255, 0)<br />
end<br />
addEventHandler("onClientResourceStart", resourceRoot, warnPeopleThatThisResourceStarted)</syntaxhighlight><br />
You can also use this outside of any function:<br />
<syntaxhighlight lang="lua">outputChatBox("The resource " .. getResourceName(resource) .. " has just started!", 0, 255, 0)</syntaxhighlight><br />
And the result will be the same, because Lua executes every instruction in every script file of a resource when it starts.<br />
* string.dump produces unsigned compiled Lua code which is not allowed for security reasons. The only way to transport code now is by using the source code. e.g.:<br />
<syntaxhighlight lang="lua">exampleFunction = [===[<br />
return param<br />
]===]<br />
<br />
local loadedFunction = loadstring(exampleFunction)</syntaxhighlight><br />
<br />
== MTA Scripting - Element IDs Being Reused ==<br />
* If your script is covered in [[isTimer]] and [[isElement]] checks to hide debug warnings from deleted elements not being dereferenced (making the variable nil) you will regret it when that element ID or timer pointer has to be re-used by MTA in a weeks time and your script starts acting strangely and you won't have a clue why. Dereference destroyed elements and disconnected players!<br />
* Why would MTA reuse it in a weeks time? Everything has a userdata value whether it's a function or an element, there is a limited amount of these available meaning that eventually the server will be forced to use the same userdata value twice, as long as whatever that userdata value was for is no longer valid. This could happen within hours, weeks or even never depending on how many elements are being created and destroyed by your scripts.<br />
* For example if you have a race server that has 100 objects in every map and the map was changing every 5 minutes your server would go through at least 1200 an hour, 28,800 a day, 201,600 a week in userdata values, it can't keep going up and up though eventually it will have to reuse the same userdata values and as long as you're dereferencing in your scripts, it won't be a problem.<br />
<br />
The is an example of a script which fails to dereference, because when the player quits their userdata value remains in the table, but what if in a weeks time another player joins and they get assigned the same userdata value?<br />
<syntaxhighlight lang="lua"><br />
<br />
local admins = {}<br />
local secretPasswordOnlyAdminsShouldKnow = "12345678"<br />
<br />
function adminLogin()<br />
if (hasObjectPermissionTo(source, "command.ban", false)) then<br />
admins[source] = true<br />
end<br />
end<br />
addEventHandler("onPlayerLogin", root, adminLogin)<br />
<br />
function cmdGetSecretPassword(plr)<br />
if (not admins[plr]) then<br />
return false<br />
end<br />
outputChatBox("The secret password is "..secretPasswordOnlyAdminsShouldKnow, plr)<br />
end<br />
addCommandHandler("getsecretpass", cmdGetSecretPassword)<br />
</syntaxhighlight><br />
<br />
Some random player who joins in a weeks time gets the same userdata value as an admin, that player can now use "getsecretpass". Solution? De-reference on destruction!<br />
<syntaxhighlight lang="lua"><br />
<br />
function onQuit()<br />
admins[source] = nil<br />
end<br />
addEventHandler("onPlayerQuit", root, onQuit)<br />
</syntaxhighlight><br />
<br />
== Server Performance ==<br />
* Server lagging? Check [[Debugging#Debugging_Performance_Issues|this page of debugging performance issues]]<br />
* Using resourceRoot in event handlers for events from clients is much more efficient than using root.<br />
* Try to be efficient, but if what you're doing is too time consuming or complex, is it really efficient?<br />
* It's much more efficient to [[SetElementHealth]] and [[setElementRotation]] on a player client side, consider a client event all your server scripts can call to set a players health.<br />
* Unless you have hundreds of players, don't worry about making little optimizations, check ''performancebrowser'' or ''ipb'' (ingame performancebrowser) and make sure no resource is using significantly more than the others.<br />
<br />
== Client Performance ==<br />
* The biggest cause of client script CPU usage is anything done in onClient/Pre/Hud/Render because it is called so often. For example if you have a script which calls dxDrawLine3D 20 times, 60 times a second, if those lines are only in 1 part of the map, consider adding a [[getDistanceBetweenPoints3D]] check between the local player and the general area that those lines are in and if they're no where near the player, don't draw the lines.<br />
* Another thing that gets called a lot and could therefore be quite consuming if not careful are events like [[onClientPlayerWeaponFire]] and [[onClientPlayerDamage]] so any scripts that use these should only be bound to the necessary elements (such as localPlayer instead of root) and run the simplest if statements for example if you wanted to handle a certain weapon being fired in a certain dimension it's better to check weapon first as that's a simple weaponID == x rather than getElementDimension(source) == y.<br />
<br />
== Speed comparison between local and global variables ==<br />
<br />
=== Slower ===<br />
<br />
<syntaxhighlight lang="lua"><br />
<br />
start = getTickCount()<br />
a = 1<br />
for i=1,10000000 do<br />
a = 1<br />
end<br />
stop = getTickCount()<br />
print("global", stop - start ) -- more than 500ms<br />
</syntaxhighlight><br />
=== Faster ===<br />
<syntaxhighlight lang="lua"><br />
start = getTickCount()<br />
local b = 1<br />
for i=1,10000000 do<br />
b = 1<br />
end<br />
stop = getTickCount()<br />
print("local", stop - start ) -- less than 200ms<br />
</syntaxhighlight><br />
<br />
== Speed comparison between structural and OOP scripting ==<br />
=== Slower ===<br />
<syntaxhighlight lang="lua"><br />
start = getTickCount()<br />
a = 1<br />
for i=1,1000000 do<br />
a = localPlayer.position<br />
end<br />
stop = getTickCount()<br />
print("variable", stop - start ) -- more than 1500ms<br />
</syntaxhighlight><br />
=== Faster ===<br />
<syntaxhighlight lang="lua"><br />
start = getTickCount()<br />
b = nil<br />
for i=1,1000000 do<br />
b = getElementPosition(localPlayer)<br />
end<br />
stop = getTickCount()<br />
print("structural", stop - start ) -- less than 200ms<br />
</syntaxhighlight></div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Compiling_MTASA&diff=73027Compiling MTASA2021-11-15T16:42:12Z<p>Arran Fortuna: Updated again, should be right now, will ask a dev about it.</p>
<hr />
<div>In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.<br />
<br />
Please read the instructions carefully and do not skip parts of it, if you have no experience.<br />
<br />
== Prerequisites ==<br />
<br />
Compiling the Multi Theft Auto client is only supported on Windows 10.<br />
<br />
Make sure you have the following software and SDKs installed:<br />
<br />
=== Visual Studio 2019 ===<br />
[[File:Visual_Studio_Community.PNG|right|150px|link=https://www.visualstudio.com/vs/]]<br />
# '''[https://visualstudio.microsoft.com/vs/ Download Microsoft Visual Studio 2019]''' - make sure you get the Community Edition, that one is free.<br />
# On the installation checklist, [[:File:VsFoundationClasses.png|make sure you tick these 3 items]]:<br />
## ''Desktop development with C++''<br />
## ''MSVC v142 - VS 2019 C++ x64/x86 build tools''<br />
## In the 'Individual Components' tab search 'MFC v142' and select 'C++ v14.29 (16.11) MFC for v142 build tools (x86 & x64)'<br />
<br />
If you don't enable MFC, you will get the following error: <code>cannot open include file 'afxres.h'</code>.<br />
<br />
If you've made a mistake, you can run the ''Visual Studio Installer'' app to modify your current installation. There is no need to uninstall and reinstall.<br />
<br />
=== Microsoft DirectX SDK ===<br />
[[File:DirectX_SDK.jpg|right|150px|link=http://web.archive.org/web/20200804044856/https://www.microsoft.com/en-us/download/details.aspx?id=23549]]<br />
'''Download Microsoft DirectX SDK (August 2009) (DXSDK_Aug09.exe):'''<br />
* [https://archive.org/download/dxsdk_aug09/DXSDK_Aug09.exe Mirror 1]<br />
* [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe Mirror 2]<br />
<br />
{| class="wikitable" style="margin-top: 0px; width: 70%; word-break: break-all;"<br />
|+ File verification<br />
|- style="vertical-align:bottom;"<br />
! colspan="2" | Algorithm and variant<br />
! Hash<br />
! Hash file<br />
|- style="text-align:center;vertical-align:center;"<br />
| rowspan="6" | '''{{nowrap|SHA-3}}''' || ''SHA3-224'' || 8bfcdc03518d7edd34689534fd4d21291469ff2f2eb10437ad648c58 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-224 DXSDK_Aug09.exe.sha3-224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-256'' || 45bf3e08da3b3636ddb4f4a74243430f8d65759c074c0d79756ef810c4701c5a || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-256 DXSDK_Aug09.exe.sha3-256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-384'' || b358e529963d6f5fd7f8bd4b530fb18f6a2e6a442009a54e981b2f9967589ed48150af310f283640d56f9b60d41100c9 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-384 DXSDK_Aug09.exe.sha3-384]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-512'' || 43522187053af744250059ef69c0f3083cecd1157fe56daac16b9497ebc6fb5b525875144e42898367c55f757cffd3526f37074d544470578602a5a944a45a75 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-512 DXSDK_Aug09.exe.sha3-512]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHAKE128'' || 2a7c81bde9e867cbb5ef00b72ad8de66a3ee64c1d59f16465fa712479b6a84d28a02cc5ed08afa1d51e72011657453dbd4656cc9340d32e18179c39d03982dfc35c8f0c2a5c99e11dc74d0e23ed21b1e55f19c809a5a152bde39a2d46fcd12421f373f2d691ade1b57faf6c2ab7aded5a7d174f1f1c77127c0d6a1523b4775c569c5e1b4efa2da4bf2f708a96707a709e245a7f507382e69a81777919c90e95a091c0b699ce7f517 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-128000 DXSDK_Aug09.exe.sha3-128000]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHAKE256'' || 9c100dac5245a61774f3a2752bf9e941bdcd5654b18035155161c63b20936dfc9bd7334feb9a6fe9a99a65491161083b39ac3bd578e2cf4f90cba3c786e9924fa0611f65a725331b77b63e7c8b552e1637bc77531ba0f2c9cac72115b28e523929ede4e5b246a0755e8d5c4089d94bf16627fb08672cfffa523bba3d976489a0eec60d3c6a96ca2b || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-256000 DXSDK_Aug09.exe.sha3-256000]<br />
|- style="text-align:center;vertical-align:center;"<br />
| rowspan="6" | '''{{nowrap|SHA-2}}''' || ''SHA-224'' || a3a74b89cccfe314b79418d5598aac5e94800221e5d945c74f15c004 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-224 DXSDK_Aug09.exe.sha2-224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-256'' || 4ab1de69312f10f6b41310a5218d80c478bbd823bc0f86627318d690b128fb9f || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-256 DXSDK_Aug09.exe.sha2-256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-384'' || 254ed29c6ad2cadc6f013d2d51c0ac78a6bbe236a2c94ca99610eba8b2c1200d1a62c445ca9ee51bb09354875d5eca8a || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-384 DXSDK_Aug09.exe.sha2-384]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512'' || style="width: 60%;" | 736393c0dfa32221e229890f87eb330174d70dd2a02fa0cace303816d3e7a10a332a44129748de39665d1b339e627d6028c2080268f7afdd5240c447fec8ff0b || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512 DXSDK_Aug09.exe.sha2-512]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512/224'' || 7e23d9ba916000782a17e23abf48e25237f45590cfe767aed9d79f10 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512224 DXSDK_Aug09.exe.sha2-512224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512/256'' || 0c833a56046fe7e4213fcb1862c730acf313d1b8f60b51eebf64dc3e79730c1c || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512256 DXSDK_Aug09.exe.sha2-512256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| colspan="2" | '''MD5''' || 66e5379ecf46b014688779621bcc677c || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.md5 DXSDK_Aug09.exe.md5]<br />
|- style="text-align:center;vertical-align:center;"<br />
| colspan="2" | '''{{nowrap|SHA-1}}''' || 5b9b969ed7b6cf5534bb7350e44c09b3573b0e71 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha1 DXSDK_Aug09.exe.sha1]<br />
|}<br />
CRC32 e9f5c61d ([https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sfv DXSDK_Aug09.exe.sfv])<br><br />
<br />
'''NOTE:''' Restart your computer after installing ''Microsoft DirectX SDK'', because otherwise the environment variable '''DXSDK_DIR''' won't be available yet. After restarting it re-run '''create-projects.bat'''<br />
<br />
'''Cant find d3dx9.h'''<br><br />
Add the '''$(DXSDK_DIR)Include;''' to the VC++ Directories in DirectX9GuiRenderer, GUI and Client Core projects.<br />
You can find the VC++ Directories list by selecting a project, then pressing the shortcut ALT + ENTER (without the +), then under the 'Configuration properties' you can find 'VC++ Directories', and in there you can find the 'Include Directories' field, click on it and add ''';$(DXSDK_DIR)Include;''' at the end of it. <br />
'''Note: You need to do the same thing in Release mode as well'''<br />
<br />
'''Cant find d3dx9.lib'''<br><br />
Do do same as in the error above, but instead of ''';$(DXSDK_DIR)Include;''' you must add ''';$(DXSDK_DIR)Lib/x86;''' to the '''Library directories''' field<br />
'''Note: You need to do the same thing in Release mode as well'''<br />
<br />
'''S1023 Error'''<br><br />
[https://support.microsoft.com/en-us/kb/2728613 "S1023" error when you install the DirectX SDK (June 2010)]<br style="clear:both"><br />
<br />
=== Git Client ===<br />
[[File:Git_logo.png|left|32px|link=https://git-scm.com/]]<br />
<br />
If you would like to contribute to MTA, you should install Git. This will allow you to collaborate with us by creating branches and pushing to your own fork. If you are not comfortable with the command line, we recommend you to download and install [https://desktop.github.com/ GitHub Desktop].<br />
<br />
If you only want to compile the source code and are not interested in contributing to MTA, you can download the source directly (see below).<br />
<br />
== Getting the latest source code ==<br />
<br />
To get the latest code, you will have to download the latest copy of our Git repository.<br><br />
We recommend cloning the repository in your Git client because you can pull any updates from there easily.<br />
<br />
* '''Repository:''' [https://github.com/multitheftauto/mtasa-blue multitheftauto/mtasa-blue]<br />
* '''.zip:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.zip master.zip]<br />
* '''.tar.gz:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.tar.gz master.tar.gz]<br />
<br />
== Compiling the code ==<br />
# Execute the script '''win-create-projects.bat'''<br />
# Open the solution file '''MTASA.sln''' in the '''Build''' directory<br />
# If you are asked to upgrade the project, click '''Cancel'''<br />
# Compile in Visual Studio with '''Debug''' configuration (may take some minutes)<br />
# Execute the script '''win-install-data.bat'''<br />
<br />
= Running the software =<br />
<br />
== Running the client ==<br />
<br />
You can start your client in the '''Bin''' directory. You might find there a ''Multi Theft Auto.exe'' and/or ''Multi Theft Auto_d.exe'' executable. The ''_d'' suffix indicates a debug build of the software.<br><br />
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions (read more in the section Debugging below).<br />
<br />
== Running the dedicated server ==<br />
<br />
If you already have run step 5 (''Install resources'') in ''Compiling the code'' to install resources then you can go to ''Starting the server''.<br />
<br />
=== Installing the latest resources ===<br />
If you want to run the Multi Theft Auto dedicated server, you will have to install the required resources. These are required because they implement the most basic functionality (e.g. spawning players) in order to play.<br />
<br />
Our official resources repository is [https://github.com/multitheftauto/mtasa-resources hosted on GitHub]. You can download the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped version]. Make sure that you have the latest resources package.<br />
<br />
=== Starting the server ===<br />
To run the server, open the ''MTA Server.exe'' executable in the '''Bin/server''' directory. The ''_d'' suffix indicates a debug build of the software.<br><br />
You can also run the debug build ''MTA Server_d.exe'' with the Visual Studio Debugger (as of writing, you can do that by right-clicking on the Server's Launcher project and selecting ''Start a local instance'' in the ''Debugger'' menu), but you can also attach to a running debug build MTA server (see more in the section Debugging below).<br />
<br />
== Debugging ==<br />
If you already compiled the code in the '''Debug''' configuration then continue reading, if not, then go up to ''Compiling the code'' and follow the steps for a ''Debug'' build.<br><br />
You can either launch MTA yourself and attach any debugger you want to use (also applies to the Visual Studio debugger) or you start a local debugging session in Visual Studio.<br><br />
[[File:Local_Windows_Debugger.PNG]]<br />
<br />
=== How to enable breakpoints ===<br />
If you choose to run MTA with Visual Studio then you should also attach the debugger to the executable '''gta_sa.exe''' (press ''CTRL + ALT + P'' in Visual Studio) - otherwise, your<br />
breakpoints will not work for anything besides the MTA Launcher project.<br><br />
[[File:Attach_to_Process.png|600px]]<br />
<br />
=== Extending timeout duration ===<br />
When you use breakpoints during debugging, you may get kicked by the server due to timeout, because the client is frozen. To prevent this, create the '''timeout.longtime''' file in your ''Bin/server/'' directory. <br />
The content of the file is the new timeout duration in seconds, so make sure you type a huge number in there. If you keep the file empty, the timeout will be set to 120 seconds.<br />
<br />
=== ReAttach for Visual Studio ===<br />
You can use [https://marketplace.visualstudio.com/items?itemName=ErlandR.ReAttach ReAttach] to re-attach the debugger to the '''gta_sa.exe''' executable whenever you start your local debugger in Visual Studio.<br><br />
[[File:ReAttach_to_GTASA.PNG]]<br />
<br />
= Getting involved =<br />
Please see our [[Coding guidelines]] for information on the coding practice.<br />
<br />
= Additional information =<br />
If you need more information, try our [http://bugs.mtasa.com/ bug tracker] or [irc://irc.multitheftauto.com IRC channel].<br />
<br />
= Errors =<br />
== CL38 error. [netc_d.dll not found] ==<br />
Solution: Delete '''Multi Theft Auto_d.exe''' and hit compile again.<br />
<br />
== After cloning the repository, it doesn't compile the project ==<br />
Solution: Execute '''win-create-projects.bat''' in main directory.<br />
<br />
== CL17 Load field. Please ensure that the latest data files have been installed correctly ==<br />
Solution: Execute '''win-install-data.bat''' in main directory.<br />
<br />
== ERROR: Loading network library (net_d.dll) failed! ==<br />
Solution: Execute '''win-install-data.bat''' in main directory.<br />
<br />
[[en:Compiling MTASA]]<br />
[[hu:Compiling MTASA]]<br />
[[pt-br:Compilando o MTASA]]<br />
[[ru:Compiling MTASA]]<br />
[[Category: Development]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Compiling_MTASA&diff=73026Compiling MTASA2021-11-15T16:00:10Z<p>Arran Fortuna: Added an error solution</p>
<hr />
<div>In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.<br />
<br />
Please read the instructions carefully and do not skip parts of it, if you have no experience.<br />
<br />
== Prerequisites ==<br />
<br />
Compiling the Multi Theft Auto client is only supported on Windows 10.<br />
<br />
Make sure you have the following software and SDKs installed:<br />
<br />
=== Visual Studio 2019 ===<br />
[[File:Visual_Studio_Community.PNG|right|150px|link=https://www.visualstudio.com/vs/]]<br />
# '''[https://visualstudio.microsoft.com/vs/ Download Microsoft Visual Studio 2019]''' - make sure you get the Community Edition, that one is free.<br />
# On the installation checklist, [[:File:VsFoundationClasses.png|make sure you tick these two items]]:<br />
## ''Desktop development with C++''<br />
## ''C++ MFC for latest v143 build tools (x86 & x64)''<br />
## ''MSVC v142 - VS 2019 C++ x64/x86 build tools''<br />
<br />
If you don't enable MFC, you will get the following error: <code>cannot open include file 'afxres.h'</code>.<br />
<br />
If you've made a mistake, you can run the ''Visual Studio Installer'' app to modify your current installation. There is no need to uninstall and reinstall.<br />
<br />
=== Microsoft DirectX SDK ===<br />
[[File:DirectX_SDK.jpg|right|150px|link=http://web.archive.org/web/20200804044856/https://www.microsoft.com/en-us/download/details.aspx?id=23549]]<br />
'''Download Microsoft DirectX SDK (August 2009) (DXSDK_Aug09.exe):'''<br />
* [https://archive.org/download/dxsdk_aug09/DXSDK_Aug09.exe Mirror 1]<br />
* [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe Mirror 2]<br />
<br />
{| class="wikitable" style="margin-top: 0px; width: 70%; word-break: break-all;"<br />
|+ File verification<br />
|- style="vertical-align:bottom;"<br />
! colspan="2" | Algorithm and variant<br />
! Hash<br />
! Hash file<br />
|- style="text-align:center;vertical-align:center;"<br />
| rowspan="6" | '''{{nowrap|SHA-3}}''' || ''SHA3-224'' || 8bfcdc03518d7edd34689534fd4d21291469ff2f2eb10437ad648c58 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-224 DXSDK_Aug09.exe.sha3-224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-256'' || 45bf3e08da3b3636ddb4f4a74243430f8d65759c074c0d79756ef810c4701c5a || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-256 DXSDK_Aug09.exe.sha3-256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-384'' || b358e529963d6f5fd7f8bd4b530fb18f6a2e6a442009a54e981b2f9967589ed48150af310f283640d56f9b60d41100c9 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-384 DXSDK_Aug09.exe.sha3-384]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-512'' || 43522187053af744250059ef69c0f3083cecd1157fe56daac16b9497ebc6fb5b525875144e42898367c55f757cffd3526f37074d544470578602a5a944a45a75 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-512 DXSDK_Aug09.exe.sha3-512]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHAKE128'' || 2a7c81bde9e867cbb5ef00b72ad8de66a3ee64c1d59f16465fa712479b6a84d28a02cc5ed08afa1d51e72011657453dbd4656cc9340d32e18179c39d03982dfc35c8f0c2a5c99e11dc74d0e23ed21b1e55f19c809a5a152bde39a2d46fcd12421f373f2d691ade1b57faf6c2ab7aded5a7d174f1f1c77127c0d6a1523b4775c569c5e1b4efa2da4bf2f708a96707a709e245a7f507382e69a81777919c90e95a091c0b699ce7f517 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-128000 DXSDK_Aug09.exe.sha3-128000]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHAKE256'' || 9c100dac5245a61774f3a2752bf9e941bdcd5654b18035155161c63b20936dfc9bd7334feb9a6fe9a99a65491161083b39ac3bd578e2cf4f90cba3c786e9924fa0611f65a725331b77b63e7c8b552e1637bc77531ba0f2c9cac72115b28e523929ede4e5b246a0755e8d5c4089d94bf16627fb08672cfffa523bba3d976489a0eec60d3c6a96ca2b || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-256000 DXSDK_Aug09.exe.sha3-256000]<br />
|- style="text-align:center;vertical-align:center;"<br />
| rowspan="6" | '''{{nowrap|SHA-2}}''' || ''SHA-224'' || a3a74b89cccfe314b79418d5598aac5e94800221e5d945c74f15c004 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-224 DXSDK_Aug09.exe.sha2-224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-256'' || 4ab1de69312f10f6b41310a5218d80c478bbd823bc0f86627318d690b128fb9f || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-256 DXSDK_Aug09.exe.sha2-256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-384'' || 254ed29c6ad2cadc6f013d2d51c0ac78a6bbe236a2c94ca99610eba8b2c1200d1a62c445ca9ee51bb09354875d5eca8a || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-384 DXSDK_Aug09.exe.sha2-384]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512'' || style="width: 60%;" | 736393c0dfa32221e229890f87eb330174d70dd2a02fa0cace303816d3e7a10a332a44129748de39665d1b339e627d6028c2080268f7afdd5240c447fec8ff0b || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512 DXSDK_Aug09.exe.sha2-512]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512/224'' || 7e23d9ba916000782a17e23abf48e25237f45590cfe767aed9d79f10 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512224 DXSDK_Aug09.exe.sha2-512224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512/256'' || 0c833a56046fe7e4213fcb1862c730acf313d1b8f60b51eebf64dc3e79730c1c || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512256 DXSDK_Aug09.exe.sha2-512256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| colspan="2" | '''MD5''' || 66e5379ecf46b014688779621bcc677c || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.md5 DXSDK_Aug09.exe.md5]<br />
|- style="text-align:center;vertical-align:center;"<br />
| colspan="2" | '''{{nowrap|SHA-1}}''' || 5b9b969ed7b6cf5534bb7350e44c09b3573b0e71 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha1 DXSDK_Aug09.exe.sha1]<br />
|}<br />
CRC32 e9f5c61d ([https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sfv DXSDK_Aug09.exe.sfv])<br><br />
<br />
'''NOTE:''' Restart your computer after installing ''Microsoft DirectX SDK'', because otherwise the environment variable '''DXSDK_DIR''' won't be available yet. After restarting it re-run '''create-projects.bat'''<br />
<br />
'''Cant find d3dx9.h'''<br><br />
Add the '''$(DXSDK_DIR)Include;''' to the VC++ Directories in DirectX9GuiRenderer, GUI and Client Core projects.<br />
You can find the VC++ Directories list by selecting a project, then pressing the shortcut ALT + ENTER (without the +), then under the 'Configuration properties' you can find 'VC++ Directories', and in there you can find the 'Include Directories' field, click on it and add ''';$(DXSDK_DIR)Include;''' at the end of it. <br />
'''Note: You need to do the same thing in Release mode as well'''<br />
<br />
'''Cant find d3dx9.lib'''<br><br />
Do do same as in the error above, but instead of ''';$(DXSDK_DIR)Include;''' you must add ''';$(DXSDK_DIR)Lib/x86;''' to the '''Library directories''' field<br />
'''Note: You need to do the same thing in Release mode as well'''<br />
<br />
'''S1023 Error'''<br><br />
[https://support.microsoft.com/en-us/kb/2728613 "S1023" error when you install the DirectX SDK (June 2010)]<br style="clear:both"><br />
<br />
=== Git Client ===<br />
[[File:Git_logo.png|left|32px|link=https://git-scm.com/]]<br />
<br />
If you would like to contribute to MTA, you should install Git. This will allow you to collaborate with us by creating branches and pushing to your own fork. If you are not comfortable with the command line, we recommend you to download and install [https://desktop.github.com/ GitHub Desktop].<br />
<br />
If you only want to compile the source code and are not interested in contributing to MTA, you can download the source directly (see below).<br />
<br />
== Getting the latest source code ==<br />
<br />
To get the latest code, you will have to download the latest copy of our Git repository.<br><br />
We recommend cloning the repository in your Git client because you can pull any updates from there easily.<br />
<br />
* '''Repository:''' [https://github.com/multitheftauto/mtasa-blue multitheftauto/mtasa-blue]<br />
* '''.zip:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.zip master.zip]<br />
* '''.tar.gz:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.tar.gz master.tar.gz]<br />
<br />
== Compiling the code ==<br />
# Execute the script '''win-create-projects.bat'''<br />
# Open the solution file '''MTASA.sln''' in the '''Build''' directory<br />
# If you are asked to upgrade the project, click '''Cancel'''<br />
# Compile in Visual Studio with '''Debug''' configuration (may take some minutes)<br />
# Execute the script '''win-install-data.bat'''<br />
<br />
= Running the software =<br />
<br />
== Running the client ==<br />
<br />
You can start your client in the '''Bin''' directory. You might find there a ''Multi Theft Auto.exe'' and/or ''Multi Theft Auto_d.exe'' executable. The ''_d'' suffix indicates a debug build of the software.<br><br />
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions (read more in the section Debugging below).<br />
<br />
== Running the dedicated server ==<br />
<br />
If you already have run step 5 (''Install resources'') in ''Compiling the code'' to install resources then you can go to ''Starting the server''.<br />
<br />
=== Installing the latest resources ===<br />
If you want to run the Multi Theft Auto dedicated server, you will have to install the required resources. These are required because they implement the most basic functionality (e.g. spawning players) in order to play.<br />
<br />
Our official resources repository is [https://github.com/multitheftauto/mtasa-resources hosted on GitHub]. You can download the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped version]. Make sure that you have the latest resources package.<br />
<br />
=== Starting the server ===<br />
To run the server, open the ''MTA Server.exe'' executable in the '''Bin/server''' directory. The ''_d'' suffix indicates a debug build of the software.<br><br />
You can also run the debug build ''MTA Server_d.exe'' with the Visual Studio Debugger (as of writing, you can do that by right-clicking on the Server's Launcher project and selecting ''Start a local instance'' in the ''Debugger'' menu), but you can also attach to a running debug build MTA server (see more in the section Debugging below).<br />
<br />
== Debugging ==<br />
If you already compiled the code in the '''Debug''' configuration then continue reading, if not, then go up to ''Compiling the code'' and follow the steps for a ''Debug'' build.<br><br />
You can either launch MTA yourself and attach any debugger you want to use (also applies to the Visual Studio debugger) or you start a local debugging session in Visual Studio.<br><br />
[[File:Local_Windows_Debugger.PNG]]<br />
<br />
=== How to enable breakpoints ===<br />
If you choose to run MTA with Visual Studio then you should also attach the debugger to the executable '''gta_sa.exe''' (press ''CTRL + ALT + P'' in Visual Studio) - otherwise, your<br />
breakpoints will not work for anything besides the MTA Launcher project.<br><br />
[[File:Attach_to_Process.png|600px]]<br />
<br />
=== Extending timeout duration ===<br />
When you use breakpoints during debugging, you may get kicked by the server due to timeout, because the client is frozen. To prevent this, create the '''timeout.longtime''' file in your ''Bin/server/'' directory. <br />
The content of the file is the new timeout duration in seconds, so make sure you type a huge number in there. If you keep the file empty, the timeout will be set to 120 seconds.<br />
<br />
=== ReAttach for Visual Studio ===<br />
You can use [https://marketplace.visualstudio.com/items?itemName=ErlandR.ReAttach ReAttach] to re-attach the debugger to the '''gta_sa.exe''' executable whenever you start your local debugger in Visual Studio.<br><br />
[[File:ReAttach_to_GTASA.PNG]]<br />
<br />
= Getting involved =<br />
Please see our [[Coding guidelines]] for information on the coding practice.<br />
<br />
= Additional information =<br />
If you need more information, try our [http://bugs.mtasa.com/ bug tracker] or [irc://irc.multitheftauto.com IRC channel].<br />
<br />
= Errors =<br />
== CL38 error. [netc_d.dll not found] ==<br />
Solution: Delete '''Multi Theft Auto_d.exe''' and hit compile again.<br />
<br />
== After cloning the repository, it doesn't compile the project ==<br />
Solution: Execute '''win-create-projects.bat''' in main directory.<br />
<br />
== CL17 Load field. Please ensure that the latest data files have been installed correctly ==<br />
Solution: Execute '''win-install-data.bat''' in main directory.<br />
<br />
== ERROR: Loading network library (net_d.dll) failed! ==<br />
Solution: Execute '''win-install-data.bat''' in main directory.<br />
<br />
[[en:Compiling MTASA]]<br />
[[hu:Compiling MTASA]]<br />
[[pt-br:Compilando o MTASA]]<br />
[[ru:Compiling MTASA]]<br />
[[Category: Development]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Compiling_MTASA&diff=73025Compiling MTASA2021-11-15T15:45:49Z<p>Arran Fortuna: Update based on changes to visual studio installer</p>
<hr />
<div>In order to successfully build Multi Theft Auto from source, it is necessary to perform a number of steps, which we will explain below.<br />
<br />
Please read the instructions carefully and do not skip parts of it, if you have no experience.<br />
<br />
== Prerequisites ==<br />
<br />
Compiling the Multi Theft Auto client is only supported on Windows 10.<br />
<br />
Make sure you have the following software and SDKs installed:<br />
<br />
=== Visual Studio 2019 ===<br />
[[File:Visual_Studio_Community.PNG|right|150px|link=https://www.visualstudio.com/vs/]]<br />
# '''[https://visualstudio.microsoft.com/vs/ Download Microsoft Visual Studio 2019]''' - make sure you get the Community Edition, that one is free.<br />
# On the installation checklist, [[:File:VsFoundationClasses.png|make sure you tick these two items]]:<br />
## ''Desktop development with C++''<br />
## ''C++ MFC for latest v143 build tools (x86 & x64)''<br />
## ''MSVC v142 - VS 2019 C++ x64/x86 build tools''<br />
<br />
If you don't enable MFC, you will get the following error: <code>cannot open include file 'afxres.h'</code>.<br />
<br />
If you've made a mistake, you can run the ''Visual Studio Installer'' app to modify your current installation. There is no need to uninstall and reinstall.<br />
<br />
=== Microsoft DirectX SDK ===<br />
[[File:DirectX_SDK.jpg|right|150px|link=http://web.archive.org/web/20200804044856/https://www.microsoft.com/en-us/download/details.aspx?id=23549]]<br />
'''Download Microsoft DirectX SDK (August 2009) (DXSDK_Aug09.exe):'''<br />
* [https://archive.org/download/dxsdk_aug09/DXSDK_Aug09.exe Mirror 1]<br />
* [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe Mirror 2]<br />
<br />
{| class="wikitable" style="margin-top: 0px; width: 70%; word-break: break-all;"<br />
|+ File verification<br />
|- style="vertical-align:bottom;"<br />
! colspan="2" | Algorithm and variant<br />
! Hash<br />
! Hash file<br />
|- style="text-align:center;vertical-align:center;"<br />
| rowspan="6" | '''{{nowrap|SHA-3}}''' || ''SHA3-224'' || 8bfcdc03518d7edd34689534fd4d21291469ff2f2eb10437ad648c58 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-224 DXSDK_Aug09.exe.sha3-224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-256'' || 45bf3e08da3b3636ddb4f4a74243430f8d65759c074c0d79756ef810c4701c5a || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-256 DXSDK_Aug09.exe.sha3-256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-384'' || b358e529963d6f5fd7f8bd4b530fb18f6a2e6a442009a54e981b2f9967589ed48150af310f283640d56f9b60d41100c9 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-384 DXSDK_Aug09.exe.sha3-384]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA3-512'' || 43522187053af744250059ef69c0f3083cecd1157fe56daac16b9497ebc6fb5b525875144e42898367c55f757cffd3526f37074d544470578602a5a944a45a75 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-512 DXSDK_Aug09.exe.sha3-512]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHAKE128'' || 2a7c81bde9e867cbb5ef00b72ad8de66a3ee64c1d59f16465fa712479b6a84d28a02cc5ed08afa1d51e72011657453dbd4656cc9340d32e18179c39d03982dfc35c8f0c2a5c99e11dc74d0e23ed21b1e55f19c809a5a152bde39a2d46fcd12421f373f2d691ade1b57faf6c2ab7aded5a7d174f1f1c77127c0d6a1523b4775c569c5e1b4efa2da4bf2f708a96707a709e245a7f507382e69a81777919c90e95a091c0b699ce7f517 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-128000 DXSDK_Aug09.exe.sha3-128000]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHAKE256'' || 9c100dac5245a61774f3a2752bf9e941bdcd5654b18035155161c63b20936dfc9bd7334feb9a6fe9a99a65491161083b39ac3bd578e2cf4f90cba3c786e9924fa0611f65a725331b77b63e7c8b552e1637bc77531ba0f2c9cac72115b28e523929ede4e5b246a0755e8d5c4089d94bf16627fb08672cfffa523bba3d976489a0eec60d3c6a96ca2b || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha3-256000 DXSDK_Aug09.exe.sha3-256000]<br />
|- style="text-align:center;vertical-align:center;"<br />
| rowspan="6" | '''{{nowrap|SHA-2}}''' || ''SHA-224'' || a3a74b89cccfe314b79418d5598aac5e94800221e5d945c74f15c004 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-224 DXSDK_Aug09.exe.sha2-224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-256'' || 4ab1de69312f10f6b41310a5218d80c478bbd823bc0f86627318d690b128fb9f || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-256 DXSDK_Aug09.exe.sha2-256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-384'' || 254ed29c6ad2cadc6f013d2d51c0ac78a6bbe236a2c94ca99610eba8b2c1200d1a62c445ca9ee51bb09354875d5eca8a || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-384 DXSDK_Aug09.exe.sha2-384]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512'' || style="width: 60%;" | 736393c0dfa32221e229890f87eb330174d70dd2a02fa0cace303816d3e7a10a332a44129748de39665d1b339e627d6028c2080268f7afdd5240c447fec8ff0b || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512 DXSDK_Aug09.exe.sha2-512]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512/224'' || 7e23d9ba916000782a17e23abf48e25237f45590cfe767aed9d79f10 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512224 DXSDK_Aug09.exe.sha2-512224]<br />
|- style="text-align:center;vertical-align:center;"<br />
| ''SHA-512/256'' || 0c833a56046fe7e4213fcb1862c730acf313d1b8f60b51eebf64dc3e79730c1c || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha2-512256 DXSDK_Aug09.exe.sha2-512256]<br />
|- style="text-align:center;vertical-align:center;"<br />
| colspan="2" | '''MD5''' || 66e5379ecf46b014688779621bcc677c || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.md5 DXSDK_Aug09.exe.md5]<br />
|- style="text-align:center;vertical-align:center;"<br />
| colspan="2" | '''{{nowrap|SHA-1}}''' || 5b9b969ed7b6cf5534bb7350e44c09b3573b0e71 || [https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sha1 DXSDK_Aug09.exe.sha1]<br />
|}<br />
CRC32 e9f5c61d ([https://assets.mtasa.com/DXSDK/DXSDK_Aug09.exe.sfv DXSDK_Aug09.exe.sfv])<br><br />
<br />
'''NOTE:''' Restart your computer after installing ''Microsoft DirectX SDK'', because otherwise the environment variable '''DXSDK_DIR''' won't be available yet. After restarting it re-run '''create-projects.bat'''<br />
<br />
'''Cant find d3dx9.h'''<br><br />
Add the '''$(DXSDK_DIR)Include;''' to the VC++ Directories in DirectX9GuiRenderer, GUI and Client Core projects.<br />
You can find the VC++ Directories list by selecting a project, then pressing the shortcut ALT + ENTER (without the +), then under the 'Configuration properties' you can find 'VC++ Directories', and in there you can find the 'Include Directories' field, click on it and add ''';$(DXSDK_DIR)Include;''' at the end of it. <br />
'''Note: You need to do the same thing in Release mode as well'''<br />
<br />
'''Cant find d3dx9.lib'''<br><br />
Do do same as in the error above, but instead of ''';$(DXSDK_DIR)Include;''' you must add ''';$(DXSDK_DIR)Lib/x86;''' to the '''Library directories''' field<br />
'''Note: You need to do the same thing in Release mode as well'''<br />
<br />
'''S1023 Error'''<br><br />
[https://support.microsoft.com/en-us/kb/2728613 "S1023" error when you install the DirectX SDK (June 2010)]<br style="clear:both"><br />
<br />
=== Git Client ===<br />
[[File:Git_logo.png|left|32px|link=https://git-scm.com/]]<br />
<br />
If you would like to contribute to MTA, you should install Git. This will allow you to collaborate with us by creating branches and pushing to your own fork. If you are not comfortable with the command line, we recommend you to download and install [https://desktop.github.com/ GitHub Desktop].<br />
<br />
If you only want to compile the source code and are not interested in contributing to MTA, you can download the source directly (see below).<br />
<br />
== Getting the latest source code ==<br />
<br />
To get the latest code, you will have to download the latest copy of our Git repository.<br><br />
We recommend cloning the repository in your Git client because you can pull any updates from there easily.<br />
<br />
* '''Repository:''' [https://github.com/multitheftauto/mtasa-blue multitheftauto/mtasa-blue]<br />
* '''.zip:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.zip master.zip]<br />
* '''.tar.gz:''' [https://github.com/multitheftauto/mtasa-blue/archive/master.tar.gz master.tar.gz]<br />
<br />
== Compiling the code ==<br />
# Execute the script '''win-create-projects.bat'''<br />
# Open the solution file '''MTASA.sln''' in the '''Build''' directory<br />
# If you are asked to upgrade the project, click '''Cancel'''<br />
# Compile in Visual Studio with '''Debug''' configuration (may take some minutes)<br />
# Execute the script '''win-install-data.bat'''<br />
<br />
= Running the software =<br />
<br />
== Running the client ==<br />
<br />
You can start your client in the '''Bin''' directory. You might find there a ''Multi Theft Auto.exe'' and/or ''Multi Theft Auto_d.exe'' executable. The ''_d'' suffix indicates a debug build of the software.<br><br />
Furthermore, you can also run your client inside the debugger from Visual Studio if you want to investigate a stack trace or set breakpoints in interesting code regions (read more in the section Debugging below).<br />
<br />
== Running the dedicated server ==<br />
<br />
If you already have run step 5 (''Install resources'') in ''Compiling the code'' to install resources then you can go to ''Starting the server''.<br />
<br />
=== Installing the latest resources ===<br />
If you want to run the Multi Theft Auto dedicated server, you will have to install the required resources. These are required because they implement the most basic functionality (e.g. spawning players) in order to play.<br />
<br />
Our official resources repository is [https://github.com/multitheftauto/mtasa-resources hosted on GitHub]. You can download the latest resources from there or [http://mirror.mtasa.com/mtasa/resources/ download a zipped version]. Make sure that you have the latest resources package.<br />
<br />
=== Starting the server ===<br />
To run the server, open the ''MTA Server.exe'' executable in the '''Bin/server''' directory. The ''_d'' suffix indicates a debug build of the software.<br><br />
You can also run the debug build ''MTA Server_d.exe'' with the Visual Studio Debugger (as of writing, you can do that by right-clicking on the Server's Launcher project and selecting ''Start a local instance'' in the ''Debugger'' menu), but you can also attach to a running debug build MTA server (see more in the section Debugging below).<br />
<br />
== Debugging ==<br />
If you already compiled the code in the '''Debug''' configuration then continue reading, if not, then go up to ''Compiling the code'' and follow the steps for a ''Debug'' build.<br><br />
You can either launch MTA yourself and attach any debugger you want to use (also applies to the Visual Studio debugger) or you start a local debugging session in Visual Studio.<br><br />
[[File:Local_Windows_Debugger.PNG]]<br />
<br />
=== How to enable breakpoints ===<br />
If you choose to run MTA with Visual Studio then you should also attach the debugger to the executable '''gta_sa.exe''' (press ''CTRL + ALT + P'' in Visual Studio) - otherwise, your<br />
breakpoints will not work for anything besides the MTA Launcher project.<br><br />
[[File:Attach_to_Process.png|600px]]<br />
<br />
=== Extending timeout duration ===<br />
When you use breakpoints during debugging, you may get kicked by the server due to timeout, because the client is frozen. To prevent this, create the '''timeout.longtime''' file in your ''Bin/server/'' directory. <br />
The content of the file is the new timeout duration in seconds, so make sure you type a huge number in there. If you keep the file empty, the timeout will be set to 120 seconds.<br />
<br />
=== ReAttach for Visual Studio ===<br />
You can use [https://marketplace.visualstudio.com/items?itemName=ErlandR.ReAttach ReAttach] to re-attach the debugger to the '''gta_sa.exe''' executable whenever you start your local debugger in Visual Studio.<br><br />
[[File:ReAttach_to_GTASA.PNG]]<br />
<br />
= Getting involved =<br />
Please see our [[Coding guidelines]] for information on the coding practice.<br />
<br />
= Additional information =<br />
If you need more information, try our [http://bugs.mtasa.com/ bug tracker] or [irc://irc.multitheftauto.com IRC channel].<br />
<br />
= Errors =<br />
== CL38 error. [netc_d.dll not found] ==<br />
Solution: Delete '''Multi Theft Auto_d.exe''' and hit compile again.<br />
<br />
== After cloning the repository, it doesn't compile the project ==<br />
Solution: Execute '''win-create-projects.bat''' in main directory.<br />
<br />
== CL17 Load field. Please ensure that the latest data files have been installed correctly ==<br />
Solution: Execute '''win-install-data.bat''' in main directory.<br />
<br />
[[en:Compiling MTASA]]<br />
[[hu:Compiling MTASA]]<br />
[[pt-br:Compilando o MTASA]]<br />
[[ru:Compiling MTASA]]<br />
[[Category: Development]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetPlayerPing&diff=72064GetPlayerPing2021-09-15T13:31:48Z<p>Arran Fortuna: Added clarification that VPN usage won't give incorrect ping (tested)</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function returns the ping of a specified [[player]]. The ping is the number of milliseconds that data takes to travel from the player's client to the server or vice versa. If a player is using a VPN their ping will still be returned correctly.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">int getPlayerPing ( player thePlayer )</syntaxhighlight><br />
{{OOP||[[player]]:getPing|ping|}}<br />
===Required Arguments===<br />
*'''thePlayer''': The [[player]] whose ping you want to determine.<br />
<br />
===Returns===<br />
Returns the ping as an [[int]], or ''false'' if the player is invalid.<br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This example checks every players ping every 5 seconds and if it's over 500 they get kicked.<br />
<syntaxhighlight lang="lua"><br />
function kickPing() -- Creates a function called kickPing<br />
for i, player in ipairs(getElementsByType("player")) do -- Loop every player<br />
if (getPlayerPing(player) >= 500) then -- If their ping is over 500<br />
kickPlayer(player, "Ping over 500!") -- Kick them<br />
end<br />
end<br />
end<br />
setTimer(kickPing, 5000, 0) -- Every 5 seconds, the kickPing function is called.<br />
</syntaxhighlight><br />
</section><br />
<br />
<section name="Client" class="client" show="true"><br />
This example checks the ping of every player entering the 'ping' command and warns him if it's over 100.<br />
<syntaxhighlight lang="lua"><br />
function checkPing()<br />
local ping = getPlayerPing(localPlayer) -- get the ping from the source element (the player who joined)<br />
if (ping > 100) then -- if it's higher than 100...<br />
outputChatBox("Your ping is pretty high! Please try to lower it if possible.") -- output a message to the player<br />
end<br />
end<br />
addCommandHandler("ping", checkPing)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Player functions}}<br />
<br />
[[ru:getPlayerPing]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=UnbindKey&diff=71505UnbindKey2021-07-29T17:42:47Z<p>Arran Fortuna: Added note about annoying bug that causes an hour lost debugging.</p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
Removes an existing key bind from the specified player.<br />
{{Note|unbindKey will only work on binds that were added by the same resource}}<br />
{{Note|unbindKey on the server may return ''true'' on failure}}<br />
{{Note|If you call unbindKey twice, it will break other scripts: [https://github.com/multitheftauto/mtasa-blue/issues/497 Issue 497]}}<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool unbindKey ( player thePlayer, string key, string keyState, string command )<br />
</syntaxhighlight> <br />
<syntaxhighlight lang="lua"><br />
bool unbindKey ( player thePlayer, string key [, string keyState, function handler ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''thePlayer:''' The player you wish to unbind the key of.<br />
*'''key:''' The key you wish to unbind. See [[Key names]] for a list of valid key names.<br />
*'''keyState:''' Can be either:<br />
**'''"up":''' If the bound key triggered a function when the key was released<br />
**'''"down":''' If the bound key triggered a function when the key was pressed<br />
**'''"both":''' If the bound key triggered a function when the key was pressed and released<br />
*'''command :''' (Syntax 1) The command you wish to unbind.<br />
<br />
===Optional Arguments===<br />
*'''keyState:''' is optional in Syntax 2.<br />
*'''handler:''' (Syntax 2) The function you wish to unbind.<br />
Note: If you do not specify ''handler'', any instances of ''key'' being bound will be unbound, whatever function they are bound to.<br />
<br />
===Returns===<br />
Returns '''true'' if the key was unbound, ''false'' if it was not previously bound or invalid arguments were passed to the function.<br />
</section><br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool unbindKey ( string key, string keyState, string command )<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
bool unbindKey ( string key [, string keyState, function handler ] )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''key:''' The key you wish to unbind. See [[Key names]] for a list of valid key names.<br />
*'''keyState:''' Can be either:<br />
**'''"up":''' If the bound key triggered a function when the key was released<br />
**'''"down":''' If the bound key triggered a function when the key was pressed<br />
**'''"both":''' If the bound key triggered a function when the key was pressed and released<br />
*'''command :''' (Syntax 1) The command you wish to unbind.<br />
<br />
===Optional Arguments===<br />
*'''keyState:''' is optional in Syntax 2.<br />
*'''handler:''' (Syntax 2) The function you wish to unbind.<br />
Note: If you do not specify ''handler'', any instances of ''key'' being bound will be unbound, whatever function they are bound to.<br />
<br />
===Returns===<br />
Returns '''true'' if the key was unbound, ''false'' if it was not previously bound or invalid arguments were passed to the function.<br />
</section><br />
<br />
==Example==<br />
<section name="Server" class="server" show="true"><br />
This function binds the player's ''F1'' key to a function ''goMoo'' which outputs a chat message when pressed. The key is then unbound so that it can effectively only be used once per life.<br />
<syntaxhighlight lang="lua"><br />
-- define the function that will be called when F1 is pressed<br />
function goMoo( player )<br />
outputChatBox ( getPlayerName ( player ) .. " says Mooooooo!" )<br />
unbindKey ( player, "F1", "down", goMoo ) -- this function will no longer be triggered by the player, after removing the bind.<br />
end<br />
<br />
function playerSpawn ( )<br />
bindKey ( source, "F1", "down", goMoo ) -- bind the player's F1 key to the 'goMoo' function defined above<br />
end<br />
addEventHandler ( "onPlayerSpawn", root, playerSpawn ) -- make the playerSpawn function be called when a player spawns<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Input functions}}<br />
<br />
[[pt-br:unbindKey]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnClientGUITabSwitched&diff=71355OnClientGUITabSwitched2021-06-16T17:42:09Z<p>Arran Fortuna: </p>
<hr />
<div>{{Client event}}<br />
__NOTOC__<br />
This event is triggered each time the user switch from GUI tab.<br />
<br />
When adding the event handler on the tab panel, propagate must be true.<br />
<br />
==Parameters== <br />
<syntaxhighlight lang="lua"><br />
element theElement<br />
</syntaxhighlight> <br />
* '''theElement''': the [[Element/GUI/Tab|tab]] which was selected.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the tab.<br />
<br />
==Example== <br />
This example creates a window with a tabpanel with two tabs. Every time a user changes tabpage a notification will be shown.<br />
<br />
First we'll create the window. Then add a tabpanel and couple tabs with some labels in them. Qoute: [[GuiCreateWindow#Example]]<br />
<syntaxhighlight lang="lua"><br />
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create a window which has "Information" in the title bar.<br />
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- create a tab panel which fills the whole window<br />
local tabMap = guiCreateTab( "Map Information", tabPanel ) -- create a tab named "Map Information" on 'tabPanel'<br />
local tabHelp = guiCreateTab( "Help", tabPanel ) -- create another tab named "Help" on 'tabPanel'<br />
<br />
-- adds a label (text) to each tab<br />
guiCreateLabel( 0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap )<br />
guiCreateLabel( 0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp )<br />
</syntaxhighlight><br />
<br />
Now let's add the event handler.<br />
<syntaxhighlight lang="lua"><br />
<br />
function OnChange(selectedTab)<br />
-- If there is a selected tab.<br />
if selectedTab ~= nil then <br />
outputChatBox( "You've changed your active tab." )<br />
end <br />
end<br />
<br />
addEventHandler("onClientGUITabSwitched", root, OnChange)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{GUI_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=CreateColPolygon&diff=68424CreateColPolygon2021-01-27T09:53:31Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
{{Note|For this function to work correctly, get/set your bound points in an anti-clockwise fashion.}}<br />
{{Note|Even though this is a 2D colshape, [[isElementWithinColShape]] returns false if an element is in the area but below 0 Z height.}}<br />
This function creates a collision polygon. See [http://en.wikipedia.org/wiki/Polygon Wikipedia] for a definition of a polygon. The first set of X Y of this shape is not part of the colshape bounds, so can set anywhere in the game world, however for performance, place it as close to the centre of the polygon as you can. It should be noted this shape is '''2D'''. There should be at least 3 bound points set. <br />
{{VisualizeColshape}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
colshape createColPolygon ( float fCenterX, float fCenterY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, ... )<br />
</syntaxhighlight> <br />
{{OOP| |ColShape.Polygon||}}<br />
===Required Arguments=== <br />
*'''fCenterX:''' The X position of the collision polygon's position - the position that will be returned from [[getElementPosition]].<br />
*'''fCenterY:''' The Y position of the collision polygon's position - the position that will be returned from [[getElementPosition]].<br />
*'''fX1:''' The 1st X position of the collision polygon's bound point<br />
*'''fY1:''' The 1st Y position of the collision polygon's bound point<br />
*'''fX2:''' The 2nd X position of the collision polygon's bound point<br />
*'''fY2:''' The 2nd Y position of the collision polygon's bound point<br />
*'''fX3:''' The 3rd X position of the collision polygon's bound point<br />
*'''fY3:''' The 3rd Y position of the collision polygon's bound point<br />
*'''... :''' From the 3rd position you can have as many points as you require to create the colshape.<br />
<br />
===Returns===<br />
Returns a [[colshape]] element if successful, ''false'' if invalid arguments were passed to the function.<br />
<br />
==Example== <br />
<section name="Server" class="server" show="true"><br />
This example displays a chat message when any element hits the colshape and allows the colshape to be created using a console function ''set_zone''.<br />
<syntaxhighlight lang="lua"><br />
local theZone = false<br />
<br />
function shapeHit( element )<br />
local descriptor = "undefined"<br />
<br />
if getElementType( element ) == "player" then<br />
-- Use the player's name<br />
descriptor = getPlayerName( element )<br />
elseif getElementType( element ) == "vehicle" then<br />
-- Use the vehicle's model name<br />
descriptor = getVehicleName( element ) or descriptor<br />
end<br />
<br />
-- Output a message in the chat box for everyone on the server<br />
outputChatBox( descriptor .. " is in the zone!" )<br />
end<br />
<br />
function createZoneCommandHandler( playerSource, commandName, fX, fY, fX1, fY1, fX2, fY2, fX3, fY3, ... )<br />
-- Verify the player has given us the minimum amount of bound points<br />
if not ( fY and fX and fX1 and fY1 and fX2 and fX3 and fY3 ) then<br />
return outputChatBox( "Syntax: set_zone <X> <Y> <X1> <Y1> <X2> <Y2> <X3> <Y3> [<Xn> <Yn> ...]", playerSource, 255, 100, 100 )<br />
end<br />
<br />
-- Create the collision shape with the numbers from the arguments<br />
local tempCol = createColPolygon( fX, fY, fX1, fY1, fX2, fY2, fX3, fY3, ... )<br />
<br />
if not tempCol then<br />
return outputChatBox( "Error: Couldn't create collision polygon", playerSource, 255, 100, 100 )<br />
end<br />
<br />
-- Destroy the previous collision polygon shape in case we already have one<br />
if isElement( theZone ) then<br />
destroyElement( theZone )<br />
end<br />
<br />
-- Use a variable out-of-scope to keep track of the most recently created collision shape element<br />
theZone = tempCol<br />
<br />
-- Attach an event handler to the element to get notified whenever an element hits our collision shape<br />
addEventHandler( "onColShapeHit", tempCol, shapeHit, false )<br />
<br />
outputChatBox( "Success: Collision shape has been created!", playerSource, 100, 255, 100 )<br />
end<br />
addCommandHandler( "set_zone", createZoneCommandHandler )<br />
</syntaxhighlight><br />
</section><br />
<section name="Server" class="server" show="hide"><br />
This example displays a chat message when any element hits the colshape and allows the colshape to be created using a console function ''set_wall''.<br />
<syntaxhighlight lang="lua"><br />
local theWall = false<br />
<br />
function shapeHit( element )<br />
local descriptor = "undefined"<br />
<br />
if getElementType( element ) == "player" then<br />
-- Use the player's name<br />
descriptor = getPlayerName( element )<br />
elseif getElementType( element ) == "vehicle" then<br />
-- Use the vehicle's model name<br />
descriptor = getVehicleName( element ) or descriptor<br />
end<br />
<br />
-- Output a message in the chat box for everyone on the server<br />
outputChatBox( descriptor .. " is in the zone!" )<br />
end<br />
<br />
function createWallCommandHandler( playerSource, commandName, fromX, fromY, toX, toY )<br />
-- Verify the player has given us the minimum amount of bound points<br />
if not ( fromX and fromY and toX and toY ) then<br />
return outputChatBox( "Syntax: set_wall <fromX> <fromY> <toX> <toY>", playerSource, 255, 100, 100 )<br />
end<br />
<br />
-- Calculate the 90° angle for the line between the two coordinates from the arguments<br />
local radian90DegreeAngle = math.atan2(toY - fromY, toX - fromX) + math.pi / 2<br />
<br />
-- Depth/width of the wall<br />
local depth = 1<br />
<br />
-- Pre-calculate the cosinus/sinus distances<br />
local cosinusDepth = math.cos(radian90DegreeAngle) * depth / 2<br />
local sinusDepth = math.sin(radian90DegreeAngle) * depth / 2<br />
<br />
-- Calculate the points in the game world<br />
local x1, y1 = fromX - cosinusDepth, fromY - sinusDepth<br />
local x2, y2 = toX - cosinusDepth, toY - sinusDepth<br />
local x3, y3 = toX + cosinusDepth, toY + sinusDepth<br />
local x4, y4 = fromX + cosinusDepth, fromY + sinusDepth<br />
<br />
-- Create the collision shape with the calculated numbers<br />
local tempCol = createColPolygon( fromX + (toX - fromX) / 2, fromY + (toY - fromY) / 2, x1, y1, x2, y2, x3, y3, x4, y4 )<br />
<br />
if not tempCol then<br />
return outputChatBox( "Error: Couldn't create collision polygon", playerSource, 255, 100, 100 )<br />
end<br />
<br />
-- Destroy the previous collision polygon shape in case we already have one<br />
if isElement( theWall ) then<br />
destroyElement( theWall )<br />
end<br />
<br />
-- Use a variable out-of-scope to keep track of the most recently created collision shape element<br />
theWall = tempCol<br />
<br />
-- Attach an event handler to the element to get notified whenever an element hits our collision shape<br />
addEventHandler( "onColShapeHit", tempCol, shapeHit, false )<br />
<br />
outputChatBox( "Success: Collision shape has been created!", playerSource, 100, 255, 100 )<br />
end<br />
addCommandHandler( "set_wall", createWallCommandHandler )<br />
</syntaxhighlight><br />
</section><br />
<br />
==Issues==<br />
{{Issues|<br />
{{Issue|9742|[Fixed in 1.5.5-3.12343] Passing this function [[Vector2|Vector2s]] are not fully supported}}<br />
}}<br />
<br />
==See Also==<br />
{{Collision shape functions}}<br />
<br />
[[hu:createColPolygon]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=PlaySoundFrontEnd&diff=68210PlaySoundFrontEnd2021-01-08T20:10:31Z<p>Arran Fortuna: </p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function plays a frontend sound for the specified player.<br />
{{Note|These sounds can be disabled with [[setWorldSoundEnabled]] so if these sounds stop working you should check if you're disabling the sounds.}}<br />
{{Note|These sounds don't work when [[fadeCamera]] has been used to make the screen black.}}<br />
<br />
==Syntax== <br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua"><br />
bool playSoundFrontEnd ( player thePlayer, int sound ) <br />
</syntaxhighlight><br />
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[player]]:playSoundFrontEnd}}}}<br />
<br />
===Required Arguments=== <br />
*'''thePlayer:''' the [[player]] you want the sound to play for.<br />
*'''sound:''' a whole [[int]] specifying the sound id to play. Valid values are:<br />
{{Sounds}}<br />
</section><br />
<section name="Client" class="client" show="false"><br />
<syntaxhighlight lang="lua"><br />
bool playSoundFrontEnd ( int sound ) <br />
</syntaxhighlight><br />
{{New feature/item|3.0141|1.4.0|6987|{{OOP||[[Sound]].playFrontEnd}}}}<br />
<br />
===Required Arguments=== <br />
*'''sound:''' a whole [[int]] specifying the sound id to play. Valid values are:<br />
{{Sounds}}<br />
</section><br />
<br />
===Returns===<br />
Returns ''true'' if the sound was successfully played, ''false'' otherwise.<br />
<br />
==Example==<br />
<section name="server" class="server" show="true"><br />
This example plays a sound when a player spawns.<br />
<syntaxhighlight lang="lua"><br />
function onPlayerSpawn ( theSpawnpoint, theTeam )<br />
playSoundFrontEnd ( source, 16 )<br />
end<br />
addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn )<br />
</syntaxhighlight><br />
</section><br />
<section name="client" class="client" show="true"><br />
This example plays a sound when the player types the command '/sound'.<br />
<syntaxhighlight lang="lua"><br />
function onSoundEvent ( )<br />
playSoundFrontEnd ( 16 )<br />
end<br />
addCommandHandler("sound", onSoundEvent)<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Client_audio_functions}}<br />
<br />
[[hu:playSoundFrontEnd]]<br />
[[de:playSoundFrontEnd]]<br />
[[ar:playSoundFrontEnd]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=FileExists&diff=68077FileExists2020-12-20T19:05:53Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This functions checks whether a specified file exists inside a resource.<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool fileExists ( string filePath )<br />
</syntaxhighlight><br />
{{OOP|This function is a static function underneath the File class.|[[File]].exists}}<br />
===Required Arguments===<br />
*'''filePath:''' The [[filepath]] of the file, whose existence is going to be checked, in the following format: '''":resourceName/path"'''. 'resourceName' is the name of the resource the file is checked to be in, and 'path' is the path from the root directory of the resource to the file.<br />
:For example, if you want to check whether a file named 'myfile.txt' exists in the resource 'mapcreator', it can be done from another resource this way: ''fileExists(":mapcreator/myfile.txt")''.<br />
:If the file, whose existence is going to be checked, is in the current resource, only the file path is necessary, e.g. ''fileExists("myfile.txt")''. Note that you must use forward slashes '/' for the folders, backslashes '\' will return false.<br />
<br />
===Returns===<br />
Returns ''true'' if the file exists, ''false'' otherwise.<br />
<br />
==Example==<br />
This example checks if a file exists in a resource directory<br />
<syntaxhighlight lang="lua"><br />
function checkExistingFile(player,cmd,filename,resourcename)<br />
if not filename then -- if the player didn't include a filename<br />
outputChatBox("ERROR: Syntax '/checkfile filename resourcename(optional)'.",player) -- display error<br />
return false -- stop function<br />
end<br />
if not resourcename then -- if the player didn't specify the resource he wants to check, use current resource<br />
resourcename = getResourceName(resource) --every resource has a predefined global variable called resource that contains the resource pointer for that resource, in other words, the value that getThisResource() function returns.<br />
else<br />
if not getResourceFromName(resourcename) then -- if a resource with that name doesn't exist, output error and stop function<br />
outputChatBox("ERROR: Resource "..resourcename.." doesn't exist.",player) -- output error message<br />
return false -- stop the function here<br />
end<br />
end<br />
-- as it hasn't stopped anywhere, we have both correct resourcename and filename<br />
local exists = fileExists((":%s/%s"):format(resourcename,filename)) -- using shorter format of string.format, see StringLibraryTutorial in lua wiki for that<br />
if exists then<br />
outputChatBox(("The file %q in resource %q exists"):format(filename,resourcename))<br />
else<br />
outputChatBox(("The file %q in resource %q doesn't exist"):format(filename,resourcename))<br />
end<br />
end<br />
addCommandHandler("exists",checkExistingFile)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{File functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnClientPlayerVehicleEnter&diff=67081OnClientPlayerVehicleEnter2020-07-21T20:08:50Z<p>Arran Fortuna: Fixed example</p>
<hr />
<div>{{Client event}}<br />
__NOTOC__<br />
This event is fired when a player or ped enters a vehicle.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
vehicle theVehicle, int seat<br />
</syntaxhighlight><br />
*'''theVehicle:''' the [[vehicle]] that the player entered<br />
*'''seat:''' the seat that the player now is on. Driver's seat = 0, higher numbers are passenger seats.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] or [[ped]] that entered the vehicle.<br />
<br />
==Example==<br />
This example will tell you the name of the vehicle you enter.<br />
<syntaxhighlight lang="lua"><br />
function checkVehicles(theVehicle)<br />
outputChatBox("You entered a "..getVehicleName(theVehicle).."!")<br />
end<br />
addEventHandler("onClientPlayerVehicleEnter", localPlayer, checkVehicles)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===Client player events===<br />
{{Client_player_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=SetGravity&diff=66416SetGravity2020-05-05T20:18:40Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Server client function}}<br />
This function sets the server's gravity level.<br />
{{Note|<br />
*This does not effect peds/players; to set ped/player gravity use [[setPedGravity]].<br />
*Setting the gravity level to different values on clients can cause animation bugs (players floating across ground because players see different fall animation.)}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool setGravity ( float level )</syntaxhighlight><br />
<br />
===Required Arguments===<br />
*'''level''': The level of gravity (default is '''0.008''').<br />
<br />
===Returns===<br />
Returns ''true'' if gravity was changed, ''false'' otherwise.<br />
<br />
==Example==<br />
<syntaxhighlight lang="lua"><br />
function grav ( sourcePlayer, command, level )<br />
local level = tonumber(level)<br />
if (not level) then return end<br />
setGravity ( tonumber(level) )<br />
end<br />
addCommandHandler ( "setgravity", grav )<br />
</syntaxhighlight><br />
<br />
==Issues==<br />
[https://github.com/multitheftauto/mtasa-blue/issues/1428 setGravity overrides setPedGravity]<br />
<br />
==See Also==<br />
{{World functions}}<br />
<br />
[[ru:setGravity]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=64838GetLocalization2019-12-28T14:02:41Z<p>Arran Fortuna: Added new language</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all (probably all) the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar"] = "Arabic",<br />
["bg"] = "Bulgarian",<br />
["cs"] = "Czech",<br />
["da"] = "Danish",<br />
["de"] = "German",<br />
["en_US"] = "English",<br />
["el"] = "Greek",<br />
["es"] = "Spanish",<br />
["et"] = "Estonian",<br />
["fr"] = "French",<br />
["hr"] = "Croatian",<br />
["hu"] = "Hungarian",<br />
["id"] = "Indonesian",<br />
["it"] = "Italian",<br />
["ja"] = "Japanese",<br />
["lt"] = "Lithuanian",<br />
["lv"] = "Latvian",<br />
["mk"] = "Macedonian",<br />
["nb"] = "Norwegian",<br />
["nl"] = "Dutch",<br />
["pt_BR"] = "Brazilian",<br />
["pl"] = "Polish",<br />
["ru"] = "Russian",<br />
["ro"] = "Romanian",<br />
["sl"] = "Slovenian",<br />
["sv"] = "Swedish",<br />
["sk"] = "Slovak",<br />
["tr"] = "Turkish",<br />
["uk"] = "Ukrainian",<br />
["vi"] = "Vietnamese",<br />
["zh_CN"] = "Chinese",<br />
["zh_TW"] = "Taiwanese",<br />
<br />
}<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=FromJSON&diff=64438FromJSON2019-09-29T09:33:24Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__ <br />
{{Server client function}}<br />
This function parses a [[JSON]] formatted string into variables. You can use [[toJSON]] to encode variables into a JSON string that can be read by this function.<br />
<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
var fromJSON ( string json )<br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''json:''' A JSON formatted string<br />
<br />
===Returns===<br />
Returns variables read from the JSON string.<br />
<br />
'''Note:''' Indices of a JSON object such as "1": "cat" are being returned as [[string]], not as [[int]]eger.<br />
<br />
==Example== <br />
This makes data equal: ''{ ["1"] = "cat", ["2"] = "mouse", ["3"] = 5, ["4"] = null, ["cat"] = 5, ["mouse"] =1 }''<br />
<syntaxhighlight lang="lua"><br />
local data = fromJSON ( '[ { "1": "cat", "2": "mouse", "3": 5, "4": null, "cat":5, "mouse":1 } ]' )<br />
</syntaxhighlight><br />
<br />
==Example 2==<br />
<syntaxhighlight lang="lua"><br />
local name, weapon, ammo = fromJSON("[\"Desert Eagle\", 24, 147]")<br />
</syntaxhighlight><br />
<br />
==Requirements==<br />
{{Requirements|1.0|1.1.1-9.03316|}}<br />
<br />
==See Also==<br />
{{Server_functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=DxDrawImageOnElement&diff=64356DxDrawImageOnElement2019-09-20T16:54:17Z<p>Arran Fortuna: At least indent properly.</p>
<hr />
<div>{{Useful Function}}<lowercasetitle/><br />
__NOTOC__<br />
This useful client function draws an image on any element you choose.<br />
{{Note|You have to use [[onClientRender]] or [[onClientPreRender]] events with this function.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">boolean dxDrawImageOnElement(element TheElement, element Image [, int distance = 20, int height = 1, int width = 1, int R = 255, int G = 255, int B = 255, int alpha = 255, bool checkBuildings = true, bool checkVehicles = false, bool checkPeds = false, bool checkDummies = true, bool seeThroughStuff = true, bool ignoreSomeObjectsForCamera = false, element ignoredElement = nil ] ) </syntaxhighlight><br />
<br />
[[File:DxDrawImageOnElement.png|thumb|Example of how it should looks like.|284x230px]]<br />
<br />
==Required arguments==<br />
* ''TheElement'': The element you want to draw the image on it.<br />
* ''Image'': The image you want. Use [[dxCreateTexture]] to create it.<br />
<br />
==Optional arguments==<br />
* ''height'': The height of the text, it's 1 by default.<br />
* ''distance'': The distance you will be able to view the image from, it's 20 by default.<br />
* ''height'': The height of the image, it's 1 by default.<br />
* ''width'': The width of the image, it's 1 by default.<br />
* ''R'': The Red color code (0-255), it's 255 by default.<br />
* ''G'': The Green color code (0-255), it's 255 by default.<br />
* ''B'': The Blue color code (0-255), it's 255 by default.<br />
* ''alpha'': The alpha of the image, it's 255 by default.<br />
<br />
*'''checkBuildings:''' Allow the line of sight to be blocked by GTA's internally placed buildings, i.e. the world map.<br />
*'''checkVehicles:''' Allow the line of sight to be blocked by [[Vehicle|vehicles]].<br />
*'''checkPeds:''' Allow the line of sight to be blocked by peds, i.e. [[Player|players]].<br />
*'''checkObjects:''' Allow the line of sight to be blocked by [[Object|objects]].<br />
*'''checkDummies:''' Allow the line of sight to be blocked by GTA's internal dummies. These are not used in the current MTA version so this argument can be set to ''false''.<br />
*'''seeThroughStuff:''' Allow the line of sight to be blocked by translucent game objects, e.g. glass.<br />
*'''ignoreSomeObjectsForCamera:''' Allow the line of sight to be blocked by certain objects.<br />
*'''ignoredElement:''' Allow the line of sight to pass through a certain specified element.<br />
<br />
==Returns==<br />
Returns ''true'' if successful, ''false'' otherwise.<br />
<br />
==Function source==<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
function dxDrawImageOnElement(TheElement,Image,distance,height,width,R,G,B,alpha)<br />
local x, y, z = getElementPosition(TheElement)<br />
local x2, y2, z2 = getElementPosition(localPlayer)<br />
local distance = distance or 20<br />
local height = height or 1<br />
local width = width or 1<br />
local checkBuildings = checkBuildings or true<br />
local checkVehicles = checkVehicles or false<br />
local checkPeds = checkPeds or false<br />
local checkObjects = checkObjects or true<br />
local checkDummies = checkDummies or true<br />
local seeThroughStuff = seeThroughStuff or false<br />
local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false<br />
local ignoredElement = ignoredElement or nil<br />
if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then<br />
local sx, sy = getScreenFromWorldPosition(x, y, z+height)<br />
if(sx) and (sy) then<br />
local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)<br />
if(distanceBetweenPoints < distance) then<br />
dxDrawMaterialLine3D(x, y, z+1+height-(distanceBetweenPoints/distance), x, y, z+height, Image, width-(distanceBetweenPoints/distance), tocolor(R or 255, G or 255, B or 255, alpha or 255))<br />
end<br />
end<br />
end<br />
end<br />
</syntaxhighlight><br />
</section><br />
*Original author: ''Al Obaidi Hassan''.<br />
*Skype: ''hassan.saad2000''<br />
<br />
==Example #1==<br />
This example creates an image on a random ped in the Grove street.<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
randomPed = createPed(285,2506.83423,-1684.89941,13.55648)<br />
tag = dxCreateTexture("crown.png")<br />
<br />
addEventHandler("onClientPreRender", root,<br />
function()<br />
dxDrawImageOnElement(randomPed,tag)<br />
end)<br />
</syntaxhighlight><br />
</section><br />
<br />
==Example #2==<br />
This example creates an image on all the vehicles in the game.<br />
<section name="Client" class="client" show="true"><br />
<syntaxhighlight lang="lua"><br />
local tag = dxCreateTexture("bike.png")<br />
<br />
addEventHandler("onClientPreRender", root,<br />
function()<br />
for k,v in ipairs(getElementsByType("vehicle")) do<br />
dxDrawImageOnElement(v,tag)<br />
end<br />
end) <br />
</syntaxhighlight><br />
</section><br />
<br />
==See also==<br />
{{Useful Functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=User:Arran_Fortuna&diff=64241User:Arran Fortuna2019-09-10T22:19:47Z<p>Arran Fortuna: </p>
<hr />
<div>==Contributions to MTA: SA Source Code==<br />
The contribution I am most proud of is [[givePedWeapon]] client side as it allowed us to hack fix server side peds and have client side missions.<br />
<br />
Some of the newer commits: https://github.com/multitheftauto/mtasa-blue/commits?author=ArranTuna<br />
<br />
But my biggest contributions to the source code is all the testing, bug reporting and mantis organising that allowed the wonderful and gifted MTA developers to have more time doing what they do best.<br />
<br />
==Contributions to The Wiki==<br />
Documented 74 of the functions and events and many other things like a lot of the Changes in X (which I started with [[Changes_in_1.1]]) over these past 8 great years.<br />
<br />
==Contributions to MTA: SA Resources==<br />
[fastrope] Fixed being able to fall from super high and not get hurt.<br />
<br />
[parachute] Reduced bandwidth usage by having a list of animations and sending a<br />
number to setElementData instead of a string.<br />
<br />
Fixed #7278 (Freeroam animations hotkeys)<br />
<br />
Fixed #6879 (Freecam (editor) binds hard keys w,s,a,d causes difficulties on other keyboards than qwerty (azerty, bepo, dvorak etc.))<br />
<br />
Fixed not spawning with spawnmanager if string is passed to spawn player instead of a team, like in CTF. <br />
<br />
Slight optimization in the parachute resource server side<br />
<br />
Fixed a security vulnerability in admin panel<br />
<br />
Fixed #7815 (Votekick abuse: 120 sec votekick period can be bypassed by nickname change)<br />
<br />
Fixed fall out spectating<br />
<br />
Fixed server side fallout exported functions<br />
<br />
Made it really hard to instant reload exploit<br />
<br />
Fixed #7674 (Temporary mute becomes permanent when admin is restarted)<br />
<br />
Added an option to acpanel which will switch a players model rather than having to totally block them<br />
<br />
Fixed #7425 (Make objects, created by editor, have LOD model preinstalled)<br />
<br />
Fixed #4767 (Race EDF - Can't enter pickup properties GUI)<br />
<br />
Fixed #7311 (Map editor doesn't load object properly but race gamemode does.)<br />
<br />
Fixed #7509 (Weapon model changes to 1337 after saving/loading some times)<br />
<br />
Created the ingame performance browser<br />
<br />
Fixed #7405 (Some settings aren't reset when you start a new map after working in another)<br />
<br />
Fixed #7394 (Votemanager can't start votekick, votekill or voteban, if the player, who we want to vote, name contains 1 character.)<br />
<br />
Reduced the size of map files by rounding position attributes to 5 decimal and rotation to 3 as you won't even see a change in position or rotation even on a large object.<br />
<br />
Cleansed admin of the redundant guiSetInputEnabled replacing it with guiSetInputMode("no_binds_when_editing")<br />
<br />
Fixed #7338: (Selecting players no longer works)<br />
<br />
Fixed #7308 (Locked Time isn't set correctly)<br />
<br />
Fixed #7351 (Make camera face haystack after player dies for walking away)<br />
<br />
Fixed #7353 (setpos command parameter check)<br />
<br />
Fixed optional arguments of setFreecamEnabled()<br />
<br />
Fixed #7317 (Freecam locks causing to make game play impossible) and fixed debugs too.<br />
<br />
Fixed #7300 (Copying a scaled object resets the object scale back to 1)<br />
<br />
Fixed #5436 (Stealth Gamemode Contains Debug After Team Choice)<br />
<br />
Fixed #6706 (Fixed Freecam) and some other little fixes.<br />
<br />
Fixed #7275 (Gamemode Settings are not in Test When no Save Before Test)<br />
<br />
Fixed debug spam after using properties pull out delete button.<br />
<br />
Fixed #7277 (Add object collisions option)<br />
<br />
Fixed #6704 (Add a scale option for the map editor)<br />
<br />
Fixed #6612 (cannot save data "Invert Mouse Look")<br />
<br />
Fixed #5791 (Placing peds)<br />
<br />
Fixed #7091 (Map settings change to default after map testing.)<br />
<br />
Fixed #6723 (RGB Color Picker For Vehicles)<br />
<br />
Fixed server settings tab in options not showing up when using Map Editor from main menu.<br />
<br />
Fixed game mode stopper by moving it to a resource that has stopResource access.<br />
<br />
Fixed a reload exploit where you could jump and then reload for an instant reload.<br />
<br />
Fixed #6775 (Freeroam: sorting bug)<br />
<br />
Fixed #6522 (No "Set Nick" ACL right and permission check in "admin" resource)<br />
<br />
Admin: Added nick change anti spam option.<br />
<br />
Freeroam: Added an option to prevent chat spam and an option to prevent repeat messages.<br />
<br />
Editor: Fixed saving of changed IDs<br />
<br />
Editor: Fixed the annoying bug when auto save makes the save-as window appear but does not stop moving the mouse look around the world violently.<br />
<br />
Fixed #6266 (CTV: Can capture the vehicle in any teams base)<br />
<br />
Fixed #6292 (Progress indicator for loading procedures)<br />
<br />
Fixed #4059 (Make test mode only start for the player who pressed F5 or the test<br />
button)<br />
<br />
Fixed #4381 (Can't change the position of an object any longer.)<br />
<br />
Fixed #6269 (The resource "maplimits" has a bug that eats up more and more resources.)<br />
<br />
Fixed #4793 (You cannot select trains in the map editor)<br />
<br />
Added RGB vehicle colors and headlight colors to freeroam with thanks to ryden for making the color picker and Ransom's assistance in making it work.<br />
<br />
Upgrading from deprecated functions (setVehicleFrozen and setPedFrozen)<br />
<br />
Fixed #6090 (Cloned objects don't keep the doublesided attribute)<br />
<br />
Removing redundant localPlayer defines (now predefined in MTA)<br />
<br />
Changed encoding of all files to UTF-8<br />
<br />
Added special skins to freeroam.<br />
<br />
Fixed #5590 (map settings ignored in test mode)<br />
<br />
Added trailers to map editor.<br />
<br />
Fixed #6255 (Saving, loading, problems)<br />
<br />
Fixed #6211: [Freeroam] /cv is missing interior and dimension update.<br />
<br />
Fixed #4855 (briefcaserace edf: player spawn point looks weird)<br />
<br />
Fixed #6073 (Create vehicle error)<br />
<br />
Fixed #5643 (editor: I can't open any map)<br />
<br />
Fixed #6043 (Lag during startup)<br />
<br />
resourcemanager: Added #6025 (Normal date in resource manager)<br />
<br />
Fixed (#6009: Editor Cannot Delete Objects)<br />
<br />
Fixed: #5974 ("is not a valid map" output is misleading<br />
<br />
Fixed #5946 (play: Some crucial gameplay elements are not defaulted)<br />
<br />
Fixed #5969: (add optional rotation argument to setpos (aka sp))<br />
<br />
deathpickups: Optimizations, thanks to changes in 1.0.4 all the client code to get a players weapons can be done on the server.<br />
<br />
Fixed #5882 (editor_main: Too long execution error when saving maps)<br />
<br />
Fixed #5795 (Admin: Temporary hang on switch to "Resources" tab if you've got a lot of resources)<br />
<br />
admin: Added special skins<br />
<br />
Fixed #5915 (resourcebrowser: Get rid of popup when using restart button)</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnPlayerDamage&diff=64240OnPlayerDamage2019-09-10T22:02:36Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__ <br />
{{Server event}}<br />
This event is triggered when a player is damaged, in any way.<br />
<br />
*This event is not triggered when attacked by a team member if friendly fire is enabled.<br />
*Canceling this event has no effect. Cancel the client-side event [[onClientPlayerDamage]] instead.<br />
*onPlayerDamage doesn't trigger if the damage kills the player, [[onPlayerWasted]] is called instead. <br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
player attacker, int attackerweapon, int bodypart, float loss<br />
</syntaxhighlight> <br />
<br />
*'''attacker''': a [[player]] element representing the player who was the attacker. If there was no attacker this returns false.<br />
*'''attackerweapon''': an [[int]] representing the [[Weapons|attacker weapon]] or the [[Damage Types|damage type]].<br />
*'''bodypart''': an [[int]] representing the bodypart ID the player was hit on when he got damaged.<br />
{{BodyParts}}<br />
*'''loss''': a [[float]] representing the percentage of health the player lost.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the [[player]] who was damaged.<br />
<br />
==Example== <br />
This example causes an instant kill when a player is shot in the head, and announces it in the chatbox.<br />
<syntaxhighlight lang="lua"><br />
function playerDamage_text ( attacker, weapon, bodypart, loss ) --when a player is damaged<br />
if ( bodypart == 9 and attacker and attacker ~= source ) then -- if the body part is 9 (head) and there is an attacker and it wasn't self damage<br />
outputChatBox ( "Headshot!", attacker, 255, 170, 0 ) --output "Headshot" into the chatbox<br />
killPed ( source, attacker, weapon, bodypart ) -- and kill the player<br />
end<br />
end<br />
addEventHandler ( "onPlayerDamage", root, playerDamage_text ) --add an event handler for the onPlayerDamage event<br />
</syntaxhighlight><br />
<br />
==Issues==<br />
{{Issues|<br />
{{Issue|6495|[Fixed in 1.3.3-5411] onPlayerDamage has wrong parameters if source on vehicle}}<br />
{{Issue|8082|(Fixed in r9762) Custom weapons & objects don't fully work with ped damage events}}<br />
}}<br />
<br />
{{See also/Server event|Player events}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=KillPed&diff=64239KillPed2019-09-10T21:54:46Z<p>Arran Fortuna: </p>
<hr />
<div>{{Shared function}}<br />
__NOTOC__<br />
This function kills the specified ped.<br />
<br />
{{New feature/item|3.0153|1.5.3|7848|<br />
From v1.5.3 onwards this function is now available client side. Only works on client side peds.<br />
}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool killPed ( ped thePed, [ ped theKiller = nil, int weapon=255, int bodyPart=255, bool stealth = false ] )</syntaxhighlight><br />
{{OOP||[[ped]]:kill}}<br />
<br />
===Required Arguments===<br />
* '''thePed:''' The [[ped]] to kill<br />
<br />
===Optional Arguments===<br />
* '''theKiller:''' The ped responsible for the kill<br />
* '''weapon:''' The ID of the [[weapon]] or [[Damage Types]] that should appear to have killed the ped (doesn't affect how they die)<br />
* '''bodyPart:''' The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)<br />
{{BodyParts}}<br />
* '''stealth:''' Boolean value, representing whether or not this a stealth kill<br />
<br />
===Returns===<br />
Returns ''true'' if the ped was killed, ''false'' if the ped specified could not be killed or is invalid.<br />
<br />
==Example==<br />
'''Example 1:''' This simple example adds a '''kill''' command to commit suicide.<br />
<syntaxhighlight lang="lua"><br />
function commitSuicide ( sourcePlayer )<br />
-- kill the player and make him responsible for it<br />
killPed ( sourcePlayer, sourcePlayer )<br />
end<br />
-- attach our handler to the "kill" command<br />
addCommandHandler ( "kill", commitSuicide )<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example enables 1 hit kills if a player is shot in the head.<br />
<syntaxhighlight lang="lua"><br />
function headshotKill ( attacker, attackerweapon, bodypart, loss )<br />
if bodypart == 9 then --if the bodypart is the head<br />
--kill the player, emulating the correct killer, weapon and bodypart.<br />
killPed ( source, attacker, attackerweapon, bodypart )<br />
end<br />
end<br />
addEventHandler ( "onPlayerDamage", getRootElement(), headshotKill )<br />
</syntaxhighlight><br />
<br />
== Issues ==<br />
{{Issues|<br />
{{IssuePR|27|Fix stealthkill crash and add killPed client side}}<br />
}}<br />
<br />
==See Also==<br />
{{Ped functions}}<br />
[[ru:killPed]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=KillPed&diff=64238KillPed2019-09-10T21:53:02Z<p>Arran Fortuna: </p>
<hr />
<div>{{Shared function}}<br />
__NOTOC__<br />
This function kills the specified ped.<br />
<br />
{{New feature/item|3.0153|1.5.3|7848|<br />
From v1.5.3 onwards this function is now available client side. Only works on client side peds.<br />
}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua">bool killPed ( ped thePed, [ ped theKiller = nil, int weapon=255, int bodyPart=255, bool stealth = false ] )</syntaxhighlight><br />
{{OOP||[[ped]]:kill}}<br />
<br />
===Required Arguments===<br />
* '''thePed:''' The [[ped]] to kill<br />
<br />
===Optional Arguments===<br />
* '''theKiller:''' The ped responsible for the kill<br />
* '''weapon:''' The ID of the [[weapon]] that should appear to have killed the ped (doesn't affect how they die)<br />
* '''bodyPart:''' The ID of the body part that should appear to have been hit by the weapon (doesn't affect how they die)<br />
{{BodyParts}}<br />
* '''stealth:''' Boolean value, representing whether or not this a stealth kill<br />
<br />
===Returns===<br />
Returns ''true'' if the ped was killed, ''false'' if the ped specified could not be killed or is invalid.<br />
<br />
==Example==<br />
'''Example 1:''' This simple example adds a '''kill''' command to commit suicide.<br />
<syntaxhighlight lang="lua"><br />
function commitSuicide ( sourcePlayer )<br />
-- kill the player and make him responsible for it<br />
killPed ( sourcePlayer, sourcePlayer )<br />
end<br />
-- attach our handler to the "kill" command<br />
addCommandHandler ( "kill", commitSuicide )<br />
</syntaxhighlight><br />
<br />
'''Example 2:''' This example enables 1 hit kills if a player is shot in the head.<br />
<syntaxhighlight lang="lua"><br />
function headshotKill ( attacker, attackerweapon, bodypart, loss )<br />
if bodypart == 9 then --if the bodypart is the head<br />
--kill the player, emulating the correct killer, weapon and bodypart.<br />
killPed ( source, attacker, attackerweapon, bodypart )<br />
end<br />
end<br />
addEventHandler ( "onPlayerDamage", getRootElement(), headshotKill )<br />
</syntaxhighlight><br />
<br />
== Issues ==<br />
{{Issues|<br />
{{IssuePR|27|Fix stealthkill crash and add killPed client side}}<br />
}}<br />
<br />
==See Also==<br />
{{Ped functions}}<br />
[[ru:killPed]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=EngineFreeModel&diff=64237EngineFreeModel2019-09-10T21:51:10Z<p>Arran Fortuna: Added XNikoXD's example from engineRequestModel as it uses engineFreeModel</p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
{{New feature/item|3.0160|1.5.7|20147|This function is used to un-assign the specified model ID from the [[engineRequestModel]] assignment.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool engineFreeModel ( int modelID )<br />
</syntaxhighlight><br />
===Required Arguments===<br />
*'''modelID''': the model ID you want to have un-assigned.<br />
<br />
===Returns===<br />
Returns ''true'' if the model was successfully freed, ''false'' otherwise.<br />
<br />
==Example==<br />
This example creates a ped and then gives you the opportunity to change its model. If the resource stops, then the IDs allocated will be deallocated. Use ''/cap'' for creating the ped and ''/sap'' to skin the ped. You will need some skins added to a folder and to the meta.xml for ''/sap'' to work.<br />
<syntaxhighlight lang="lua"><br />
local peds = {}<br />
function createAllocatedPed()<br />
local x, y, z = getElementPosition(localPlayer)<br />
local id = engineRequestModel("ped")<br />
peds[id] = createPed(id, x+0.5, y, z+0.5)<br />
outputChatBox("New ped with ID "..id.." created.")<br />
end<br />
addCommandHandler("cap", createAllocatedPed, false, false)<br />
<br />
function skinAllocatedPeds()<br />
local txd, dff;<br />
for id,ped in pairs(peds) do<br />
if fileExists("skins/" .. id .. ".txd") and fileExists("skins/" .. id .. ".dff") then<br />
txd = engineLoadTXD("skins/" .. id .. ".txd")<br />
engineImportTXD(txd, id)<br />
dff = engineLoadDFF("skins/" .. id .. ".dff")<br />
engineReplaceModel(dff, id)<br />
outputChatBox("Model ID "..id.." changed correctly.")<br />
else<br />
outputChatBox("Model ID "..id.." couldn't change. REASON: skins/" .. id .. ".txd or skins/" .. id .. ".dff does not exist.")<br />
end<br />
end<br />
end<br />
addCommandHandler("sap", skinAllocatedPeds, false, false)<br />
<br />
function onStop()<br />
for id,ped in pairs(peds) do<br />
engineFreeModel(id)<br />
end<br />
end<br />
addEventHandler("onClientResourceStop", resourceRoot, onStop)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Engine functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=EngineRequestModel&diff=64236EngineRequestModel2019-09-10T21:49:21Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
{{New feature/item|3.0160|1.5.7|20147|This function is used to assign the next available model ID to a certain element type. Currently only "ped" is supported.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool engineRequestModel ( str elementType )<br />
</syntaxhighlight><br />
===Required Arguments===<br />
*'''elementType''': this must be "ped".<br />
<br />
===Returns===<br />
Returns an ''integer'' of the model ID that was available to be assigned to the element type, ''false'' if no free model ID available or invalid element type.<br />
<br />
==Example==<br />
This example creates a ped and then gives you the opportunity to change its model. If the resource stops, then the IDs allocated will be deallocated. Use ''/cap'' for creating the ped and ''/sap'' to skin the ped. You will need some skins added to a folder and to the meta.xml for ''/sap'' to work.<br />
<syntaxhighlight lang="lua"><br />
local peds = {}<br />
function createAllocatedPed()<br />
local x, y, z = getElementPosition(localPlayer)<br />
local id = engineRequestModel("ped")<br />
peds[id] = createPed(id, x+0.5, y, z+0.5)<br />
outputChatBox("New ped with ID "..id.." created.")<br />
end<br />
addCommandHandler("cap", createAllocatedPed, false, false)<br />
<br />
function skinAllocatedPeds()<br />
local txd, dff;<br />
for id,ped in pairs(peds) do<br />
if fileExists("skins/" .. id .. ".txd") and fileExists("skins/" .. id .. ".dff") then<br />
txd = engineLoadTXD("skins/" .. id .. ".txd")<br />
engineImportTXD(txd, id)<br />
dff = engineLoadDFF("skins/" .. id .. ".dff")<br />
engineReplaceModel(dff, id)<br />
outputChatBox("Model ID "..id.." changed correctly.")<br />
else<br />
outputChatBox("Model ID "..id.." couldn't change. REASON: skins/" .. id .. ".txd or skins/" .. id .. ".dff does not exist.")<br />
end<br />
end<br />
end<br />
addCommandHandler("sap", skinAllocatedPeds, false, false)<br />
<br />
function onStop()<br />
for id,ped in pairs(peds) do<br />
engineFreeModel(id)<br />
end<br />
end<br />
addEventHandler("onClientResourceStop", resourceRoot, onStop)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Engine functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Changes_in_1.5.8&diff=64204Changes in 1.5.82019-09-08T17:42:01Z<p>Arran Fortuna: </p>
<hr />
<div><pageclass class="#4286f4" subcaption="Future release"></pageclass><br />
{{Changelogs}}<br />
__NOTOC__<br />
* GitHub commit log: https://github.com/multitheftauto/mtasa-blue/compare/1.5.7...master<br />
* GitHub milestone: https://github.com/multitheftauto/mtasa-blue/milestone/2<br />
* So far https://github.com/multitheftauto/mtasa-blue/compare/632130e...master<br />
<br />
'''This changelog is partial and needs updating.'''<br />
<br />
== Main Additions / Changes ==<br />
<section show="true"><br />
* '''10<sup>th</sup>''' year anniversary update<br />
* Add [[dxDrawPrimitive3D]] and [[dxDrawMaterialPrimitive3D]] ([https://github.com/multitheftauto/mtasa-blue/pull/760 #760] by '''CrosRoad95''')<br />
* Add functions to modify dynamic objects' behaviour ([https://github.com/multitheftauto/mtasa-blue/pull/784 #784] by '''forkerer''')<br />
* Add dynamic ped ID allocating using [[engineRequestModel]] and [[engineFreeModel]] ([https://github.com/multitheftauto/mtasa-blue/commit/475544f1753ce1af24c4cdff7f0d0be48ede709b #349] by '''lopezloo''' + '''Neproify''' + '''Arran''' + '''Qais Patankar''')<br />
</section><br />
<br />
== Statistics ==<br />
<section show="false"><br />
These are some statistics since the [[Changes in 1.5.7|previous release]].<br />
* This is the '''25<sup>th</sup>''' 1.x.x release, planned to be released x.x.xxxx<br />
* '''10<sup>th</sup>''' year anniversary update<br />
* '''{{date difference|2019|8|31}}''' days<br />
* '''14''' new functions<br />
* '''0''' new events<br />
* '''0''' deprecations<br />
* '''7''' bug fixes and changes<br />
* '''38''' commits ([https://github.com/multitheftauto/mtasa-blue/compare/1.5.7...master see comparison])<br />
* '''0''' new open Mantis issues<br />
* '''0''' resolved Mantis issues<br />
* '''5''' closed Mantis issues<br />
* '''2''' new open GitHub issues ([https://github.com/multitheftauto/mtasa-blue/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+created%3A%3E%3D2019-08-31 see list])<br />
* '''2''' resolved GitHub issues ([https://github.com/multitheftauto/mtasa-blue/issues?utf8=%E2%9C%93&q=is%3Aclosed+is%3Aissue+milestone%3A1.6 see list])<br />
* '''1''' closed GitHub issue ([https://github.com/multitheftauto/mtasa-blue/issues?utf8=%E2%9C%93&q=is%3Aclosed+is%3Aissue+closed%3A%3E%3D2019-08-31+no%3Amilestone see list])<br />
* '''0''' new open GitHub pull requests ([https://github.com/multitheftauto/mtasa-blue/pulls?utf8=%E2%9C%93&q=is%3Aopen+is%3Apr+created%3A%3E%3D2019-08-31 see list])<br />
* '''13''' merged GitHub pull requests ([https://github.com/multitheftauto/mtasa-blue/pulls?q=is%3Apr+milestone%3A1.6+is%3Amerged see list])<br />
* '''0''' closed GitHub pull requests ([https://github.com/multitheftauto/mtasa-blue/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aunmerged+closed%3A%3E%3D2019-08-31 see list])<br />
* '''11''' contributors of which '''2''' are new ([https://github.com/multitheftauto/mtasa-blue/graphs/contributors?from=2019-08-31&to=2020-08-31&type=c see list])<br />
* '''67+''' total contributors ([https://github.com/multitheftauto/mtasa-blue/graphs/contributors see list])<br />
* '''1''' vendor update<br />
<br />
<!--<br />
We don't have the https://www.mediawiki.org/wiki/Extension:Variables extension installed,<br />
so remember to update the date in all parts below.<br />
--><br />
<sub>'''Note:''' Last update to these statistics was made<br />
{{#ifeq: {{date difference|2019|9|7}} | 0 | today |<br />
{{#ifeq: {{date difference|2019|9|7}} | 1 | yesterday |<br />
{{date difference|2019|9|7}} days ago<br />
}}<br />
}}.</sub><br />
</section><br />
<br />
== Scripting ==<br />
=== Client ===<br />
<section show="true"><br />
==== 11 New Functions ====<br />
* Add [[setPedFightingStyle]] (previously available server-side only) ([https://github.com/multitheftauto/mtasa-blue/pull/810 #810] by '''StrixG''')<br />
* Add [[setPedArmor]] (previously available server-side only) ([https://github.com/multitheftauto/mtasa-blue/pull/811 #811] by '''StrixG''')<br />
* Add [[areVehicleLightsOn]] ([https://github.com/multitheftauto/mtasa-blue/pull/938 #938] by '''StrixG''')<br />
* Add [[dxDrawPrimitive3D]] and [[dxDrawMaterialPrimitive3D]] ([https://github.com/multitheftauto/mtasa-blue/pull/760 #760] by '''CrosRoad95''')<br />
* Add functions to modify dynamic objects' behaviour ([https://github.com/multitheftauto/mtasa-blue/pull/784 #784] by '''forkerer''')<br />
** [[engineGetModelPhysicalPropertiesGroup]]<br />
** [[engineRestoreModelPhysicalPropertiesGroup]]<br />
** [[engineSetModelPhysicalPropertiesGroup]]<br />
** [[engineGetObjectGroupPhysicalProperty]]<br />
** [[engineRestoreObjectGroupPhysicalProperties]]<br />
** [[engineSetObjectGroupPhysicalProperty]]<br />
* Add dynamic ped ID allocating using [[engineRequestModel]] and [[engineFreeModel]] ([https://github.com/multitheftauto/mtasa-blue/commit/475544f1753ce1af24c4cdff7f0d0be48ede709b #349] by '''lopezloo''' + '''Neproify''' + '''Arran''' + '''Qais Patankar''')<br />
<br />
<!--<br />
==== New Events ====<br />
* Placeholder<br />
<br />
==== Deprecations ====<br />
* Placeholder<br />
<br />
==== New Arguments & Parameters ====<br />
* Placeholder<br />
<br />
==== Bug Fixes & Changes ====<br />
* Placeholder<br />
--><br />
</section><br />
<br />
=== Server ===<br />
<section show="true"><br />
==== 2 New Functions ====<br />
* Add [[setPlayerScriptDebugLevel]] and [[getPlayerScriptDebugLevel]] ([https://github.com/multitheftauto/mtasa-blue/pull/826 #826] by '''knitz12''')<br />
<br />
<!--<br />
==== New Events ====<br />
* Placeholder<br />
<br />
==== Deprecations ====<br />
* Placeholder<br />
<br />
==== New Arguments & Parameters ====<br />
* Placeholder<br />
--><br />
==== Bug Fixes & Changes ====<br />
<!--<br />
* Fix [[callRemote]] to return 0 errno instead of nil upon success ([https://github.com/multitheftauto/mtasa-blue/pull/295 #295] by '''myonlake''')<br />
--><br />
* Fix [[iprint]] to be able to read and output nil arguments properly ([https://github.com/multitheftauto/mtasa-blue/pull/1064 #1064] by '''TheNormalnij''')<br />
</section><br />
<br />
=== Shared (''Client & Server side'') ===<br />
<section show="true"><br />
==== New Functions ====<br />
* Add [[xmlLoadString]] ([https://github.com/multitheftauto/mtasa-blue/pull/809 #809] by '''LopSided''')<br />
<!--<br />
==== New Events ====<br />
* Placeholder<br />
<br />
==== Deprecations ====<br />
* Placeholder<br />
<br />
==== New Arguments & Parameters ====<br />
* Placeholder<br />
<br />
==== Bug Fixes & Changes ====<br />
* Placeholder<br />
--><br />
</section><br />
<br />
== Client ==<br />
<section show="true"><br />
=== 6 Bug Fixes & Changes ===<br />
* Add new client setting to toggle external sounds ([https://github.com/multitheftauto/mtasa-blue/pull/834 #834] by '''myonlake''')<br />
* Fix crash when attempting to stream out a sound that's not streamed in (See commit [https://github.com/multitheftauto/mtasa-blue/commit/e1b7c730448d12a5eeb452239e8053e86924294f e1b7c73] by '''sbx320''')<br />
* Fix [[dxDrawCircle]] ''segments'' argument being wrongly offset by one ([https://github.com/multitheftauto/mtasa-blue/pull/1079 #1079] by '''ApeLsiN4eG''')<br />
* Fix potential crash when moving objects (See commit [https://github.com/multitheftauto/mtasa-blue/commit/90895c221549893501f5f717af3ca56878e29b5d 90895c2] by '''botder''')<br />
* Update credits (See commit [https://github.com/multitheftauto/mtasa-blue/commit/39227d795efafe940dc6c317c20b0162b1bd0bb3 39227d7] by '''qaisjp''')<br />
* Don't apply damage to peds without a game entity (See commit [https://github.com/multitheftauto/mtasa-blue/commit/632130e36a96071290593fc3c677a536f7b19e1f 632130e] by '''botder''')<br />
<br />
=== Vendor Updates ===<br />
* Update BASS libraries (See commit [https://github.com/multitheftauto/mtasa-blue/commit/e5ede83b936e0e3c59d3670969e72b9583c0a219 e5ede83] by '''Dutchman101''')<br />
</section><br />
<br />
<!--<br />
== Server ==<br />
<section show="false"><br />
=== Bug Fixes & Changes ===<br />
* Placeholder<br />
<br />
=== Vendor Updates ===<br />
* Placeholder<br />
</section><br />
<br />
== Shared ==<br />
<section show="false"><br />
=== Bug Fixes & Changes ===<br />
* Placeholder<br />
<br />
=== Vendor Updates ===<br />
* Placeholder<br />
</section><br />
<br />
== Resources ==<br />
<section show="false"><br />
* Placeholder<br />
</section><br />
--><br />
== Extra information ==<br />
''More detailed information available on our GitHub repositories:<br />
:* [https://github.com/multitheftauto/mtasa-blue MTA:SA Blue]<br />
:* [https://github.com/multitheftauto/mtasa-resources MTA:SA Official Resources]<br />
<br />
[[Category:Changelog]]<br />
[[Category:Incomplete]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=EngineRequestModel&diff=64203EngineRequestModel2019-09-08T17:36:09Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
{{New feature/item|3.0160|1.5.7|20147|This function is used to assign the next available model ID to a certain element type. Currently only "ped" is supported.}}<br />
{{Note|<br />
Needs checking / improving.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool engineRequestModel ( str elementType )<br />
</syntaxhighlight><br />
===Required Arguments===<br />
*'''elementType''': this must be "ped".<br />
<br />
===Returns===<br />
Returns an ''integer'' of the model ID that was available to be assigned to the element type, ''false'' if no free model ID available or invalid element type.<br />
<br />
==Example==<br />
{{Example}}<br />
<br />
==See Also==<br />
{{Engine functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Template:Engine_functions&diff=64202Template:Engine functions2019-09-08T17:31:40Z<p>Arran Fortuna: </p>
<hr />
<div>* [[engineApplyShaderToWorldTexture]]<br />
* [[engineGetModelIDFromName]]<br />
* [[engineGetModelLODDistance]]<br />
* [[engineGetModelNameFromID]]<br />
{{New items|3.0160|1.5.7|<br />
* [[engineGetModelPhysicalPropertiesGroup]]<br />
* [[engineRestoreModelPhysicalPropertiesGroup]]<br />
* [[engineSetModelPhysicalPropertiesGroup]]<br />
* [[engineGetObjectGroupPhysicalProperty]]<br />
* [[engineRestoreObjectGroupPhysicalProperties]]<br />
* [[engineSetObjectGroupPhysicalProperty]]<br />
|19626}}<br />
{{New items|3.0160|1.5.7|<br />
* [[engineRequestModel]]<br />
* [[engineFreeModel]]<br />
|20147}}<br />
* [[engineGetModelTextureNames]]<br />
* [[engineGetVisibleTextureNames]]<br />
* [[engineImportTXD]]<br />
* [[engineLoadCOL]]<br />
* [[engineLoadDFF]]<br />
* [[engineLoadIFP]]<br />
* [[engineLoadTXD]]<br />
* [[engineRemoveShaderFromWorldTexture]]<br />
* [[engineReplaceAnimation]]<br />
* [[engineReplaceCOL]]<br />
* [[engineReplaceModel]]<br />
* [[engineRestoreAnimation]]<br />
* [[engineRestoreCOL]]<br />
* [[engineRestoreModel]]<br />
* [[engineSetAsynchronousLoading]]<br />
* [[engineSetModelLODDistance]]<br />
* [[engineSetSurfaceProperties]]<br />
* [[engineGetSurfaceProperties]]<br />
* [[engineResetSurfaceProperties]]<br />
<noinclude>[[Category:Functions templates]]</noinclude></div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=EngineFreeModel&diff=64201EngineFreeModel2019-09-08T17:03:37Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Client function}}<br />
{{New feature/item|3.0160|1.5.7|20147|This function is used to un-assign the specified model ID from the [[engineRequestModel]] assignment.}}<br />
{{Note|<br />
Needs checking / improving.}}<br />
<br />
==Syntax==<br />
<syntaxhighlight lang="lua"><br />
bool engineFreeModel ( int modelID )<br />
</syntaxhighlight><br />
===Required Arguments===<br />
*'''modelID''': the model ID you want to have un-assigned.<br />
<br />
===Returns===<br />
Returns ''true'' if the model was successfully freed, ''false'' otherwise.<br />
<br />
==Example==<br />
{{Example}}<br />
<br />
==See Also==<br />
{{Engine functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnClientWorldSound&diff=63861OnClientWorldSound2019-08-23T09:52:46Z<p>Arran Fortuna: Added example to see sound calls</p>
<hr />
<div>{{Client event}}<br />
__NOTOC__<br />
{{New feature/item|3.0157|1.5.6|14652|This event triggers whenever a GTA sound starts playing.}}<br />
{{Note|Use [[setWorldSoundEnabled]] if you want to disable certain sounds conditionless.<br />
For example, you should only cancel player emitted sounds in this event, because when you cancel certain vehicle sounds, the game will try to play the same sound on the next frame.}}<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
int group, int index, float x, float y, float z<br />
</syntaxhighlight><br />
*'''group:''' An [[int|integer]] representing the [[World sound groups|world sound group]]<br />
*'''index:''' An [[int|integer]] representing an individual sound within the group<br />
*'''x:''' a [[float]]ing point number representing the X coordinate on the map.<br />
*'''y:''' a [[float]]ing point number representing the Y coordinate on the map.<br />
*'''z:''' a [[float]]ing point number representing the Z coordinate on the map.<br />
<br />
==Source==<br />
The source of this event is the element, which emitted the sound.<br />
<br />
==Cancel effect==<br />
If this event is [[Event system#Canceling|canceled]], the sound won't play at all.<br />
<br />
==Example==<br />
This example will cancel every vehicle sound.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler("onClientWorldSound", root, function()<br />
if getElementType(source) == "vehicle" then<br />
cancelEvent()<br />
end<br />
end)<br />
</syntaxhighlight><br />
<br />
This example lets you see how many times each sound that gets played has been played using '/seesoundlist'.<br />
<syntaxhighlight lang="lua"><br />
local sounds = {}<br />
<br />
addEventHandler("onClientWorldSound", root, function(group, index)<br />
sounds[group.." | "..index] = (sounds[group.." | "..index] or 0) + 1<br />
end)<br />
<br />
function cmdSeeSoundList()<br />
-- Put the non iterated table into an interated table so we can sort them<br />
local tbl = {}<br />
for sound, count in pairs(sounds) do<br />
tbl[#tbl + 1] = {sound, count}<br />
end<br />
table.sort(tbl, function(a, b) return a[2] > b[2] end)<br />
-- Output the table to clipboard<br />
local str = "Group | Index: Times played\n"<br />
for i, dat in ipairs(tbl) do<br />
str = str..dat[1]..": "..dat[2].."\n"<br />
end<br />
setClipboard(str)<br />
outputChatBox("Use CTRL + V in notepad to view the table.")<br />
end<br />
addCommandHandler("seesoundlist", cmdSeeSoundList)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===World sound functions===<br />
* [[setWorldSoundEnabled]]<br />
* [[isWorldSoundEnabled]]<br />
* [[resetWorldSounds]]<br />
===Client other events===<br />
{{Client_other_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnClientWorldSound&diff=63860OnClientWorldSound2019-08-23T09:41:48Z<p>Arran Fortuna: /* Example */ pretty sure that needs to be root</p>
<hr />
<div>{{Client event}}<br />
__NOTOC__<br />
{{New feature/item|3.0157|1.5.6|14652|This event triggers whenever a GTA sound starts playing.}}<br />
{{Note|Use [[setWorldSoundEnabled]] if you want to disable certain sounds conditionless.<br />
For example, you should only cancel player emitted sounds in this event, because when you cancel certain vehicle sounds, the game will try to play the same sound on the next frame.}}<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
int group, int index, float x, float y, float z<br />
</syntaxhighlight><br />
*'''group:''' An [[int|integer]] representing the [[World sound groups|world sound group]]<br />
*'''index:''' An [[int|integer]] representing an individual sound within the group<br />
*'''x:''' a [[float]]ing point number representing the X coordinate on the map.<br />
*'''y:''' a [[float]]ing point number representing the Y coordinate on the map.<br />
*'''z:''' a [[float]]ing point number representing the Z coordinate on the map.<br />
<br />
==Source==<br />
The source of this event is the element, which emitted the sound.<br />
<br />
==Cancel effect==<br />
If this event is [[Event system#Canceling|canceled]], the sound won't play at all.<br />
<br />
==Example==<br />
This example will cancel every vehicle sound.<br />
<syntaxhighlight lang="lua"><br />
addEventHandler("onClientWorldSound", root, function()<br />
if getElementType(source) == "vehicle" then<br />
cancelEvent()<br />
end<br />
end)<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
===World sound functions===<br />
* [[setWorldSoundEnabled]]<br />
* [[isWorldSoundEnabled]]<br />
* [[resetWorldSounds]]<br />
===Client other events===<br />
{{Client_other_events}}<br />
===Client event functions===<br />
{{Client_event_functions}}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=63002GetLocalization2019-06-14T16:22:16Z<p>Arran Fortuna: Order alphabetically</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all (probably all) the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["ar"] = "Arabic",<br />
["bg"] = "Bulgarian",<br />
["cs"] = "Czech",<br />
["de"] = "German",<br />
["en_US"] = "English",<br />
["el"] = "Greek",<br />
["es"] = "Spanish",<br />
["et"] = "Estonian",<br />
["fr"] = "French",<br />
["hr"] = "Croatian",<br />
["hu"] = "Hungarian",<br />
["id"] = "Indonesian",<br />
["it"] = "Italian",<br />
["ja"] = "Japanese",<br />
["lt"] = "Lithuanian",<br />
["lv"] = "Latvian",<br />
["mk"] = "Macedonian",<br />
["nb"] = "Norwegian",<br />
["nl"] = "Dutch",<br />
["pt_BR"] = "Brazilian",<br />
["pl"] = "Polish",<br />
["ru"] = "Russian",<br />
["ro"] = "Romanian",<br />
["sl"] = "Slovenian",<br />
["sv"] = "Swedish",<br />
["sk"] = "Slovak",<br />
["tr"] = "Turkish",<br />
["uk"] = "Ukranian",<br />
["vi"] = "Vietnamese",<br />
["zh_CN"] = "Chinese",<br />
["zh_TW"] = "Taiwanese",<br />
<br />
}<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=63001GetLocalization2019-06-14T16:03:32Z<p>Arran Fortuna: Should be complete now</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is a list of all (probably all) the language codes used in MTA in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["en_US"] = "English",<br />
["ru"] = "Russian",<br />
["ar"] = "Arabic",<br />
["es"] = "Spanish",<br />
["pt_BR"] = "Brazilian",<br />
["hu"] = "Hungarian",<br />
["de"] = "German",<br />
["pl"] = "Polish",<br />
["nl"] = "Dutch",<br />
["tr"] = "Turkish",<br />
["fr"] = "French",<br />
["hr"] = "Croatian",<br />
["sl"] = "Slovenian",<br />
["it"] = "Italian",<br />
["zh_CN"] = "Chinese",<br />
["ro"] = "Romanian",<br />
["nb"] = "Norwegian",<br />
["sv"] = "Swedish",<br />
["el"] = "Greek",<br />
["lt"] = "Lithuanian",<br />
["id"] = "Indonesian",<br />
["vi"] = "Vietnamese",<br />
["bg"] = "Bulgarian",<br />
["cs"] = "Czech",<br />
["et"] = "Estonian",<br />
["ja"] = "Japanese",<br />
["lv"] = "Latvian",<br />
["mk"] = "Macedonian",<br />
["sk"] = "Slovak",<br />
["uk"] = "Ukranian",<br />
["zh_TW"] = "Taiwanese",<br />
<br />
}<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=GetLocalization&diff=63000GetLocalization2019-06-14T15:50:34Z<p>Arran Fortuna: Added an incomplete (where do I find them?) table of language codes to their language</p>
<hr />
<div>{{Client function}}<br />
__NOTOC__<br />
{{New items|3.0140|1.4|<br />
This function gets the player's localization setting as set in the MTA client.<br />
}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
table getLocalization ( )<br />
</syntaxhighlight> <br />
<br />
===Returns===<br />
Returns a [[table]] with the following entries:<br />
*'''code :''' The language code ''(eg. "en_US" for "English (United States)" or "ar" for "Arabic")''.<br />
*'''name :''' The name of the language ''(eg. "English (United States)" or "Arabic")''.<br />
<br />
==Example==<br />
This example outputs simple ''Welcome'' message at the resource start (also when player joins the game if the resource is already running).<br />
<syntaxhighlight lang="lua"><br />
local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie", hu = "Üdv"}<br />
<br />
addEventHandler("onClientResourceStart", resourceRoot, <br />
function ()<br />
local languageCode = getLocalization()["code"]<br />
if msg[languageCode] then --Check if the message is avaible in client's language<br />
outputChatBox(msg[languageCode] .. "!") --Output it<br />
else<br />
outputChatBox("Welcome!") --Output English for any other language<br />
end<br />
end)<br />
</syntaxhighlight><br />
This is many of but not all (please add more to this list) the language codes in a table with the full name of the language.<br />
<syntaxhighlight lang="lua"><br />
langTable = {<br />
["en_US"] = "English",<br />
["ru"] = "Russian",<br />
["ar"] = "Arabic",<br />
["es"] = "Spanish",<br />
["pt_BR"] = "Brazilian",<br />
["hu"] = "Hungarian",<br />
["de"] = "German",<br />
["pl"] = "Polish",<br />
["nl"] = "Dutch",<br />
["tr"] = "Turkish",<br />
["fr"] = "French",<br />
["hr"] = "Croatian",<br />
["sl"] = "Slovenian",<br />
["it"] = "Italian",<br />
["zh_CN"] = "Chinese",<br />
["ro"] = "Romanian",<br />
["nb"] = "Norwegian",<br />
["se"] = "Swedish",<br />
["el"] = "Greek",<br />
["lt"] = "Lithuanian",<br />
["id"] = "Indonesian",<br />
["vi"] = "Vietnamese",<br />
["bg"] = "Bulgarian",<br />
["sv"] = "Unknown", -- Google is saying Swedish but MTA uses "se" for that.<br />
}<br />
</syntaxhighlight><br />
<br />
==See Also==<br />
{{Client_utility_functions}}<br />
[[ru:GetLocalization]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=How_you_can_help&diff=62944How you can help2019-06-06T21:37:08Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
Multi Theft Auto has loads of areas in which you can help us. In turn, we'll be more than happy to help you get started with any ideas you have, help test them and - if they're good enough - release them to the whole community. This page outlines the key areas you could do something in, of course, there are many things we've not thought of, so think outside the box!<br />
<br />
==Coding for MTA:SA==<br />
* Create [https://github.com/multitheftauto/mtasa-blue/pulls pull requests] for the mod, containing requested features or bugfixes. ([[Coding guidelines]])<br />
* Translate MTA:SA to your native language - https://translate.multitheftauto.com/<br />
<br />
==Scripting==<br />
* Create a gamemode <br />
**[[Scripting Introduction]]<br />
**[https://www.lua.org/pil/index.html "Programming in Lua" Manual]<br />
* Create an administration page on the HTTP server.<br />
**[[Resource Web Access]]<br />
* Make a general purpose resource that provides useful functions to other resources.<br />
<br />
==Mapping==<br />
* Create a map with the map editor for an existing gamemode.<br />
**[[Resource:Editor|Map Editor Manual]]<br />
<br />
==Web development==<br />
* Work with lil_Toady to add new features and improvements to community.mtasa.com.<br />
* Create your own system for statistics - using the [[PHP SDK]] as a basis. Contact eAi or jbeta for help.<br />
<br />
==Documentation==<br />
Before you make changes check out: [[Help:Editing Guidelines|Editing Guidelines]] and [[Help:MTA Wiki Specific Templates|Specific Templates]]<br />
* Finish documentation for [[:Category:Incomplete|Incomplete functions]] - ask in #mta.scripting if you're not sure of something.<br />
* Add examples to [[:Category:Needs Example|functions & events missing examples]] - please '''test''' them, and again, ask if you need help.<br />
* Review and verify [[:Category:Needs Checking|pages that need checking]] - make sure highlighted issues are solved before removing pages from the category.<br />
* Expand the pages that explain [[:Category:Scripting_Concepts|MTA core concepts]].<br />
* Write tutorials to help new people.<br />
* Translate the wiki pages so people from other countries can get started in MTA too.<br />
* Create documentation for undocumented functions and events [[Undocumented Items]]<br />
* Keep 'changes in' [https://wiki.multitheftauto.com/wiki/Changes_in_1.5.7 page] for the future releases updated.<br />
<br />
==Quality Assurance==<br />
* [https://github.com/multitheftauto/mtasa-blue/issues Report issues] with the mod, make sure to do a search on the already reported issues first.<br />
* Test and confirm existing reported issues.<br />
* Use the newest build of MTA to detect and report new bugs, by going to 'Settings', 'Advanced', 'Update build type' and choosing 'Nightly' or get it regularly [https://nightly.mtasa.com/ from here].<br />
* Any bugs which are related to a scripting function / event, document that bug by adding a [https://wiki.multitheftauto.com/wiki/Help:MTA_Wiki_Specific_Templates warning] to the wiki page to save other scripters a lot of time.<br />
<br />
==Specific tasks==<br />
* Create a fuzzer to check for crashes in our scripting functions.<br />
* Help develop/fix existing gamemodes. Contact the original author on IRC (or ask a developer) to tell the author so you can work together.<br />
* The web interface resources (resourcemanager, resourcebrowser and webadmin chiefly) are really only compatible with Firefox. Someone could put in some time to make these work on Internet Explorer, Opera and Safari. See [[User_talk:EAi|eAi]] for help.<br />
<br />
==Grant==<br />
You can donate to MTA:SA [https://mtasa.com/donate/manage.php here]<br />
<br />
[[pl:Jak możesz pomóc]]<br />
[[uk:How you can help]]<br />
[[ru:How you can help]]<br />
[[es:Cómo puedes ayudar]]<br />
[[hu:How you can help]]<br />
[[tr:Nasıl yardımcı olabilirsiniz]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=How_you_can_help&diff=62943How you can help2019-06-06T21:28:22Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
Multi Theft Auto has loads of areas in which you can help us. In turn, we'll be more than happy to help you get started with any ideas you have, help test them and - if they're good enough - release them to the whole community. This page outlines the key areas you could do something in, of course, there are many things we've not thought of, so think outside the box!<br />
<br />
==Coding for MTA:SA==<br />
* Create [https://github.com/multitheftauto/mtasa-blue/pulls pull requests] for the mod, containing requested features or bugfixes. ([[Coding guidelines]])<br />
* Translate MTA:SA to your native language - https://translate.multitheftauto.com/<br />
<br />
==Scripting==<br />
* Create a gamemode <br />
**[[Scripting Introduction]]<br />
**[https://www.lua.org/pil/index.html "Programming in Lua" Manual]<br />
* Create an administration page on the HTTP server.<br />
**[[Resource Web Access]]<br />
* Make a general purpose resource that provides useful functions to other resources.<br />
<br />
==Mapping==<br />
* Create a map with the map editor for an existing gamemode.<br />
**[[Resource:Editor|Map Editor Manual]]<br />
<br />
==Web development==<br />
* Work with lil_Toady to add new features and improvements to community.mtasa.com.<br />
* Create your own system for statistics - using the [[PHP SDK]] as a basis. Contact eAi or jbeta for help.<br />
<br />
==Documentation==<br />
Before you make changes check out: [[Help:Editing Guidelines|Editing Guidelines]] and [[Help:MTA Wiki Specific Templates|Specific Templates]]<br />
* Finish documentation for [[:Category:Incomplete|Incomplete functions]] - ask in #mta.scripting if you're not sure of something.<br />
* Add examples to [[:Category:Needs Example|functions & events missing examples]] - please '''test''' them, and again, ask if you need help.<br />
* Review and verify [[:Category:Needs Checking|pages that need checking]] - make sure highlighted issues are solved before removing pages from the category.<br />
* Expand the pages that explain [[:Category:Scripting_Concepts|MTA core concepts]].<br />
* Write tutorials to help new people.<br />
* Translate the wiki pages so people from other countries can get started in MTA too.<br />
* Create documentation for undocumented functions and events [[Undocumented Items]]<br />
<br />
==Quality Assurance==<br />
* [https://github.com/multitheftauto/mtasa-blue/issues Report issues] with the mod, make sure to do a search on the already reported issues first.<br />
* Test and confirm existing reported issues.<br />
* Use the newest build of MTA to detect and report new bugs, by going to 'Settings', 'Advanced', 'Update build type' and choosing 'Nightly' or get it regularly [https://nightly.mtasa.com/ from here]<br />
<br />
==Specific tasks==<br />
* Create a fuzzer to check for crashes in our scripting functions.<br />
* Help develop/fix existing gamemodes. Contact the original author on IRC (or ask a developer) to tell the author so you can work together.<br />
* The web interface resources (resourcemanager, resourcebrowser and webadmin chiefly) are really only compatible with Firefox. Someone could put in some time to make these work on Internet Explorer, Opera and Safari. See [[User_talk:EAi|eAi]] for help.<br />
<br />
==Grant==<br />
You can donate to MTA:SA [https://mtasa.com/donate/manage.php here]<br />
<br />
[[pl:Jak możesz pomóc]]<br />
[[uk:How you can help]]<br />
[[ru:How you can help]]<br />
[[es:Cómo puedes ayudar]]<br />
[[hu:How you can help]]<br />
[[tr:Nasıl yardımcı olabilirsiniz]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=Template:Changelogs&diff=62927Template:Changelogs2019-06-03T20:22:47Z<p>Arran Fortuna: Added 1.5.7</p>
<hr />
<div>{| cellpadding="4" style="border-collapse: collapse; border-width: 1px; border-style: solid; border-color: #FFF; float: right; margin-left: 1em;"<br />
|-<br />
!width=140 style="background-color: #D6DCFF; border-style: solid; border-width: 1px; border-color: #FFF; color: #00000;"| MTA:SA Version<br />
!width=400 style="white-space: nowrap; background-color: #D6DCFF; border-style: solid; border-width: 1px; border-color: #FFF;"| Changelogs<br />
{{Changelogsrow|1.0|[[Changes in 1.0|1.0.0]] &bull; 1.0.1 &bull; 1.0.2 &bull; 1.0.3 &bull; 1.0.4}}<br />
{{Changelogsrow|1.1|[[Changes in 1.1|1.1.0]] &bull; 1.1.1}}<br />
{{Changelogsrow|1.2|[[Changes in 1.2|1.2.0]]}}<br />
{{Changelogsrow|1.3|[[Changes in 1.3|1.3.0]] &bull; [[Changes in 1.3.1|1.3.1]] &bull; [[Changes in 1.3.2|1.3.2]] &bull; [[Changes in 1.3.3|1.3.3]] &bull; [[Changes in 1.3.4|1.3.4]] &bull; [[Changes in 1.3.5|1.3.5]]}}<br />
{{Changelogsrow|1.4|[[Changes in 1.4|1.4.0]] &bull; [[Changes in 1.4.1|1.4.1]]}}<br />
{{Changelogsrow|1.5|[[Changes in 1.5|1.5.0]] &bull; [[Changes in 1.5.1|1.5.1]] &bull; [[Changes in 1.5.2|1.5.2]] &bull; [[Changes in 1.5.3|1.5.3]] &bull; [[Changes in 1.5.4|1.5.4]] &bull; [[Changes in 1.5.5|1.5.5]] &bull; [[Changes in 1.5.6|1.5.6]] &bull; [[Changes in 1.5.7|1.5.7]]}}<br />
|}</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnTrailerAttach&diff=62843OnTrailerAttach2019-05-29T15:52:11Z<p>Arran Fortuna: /* Cancel effect */</p>
<hr />
<div>__NOTOC__<br />
{{Server event}}<br />
{{Needs Checking|Cancellation of event has no effect. detachTrailerFromVehicle in the event doesn't work either, 50 ms timer is effective.}}<br />
This event is triggered when a trailer is attached to a truck or when a tow truck hooks on to a vehicle.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
vehicle theTruck<br />
</syntaxhighlight> <br />
<br />
*'''theTruck''': the truck [[vehicle]] that got attached to this trailer.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the trailer [[vehicle]] that the truck got attached to.<br />
<br />
<!-- Only include this section below if cancelling the event has any effect. If you don't know if it does, ask a dev! --><br />
==Cancel effect==<br />
{{Warning|Doesn't appear to work.}}<br />
If this event is [[Event system#Canceling|canceled]], the trailer will detach from the truck again.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example removes a trailer from the truck it is attached to. Good if you do not want people attaching trailers to vehicles<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function detachTrailer(theTruck)<br />
--detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer<br />
-- Immediate detatchment of the trailer through cancel event or this method doesn't seem to work so requires a timer:<br />
setTimer(detachTrailer2, 50, 1, theTruck, source)<br />
end<br />
addEventHandler("onTrailerAttach", getRootElement(), detachTrailer)<br />
<br />
function detachTrailer2(theTruck, trailer)<br />
if (isElement(theTruck) and isElement(trailer)) then<br />
detachTrailerFromVehicle(theTruck, trailer)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Vehicle events}}<br />
<br />
[[ru:onTrailerAttach]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnTrailerAttach&diff=62842OnTrailerAttach2019-05-29T15:50:54Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Server event}}<br />
{{Needs Checking|Cancellation of event has no effect. detachTrailerFromVehicle in the event doesn't work either, 50 ms timer is effective.}}<br />
This event is triggered when a trailer is attached to a truck or when a tow truck hooks on to a vehicle.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
vehicle theTruck<br />
</syntaxhighlight> <br />
<br />
*'''theTruck''': the truck [[vehicle]] that got attached to this trailer.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the trailer [[vehicle]] that the truck got attached to.<br />
<br />
<!-- Only include this section below if cancelling the event has any effect. If you don't know if it does, ask a dev! --><br />
==Cancel effect==<br />
If this event is [[Event system#Canceling|canceled]], the trailer will detach from the truck again.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example removes a trailer from the truck it is attached to. Good if you do not want people attaching trailers to vehicles<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function detachTrailer(theTruck)<br />
--detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer<br />
-- Immediate detatchment of the trailer through cancel event or this method doesn't seem to work so requires a timer:<br />
setTimer(detachTrailer2, 50, 1, theTruck, source)<br />
end<br />
addEventHandler("onTrailerAttach", getRootElement(), detachTrailer)<br />
<br />
function detachTrailer2(theTruck, trailer)<br />
if (isElement(theTruck) and isElement(trailer)) then<br />
detachTrailerFromVehicle(theTruck, trailer)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Vehicle events}}<br />
<br />
[[ru:onTrailerAttach]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=OnTrailerAttach&diff=62841OnTrailerAttach2019-05-29T15:37:20Z<p>Arran Fortuna: </p>
<hr />
<div>__NOTOC__<br />
{{Server event}}<br />
This event is triggered when a trailer is attached to a truck or when a tow truck hooks on to a vehicle.<br />
<br />
==Parameters==<br />
<syntaxhighlight lang="lua"><br />
vehicle theTruck<br />
</syntaxhighlight> <br />
<br />
*'''theTruck''': the truck [[vehicle]] that got attached to this trailer.<br />
<br />
==Source==<br />
The [[event system#Event source|source]] of this event is the trailer [[vehicle]] that the truck got attached to.<br />
<br />
<!-- Only include this section below if cancelling the event has any effect. If you don't know if it does, ask a dev! --><br />
==Cancel effect==<br />
If this event is [[Event system#Canceling|canceled]], the trailer will detach from the truck again.<br />
<br />
==Example== <br />
<!-- Explain what the example is in a single sentance --><br />
This example removes a trailer from the truck it is attached to. Good if you do not want people attaching trailers to vehicles<br />
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --><br />
<syntaxhighlight lang="lua"><br />
function detachTrailer(theTruck)<br />
detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer<br />
end<br />
addEventHandler("onTrailerAttach", getRootElement(), detachTrailer)<br />
</syntaxhighlight><br />
<br />
{{See also/Server event|Vehicle events}}<br />
<br />
[[ru:onTrailerAttach]]</div>Arran Fortunahttps://wiki.multitheftauto.com/index.php?title=SetFPSLimit&diff=62760SetFPSLimit2019-05-22T15:20:36Z<p>Arran Fortuna: /* Issues when increasing FPS */</p>
<hr />
<div>{{Server client function}}<br />
__NOTOC__<br />
This function sets the maximum [http://en.wikipedia.org/wiki/Frame_rate FPS (Frames per second)] that players on the server can run their game at. <br />
{{Note|When set client side, the actual limit used is the lowest of both the server and client set values}}<br />
==Syntax== <br />
<syntaxhighlight lang="lua"><br />
bool setFPSLimit ( int fpsLimit ) <br />
</syntaxhighlight> <br />
<br />
===Required Arguments=== <br />
*'''fpsLimit:''' An integer value representing the maximum FPS. This value may be between '''25''' and '''100''' FPS. You can also pass '''0''' or ''false'', in which case the FPS limit will be the one set in the client settings (by default, 100 FPS).<br />
<br />
===Returns===<br />
Returns ''true'' if successful, or ''false'' if it was not possible to set the limit or an invalid value was passed.<br />
<br />
==Issues when increasing FPS==<br />
It is also recommended to set a conservative FPS limit (between 30-60), because high FPS can break some GTA internal calculations. The higher the FPS the more of a problem these become:<br />
* Slower swimming.<br />
* Impossibility to move sideways while aiming certain weapons.<br />
* Speed of vehicles is effected, racers with a higher FPS will have an unfair advantage.<br />
* Pressing the horn button to turn on and off sirens gets really hard the higher the FPS.<br />
* Climbing over certain objects will result in instant death. Example at: 2520.108, -1681.407, 19.406, 266<br />
* Animations can randomly get messed up.<br />
* There were more issues like not being able to take off in Skimmer which MTA developers have fixed.<br />
* Satchels can be thrown ~10% less distance.<br />
<br />
==Example== <br />
This command sets the fps limit in a command handler.<br />
<section name="Server" class="server" show="true"><br />
<syntaxhighlight lang="lua">function fpsFunction( player, command, limit ) -- First define the function<br />
if hasObjectPermissionTo ( player, "function.setFPSLimit" ) and limit then <br />
-- If the player has permission to set FPS limit and limit is submitted...<br />
setFPSLimit ( limit ) -- Set the fps.<br />
end<br />
end <br />
<br />
addCommandHandler ( "setfps", fpsFunction ) -- Attach the setfps command to fpsFunction function.<br />
</syntaxhighlight><br />
</section><br />
<br />
==See Also==<br />
{{Server functions}}<br />
<br />
[[pl:setFPSLimit]]<br />
[[ru:setFPSLimit]]</div>Arran Fortuna