Fitamin4ik Posted October 27, 2015 Share Posted October 27, 2015 Здравствуйте, есть меню (клиент). Названия пунктов в меню берутся из функции getVehicleUpgradeSlotName() Названия на английском языке. Вот кусок кода, как изменить английские названия на русские? for i = 1, 17 do local upName = getVehicleUpgradeSlotName( i-1 ) -- slot 11 is "Unknown" if not shopGUI.buttons[ i ] and i ~= 12 then shopGUI.buttons[ i ] = guiCreateButton( 10, buttonHeight * btns + 5, 230, buttonHeight - 5, upName, false, shopGUI.wnd ) guiSetVisible( shopGUI.buttons[ i ], false ) btns = btns + 1 end end Link to comment
Other Languages Moderators Disinterpreter Posted October 27, 2015 Other Languages Moderators Share Posted October 27, 2015 Создай свой массив и вызывай из него. Link to comment
Fitamin4ik Posted October 27, 2015 Author Share Posted October 27, 2015 Создай свой массив и вызывай из него. Пробовал, пункты исчезают. Массив так создавал. local massiv = { "1", "2", "3", "и т.д." } И вот так использовал for i = 1, 17 do local upName = getVehicleUpgradeSlotName( i-1 ) -- slot 11 is "Unknown" if not shopGUI.buttons[ i ] and i ~= 12 then shopGUI.buttons[ i ] = guiCreateButton( 10, buttonHeight * btns + 5, 230, buttonHeight - 5, massiv[i], false, shopGUI.wnd ) guiSetVisible( shopGUI.buttons[ i ], false ) btns = btns + 1 end end Link to comment
Other Languages Moderators Disinterpreter Posted October 27, 2015 Other Languages Moderators Share Posted October 27, 2015 Создай свой массив и вызывай из него. Пробовал, пункты исчезают. Массив так создавал. local massiv = { "1", "2", "3", "и т.д." } aVehicleUpgradesRU = { "Худ", "Вент", "Спойлер" } function getVehicleUpgradeSlotNameRU(id) if (tonumber(id) and tonumber(id)<16) then return aVehicleUpgradesRU[id] else return false; end end print(getVehicleUpgradeSlotNameRU(3)) Link to comment
Fitamin4ik Posted October 27, 2015 Author Share Posted October 27, 2015 Всё равно пункты исчезают((( --[[ Mod Shop Author: 50p Version: 1.4.2 ]] local screenWidth, screenHeight = guiGetScreenSize( ) local g_root = getRootElement( ) local g_resRoot = getResourceRootElement( getThisResource( ) ) g_Me = getLocalPlayer(); local shopGUI = { buttons = { } } local upgradeGUI = { } local upgWidth = 230 local shopWidth = 170 local movingSpeed = 10 -- 10 px per frame local hideSubToo = false local hideMain = false local mainWindowIsMoving = false local shoNewSub = false local moddingVeh = nil local currUpgrades = nil local currColors = { } local tempColors = { } local shopEnteredName = nil local colorSet = { } local paintjobSet = false local upgradeChanged = { } local newUpgrades = { } aVehicleUpgradesRU = { "Капот", "Вент", "Спойлер", "Боковые юбки", "Передний кенгурятник", "Задний кенгурятник", "Фары", "Крыша", "Нитро", "Гидравлика", "Стерео", "Неизвестно", "Колёса", "Выхлоп", "Передний бампер", "Задний бампер", "Разно", } addEvent( "onClientPlayerEnterModShop", true ) addEventHandler( "onClientPlayerEnterModShop", g_root, function( vehicle, money, shopname ) if getLocalPlayer() == source then moddingVeh = vehicle hideAllButtonsInMainWnd() showUpgradeButtons() upgradeChanged = { } newUpgrades = { } -- outputChatBox( "#FFFF00Welcome to #00FF00".. shopname .." #FFFF00mod shop!", 0,0,0, true ) emptyShoppingCart( ) guiSetText( shoppingCostLbl, "0" ) shopEnteredName = shopname currColors = { getVehicleColor( vehicle ) } --outputDebugString( "Colors when you entered shop: ".. tostring( currColors[ 1 ] ) ..", "..tostring( currColors[ 2 ] ) ) tempColors[ 1 ],tempColors[ 2 ] = currColors[ 1 ], currColors[ 2 ] currUpgrades = getVehicleUpgrades( vehicle ) for k, id in ipairs( currUpgrades ) do upgradeChanged[ getVehicleUpgradeSlotName( id ) ] = false end paintjob = getVehiclePaintjob( vehicle ) showCursor( true ) hideAllButtonsInMainWnd( ) showUpgradeButtons( ) guiSetText( shopGUI.wnd, shopname ) guiSetVisible( cartWnd, true ) addEventHandler( "onClientRender", g_root, showShopWindow ) --toggleCameraFixedMode( true ) addEventHandler( "onClientRender", g_root, rotateCameraAroundPlayer ) return end end ) function getVehicleUpgradeSlotNameRU(id) if (tonumber(id) and tonumber(id)<16) then return aVehicleUpgradesRU[id] else return false; end end addEventHandler( "onClientResourceStart", g_resRoot, function( ) loadItems( ) local buttonHeight = 23 local btns = 3 cartWnd = guiCreateWindow( 5, screenHeight - 320, 120, 150, "Cart", false ) guiWindowSetSizable( cartWnd, false ) guiCreateStaticImage( 10, 20, 100, 100, "cart.png", false, cartWnd) guiCreateButton( 10, 121, 110, 19, "", false, cartWnd ) costsLbl = guiCreateLabel( 10, 121, 110, 20, " Costs: $", false, cartWnd ) shoppingCostLbl = guiCreateLabel( 10, 122, 95, 20, "0", false, cartWnd ) guiSetFont( shoppingCostLbl, "default-bold-small" ) guiLabelSetHorizontalAlign( shoppingCostLbl, "right" ) guiLabelSetColor( shoppingCostLbl, 0, 255, 0 ) guiSetVisible( cartWnd, false ) shopGUI.wnd = guiCreateWindow( screenWidth + 2, screenHeight / 2 - 200, shopWidth, 430, "", false ); guiWindowSetSizable( shopGUI.wnd, false ) guiWindowSetMovable( shopGUI.wnd, false ) guiSetAlpha( shopGUI.wnd, 0 ) colorsWnd = guiCreateWindow( screenWidth / 2 - 230, screenHeight / 2 - 270, 460, 540, "", false ) guiWindowSetSizable( colorsWnd, false ) guiSetVisible( colorsWnd, false ) guiSetText( colorsWnd, "Выбери цвет" ) colorGrid_img = guiCreateStaticImage( 10, 23, 440, 480, "vehiclecolors.png", false, colorsWnd ) bothSame_img = guiCreateStaticImage( 0, 0, 9, 9, "colorselect.png", false, colorGrid_img ) color1_img = guiCreateStaticImage( 0, 0, 9, 9, "color1.png", false, colorGrid_img ) color2_img = guiCreateStaticImage( 0, 0, 9, 9, "color2.png", false, colorGrid_img ) okBtn = guiCreateButton( 10, 512, 100, 25, "OK", false, colorsWnd ) resetBtn = guiCreateButton( 115, 512, 100, 25, "Сброс", false, colorsWnd ) cancelBtn = guiCreateButton( 220, 512, 100, 25, "Отмена", false, colorsWnd ) shopGUI.buttons = { } shopGUI.buttons[ "Color" ] = guiCreateButton( 10, 28, shopWidth, 18, "Цвет", false, shopGUI.wnd ) shopGUI.buttons[ "Paintjob" ] = guiCreateButton( 10, 51, shopWidth, 18, "Набор цветов", false, shopGUI.wnd ) shopGUI.buttons[ "Exit" ] = guiCreateButton( 10, buttonHeight * btns + 8, shopWidth, buttonHeight - 5, "Выход", false, shopGUI.wnd ) for i = 1, 17 do local upName = getVehicleUpgradeSlotName( i-1 ) -- slot 11 is "Unknown" if not shopGUI.buttons[ i ] and i ~= 12 then shopGUI.buttons[ i ] = guiCreateButton( 10, buttonHeight * btns + 5, 230, buttonHeight - 5, upName, false, shopGUI.wnd ) guiSetVisible( shopGUI.buttons[ i ], false ) btns = btns + 1 end end upgradeGUI.wnd = guiCreateWindow( screenWidth - 215, screenHeight / 2 - 150, upgWidth, 30, "", false ) guiWindowSetSizable( upgradeGUI.wnd, false ) guiWindowSetMovable( upgradeGUI.wnd, false ) guiSetText( upgradeGUI.wnd, "" ) guiSetVisible( upgradeGUI.wnd, false ) guiMoveToBack( upgradeGUI.wnd ) local _wx, _wy = guiGetPosition( shopGUI.wnd, false ) guiSetPosition( upgradeGUI.wnd, _wx, _wy, false ) upgradeGUI.gridList = { } upgradeGUI.gridList.grd = guiCreateGridList( 10, 23, upgWidth, 200, false, upgradeGUI.wnd ) guiGridListSetSortingEnabled( upgradeGUI.gridList.grd, false ) guiGridListAddColumn( upgradeGUI.gridList.grd, "Имя", 0.6 ) guiGridListAddColumn( upgradeGUI.gridList.grd, "Цена", 0.25 ) guiGridListSetSelectionMode( upgradeGUI.gridList.grd, 0 ) addEventHandler( "onClientGUIClick", shopGUI.buttons[ "Color" ], colorButtonClicked, false ) addEventHandler( "onClientGUIClick", colorGrid_img, function( btn, state, x, y ) colorGridClicked( btn, x, y ) end, false ) addEventHandler( "onClientGUIClick", getResourceRootElement( ), function( btn ) colorWndButtonClicked( btn ) end ) addEventHandler( "onClientGUIClick", shopGUI.buttons[ "Exit" ], function( btn ) exitButtonClicked( btn ) end, false ) addEventHandler( "onClientGUIDoubleClick", upgradeGUI.gridList.grd, function( btn ) gridListClicked( btn ) end, false ) end ) function colorButtonClicked( btn ) if btn == "left" then local colors = { getVehicleColor( moddingVeh ) } setColorSelection( colors[ 1 ], 1 ) setColorSelection( colors[ 2 ], 2 ) guiSetVisible( colorsWnd, true ) local rem = guiSetEnabled( shopGUI.buttons[ "Color" ], false ) elseif btn == "hide" then guiSetEnabled( shopGUI.buttons[ "Color" ], true ) for i=1, 2 do tempColors[ i ] = currColors[ i ] end setVehicleColor( moddingVeh, currColors[ 1 ], currColors[ 2 ], 0, 0 ) guiSetVisible( colorsWnd, false ) guiSetText( shoppingCostLbl, tostring( getShoppingCosts( ) ) ) end end function colorWndButtonClicked( btn ) if btn == "left" then if ( ( source == okBtn or source == cancelBtn or source == resetBtn ) and getElementParent( source ) == colorsWnd ) then if source == okBtn then guiSetEnabled( shopGUI.buttons[ "Color" ], true ) guiSetVisible( colorsWnd, false ) elseif source == cancelBtn then guiSetEnabled( shopGUI.buttons[ "Color" ], true ) setVehicleColor( moddingVeh, unpack( currColors ) ) tempColors[ 1 ], tempColors[ 2 ] = currColors[ 1 ], currColors[ 2 ] guiSetVisible( colorsWnd, false ) setColorSelection( currColors[ 1 ], 1 ) setColorSelection( currColors[ 2 ], 2 ) colorSet[ 1 ], colorSet[ 2 ] = false, false else setColorSelection( currColors[ 1 ], 1 ) setColorSelection( currColors[ 2 ], 2 ) tempColors[ 1 ], tempColors[ 2 ] = currColors[ 1 ], currColors[ 2 ] setVehicleColor( moddingVeh, unpack( currColors ) ) colorSet[ 1 ], colorSet[ 2 ] = false, false end end end end function exitButtonClicked( btn ) if btn == "left" then if guiGetVisible( colorsWnd ) then colorButtonClicked( "hide" ) end local upgrades = getVehicleUpgrades( moddingVeh ) if not table.same( upgrades, currUpgrades ) or not table.same( tempColors, currColors ) or paintjob ~= getVehiclePaintjob( moddingVeh ) then upgrades = leaveNewUpgrades( upgrades, currUpgrades ) local newClrs = { unpack( currColors ) } if not table.same( tempColors, currColors ) then for i=1, 2 do if tempColors[ i ] ~= currColors[ i ] then newClrs[ i ] = tempColors[ i ] 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