Volltron Posted June 15, 2016 Share Posted June 15, 2016 Hello guys ! Can someone help me with this script ? It is supposed to change the shop gui text to the chosen language but it only displays the english language local languageCode = getLocalization()["code"] function checkTheLanguage() if languageCode == "en_US" then languageCode = "en_US" elseif languageCode == "ro" then languageCode = "ro" else languageCode = "en_US" end end addEventHandler("onClientResourceStart",root,checkTheLanguage) local languageTable = { {"en","en_US"}, {"ro","ro"}, } function changeLanguageOnCommand(playerSource,language) if language then for i, lang in ipairs(languageTable) do if language == lang[1] then languageCode = lang[2] outputChatBox("New language: "..tostring(languageCode),0,255,0) end end else outputChatBox("Possible values for language: en, ro.",255,0,0) end end addCommandHandler("language",changeLanguageOnCommand) GUIEditor = { tab = {}, window = {}, tabpanel = {}, button = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(0.34, 0.32, 0.36, 0.49, "SHOP", true) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(0.01, 0.08, 0.97, 0.90, true, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab(LangTextTable[languageCode][1], GUIEditor.tabpanel[1]) GUIEditor.button[1] = guiCreateButton(0.06, 0.17, 0.10, 0.05, "xxx$", true, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab(LangTextTable[languageCode][2], GUIEditor.tabpanel[1]) GUIEditor.button[2] = guiCreateButton(0.89, 0.04, 0.09, 0.05, "Close", true, GUIEditor.window[1]) end ) addEventHandler ( "onClientGUIClick", getResourceRootElement(getThisResource()), function ( ) if (source == GUIEditor.button[2]) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end ) function shopwindow() guiSetVisible(GUIEditor.window[1], true) showCursor(true) end addCommandHandler("shop", shopwindow) addEvent("openShop",true) addEventHandler("openShop", getRootElement(), shopwindow) LangTextTable = { ["en_US"] = { "Medicine", "Weapons", }, ["ro"] = { "Medicina", "Arme", }, } Link to comment
ozulus Posted June 16, 2016 Share Posted June 16, 2016 (edited) I think it's better than yours. Check this out UPDATED local languageCode = getLocalization()["code"] function checkTheLanguage() if languageCode then if not LangTextTable[languageCode] then languageCode = "en_US" end end end addEventHandler("onClientResourceStart",root,checkTheLanguage) Edited June 16, 2016 by Guest Link to comment
Volltron Posted June 16, 2016 Author Share Posted June 16, 2016 Nope , it won't display the gui text now Link to comment
ozulus Posted June 16, 2016 Share Posted June 16, 2016 Just move local languageCode = getLocalization()["code"] out of the function. I have updated my code. Try that Link to comment
Volltron Posted June 17, 2016 Author Share Posted June 17, 2016 I did that and still showing english text when changing language Link to comment
Simple0x47 Posted June 17, 2016 Share Posted June 17, 2016 Post it on Romanian Section there I can give you some support In Romanian. Link to comment
Volltron Posted June 17, 2016 Author Share Posted June 17, 2016 The script itself actually works by changing the mta language but the language change command doesn't Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now