GetVersion: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ {{Server client function}} This function gives you various version information about MTA and the operating system. ==Syntax== <syntaxhighlight lang="lua">table getVersion ( )</syntaxhighlight> ===Require...)
 
No edit summary
Line 17: Line 17:
*'''netcode:''' the netcode version number.
*'''netcode:''' the netcode version number.
*'''os:''' can be "Windows", "Linux", "FreeBSD" or "OpenBSD".
*'''os:''' can be "Windows", "Linux", "FreeBSD" or "OpenBSD".
==Example==
This example will make a script compatible with both DP2.3 and 1.0 versions:
<syntaxhighlight lang="lua">
function setHoboSkin ( playerSource )
  local version = getVersion ( )
  if version.number < 256 then -- MTA 1.0 version number is 0x0100
    setPlayerSkin ( playerSource, 137 )
  else
    setElementModel ( playerSource, 137 )
  end
end
addCommandHandler ( "hobo", setHoboSkin )
</syntaxhighlight>


==See Also==
==See Also==
{{Server functions}}
{{Server functions}}

Revision as of 13:38, 7 March 2009

This function gives you various version information about MTA and the operating system.

Syntax

table getVersion ( )

Required Arguments

None.

Returns

Returns a table with version information. Specifically these keys are present in the table:

  • number: the MTA server or client version (depending where the function was called) in pure numerical form.
  • mta: the MTA server or client version in textual form.
  • name: the full MTA product name.
  • netcode: the netcode version number.
  • os: can be "Windows", "Linux", "FreeBSD" or "OpenBSD".


Example

This example will make a script compatible with both DP2.3 and 1.0 versions:

function setHoboSkin ( playerSource )
  local version = getVersion ( )
  if version.number < 256 then -- MTA 1.0 version number is 0x0100
    setPlayerSkin ( playerSource, 137 )
  else
    setElementModel ( playerSource, 137 )
  end
end
addCommandHandler ( "hobo", setHoboSkin )


See Also