GetLocalization

From Multi Theft Auto: Wiki
Revision as of 18:29, 29 April 2014 by Miki785 (talk | contribs) (Created page with "{{Client function}} __NOTOC__ {{New items|4.0132|1.4| This function gets the player's localization setting as he/she has set in his/her MTA client. }} ==Syntax== <syntaxhighlight lang="lua"> t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

ADDED/UPDATED IN VERSION 1.4 :

This function gets the player's localization setting as he/she has set in his/her MTA client.

Syntax

table getLocalization ( )

Returns

Returns a table with the following entries:

  • code : The language code (eg. "en_US" for "English (United States)" or "ar" for "Arabic").
  • name : The name of the language (eg. "English (United States)" or "Arabic").

Example

This example outputs simple Welcome message at the resource start (also when player joins the game if the resource is already running).

local msg = {cs = "Vítejte", fr = "Accueil", de = "Willkommen", pl = "Powitanie"}

addEventHandler("onClientResourceStart", resourceRoot, 
	function ()
		local languageCode = getLocalization()["code"]
		if msg[languageCode] then --Check if the message is avaible in client's language
			outputChatBox(msg[languageCode] .. "!") --Output it
		else
			outputChatBox("Welcome!") --Output English for any other language
		end
	end)

See Also