GetVersion: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 24: Line 24:


==Example==  
==Example==  
'''Example 1:''' This example will make a script compatible only with version 1.0:
{{Needs Example}}
<section name="Server" class="server" show="true">
<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>
</section>
 
'''Example 2:''' This client example will print out the version of the MTA client.
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
addCommandHandler("myver", function()
  outputChatBox("My MTA version: " .. getVersion().sortable)
end)
</syntaxhighlight>
</section>


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

Latest revision as of 13:59, 19 November 2024

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

[[{{{image}}}|link=|]] Note: Clientside will return the version from the player, and the server-sided will return version from the server.
[[{{{image}}}|link=|]] Note: Current MTA version:

mta -> 1.6
netcode -> 474
number -> 352
sortable -> 1.6.0-9.22279.0
tag -> 1.6-release-22279
type -> Release

Syntax

table getVersion ( )

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, e.g. "256"
  • mta: the MTA server or client version (depending where the function was called) in textual form, e.g. "1.0"
  • name: the full MTA product name, either "MTA:SA Server" or "MTA:SA Client".
  • netcode: the netcode version number.
  • os: returns the operating system on which the server or client is running
  • type: the type of build. can be:
    • "Nightly rX" - A nightly development build. X represents the nightly build revision.
    • "Custom" - A build compiled manually
    • "Release" - A build that is publicly released (provisional).
  • tag: the build tag (from 1.0.3 onwards). Contains infomation about the underlying version used. i.e. The final version of 1.0.3 has the build tag of "1.0.3 rc-9". (This can be confirmed by using the console command 'ver'.)
  • sortable: a 15 character sortable version string (from 1.0.4 onwards). Format of the string is described in getPlayerVersion.

Example

Accessories-text-editor.png Script Example Missing Function GetVersion needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.


See Also