Template:Useful Functions: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (sorted alphabetically, added dxDrawColorText)
Line 2: Line 2:


*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span>
*[[callServerFunction]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to call any server-side function from the client's side.</span>
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span>


*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span>
*[[Check]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function checks if it's arguments are of the right types and calls the error-function if one isn't.</span>
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span>


*[[doForAllElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function can be used to execute a specified function for all elements of a specified type.</span>
*[[doForAllElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function can be used to execute a specified function for all elements of a specified type.</span>
*[[dxDrawColorText]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function draws a dx text with #RRGGBB color codes support.</span>


*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span>
*[[iterElements]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).</span>
Line 14: Line 20:


*[[getAge]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span>
*[[getAge]] <span style="color:gray; font-family:'Georgia', sans-serif; font-size:smaller;">» This function calculates the age of a birthday.</span>
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span>
*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span>
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span>


*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span>
*[[getPointFromDistanceRotation]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds a point based on a starting point, direction and distance.</span>
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span>


*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].</span>
*[[getTimestamp]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» With this function you can get the [http://en.wikipedia.org/wiki/Unix_time UNIX timestamp].</span>
Line 24: Line 38:


*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span>
*[[math.round]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Rounds a number whereas the number of decimals to keep and the method may be set.</span>
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span>
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span>
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span>


*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span>
*[[setTableProtected]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Protects a table and makes it read-only.</span>
Line 36: Line 56:


*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span>
*[[table.size]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Finds the absolute size of a table.</span>
*[[var_dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">»This function outputs information about one or more variables using outputConsole(). </span>
*[[RGBToHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a string representing the color in hexadecimal.</span>
*[[getAlivePlayersInTeam]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the alive players in a team.</span>
*[[getResourceSettings]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function returns a table of the resource settings.</span>
*[[onVehicleWeaponFire]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.</span>


*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span>
*[[toHex]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.</span>


*[[getElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get element speed in kph or mph units.</span>
*[[var_dump]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">»This function outputs information about one or more variables using outputConsole(). </span>
 
*[[setElementSpeed]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to set moving element speed in kph or mph units.</span>
 
*[[centerWindow]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function center the window in any resolution.</span>
 
*[[coroutine.resume]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» Fix for hidden coroutine error messages</span>
 
*[[getPlayerFromNamePart]] <span style="color:gray; font-family:'Georgia',sans-serif; font-size:smaller;">» This function allows you to get player From his Name part.</span>


[[Category:Useful Functions]]
[[Category:Useful Functions]]

Revision as of 22:36, 21 March 2012

  • callClientFunction » This function allows you to call any clientside function from the server's side.
  • callServerFunction » This function allows you to call any server-side function from the client's side.
  • centerWindow » This function center the window in any resolution.
  • Check » This function checks if it's arguments are of the right types and calls the error-function if one isn't.
  • doForAllElements » This function can be used to execute a specified function for all elements of a specified type.
  • dxDrawColorText » This function draws a dx text with #RRGGBB color codes support.
  • iterElements » Returns an iterator for your for loops saving time typing ipairs( getElementsByType( type ) ), instead you type: iterElements( type ).
  • findRotation » Takes two points and returns the direction from point A to point B.
  • FormatDate » Formats a date on the basis of a format string and returns it.
  • getAge » This function calculates the age of a birthday.
  • getElementSpeed » This function allows you to get element speed in kph or mph units.
  • IfElse » Returns one of two values based on a boolean expression.
  • isLeapYear » Checks if the given year is a leap year.
  • math.round » Rounds a number whereas the number of decimals to keep and the method may be set.
  • onVehicleWeaponFire » This code implements an event that is triggered when a player in a vehicle fires a vehicles weapon.
  • RGBToHex » This function returns a string representing the color in hexadecimal.
  • setElementSpeed » This function allows you to set moving element speed in kph or mph units.
  • setVehicleGravityPoint » This clientside function sets a vehicle's gravity in the direction of a 3 dimensional coordinate with the strength specified.
  • string.explode » This function splits a string at a given separator pattern and returns a table with the pieces.
  • table.copy » This function copies a whole table and all the tables in that table.
  • table.map » 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.
  • toHex » This function converts a decimal number to a hexadecimal number, as a fix to be used clientside.
  • var_dump »This function outputs information about one or more variables using outputConsole().