Jump to content

Fitamin4ik

Members
  • Posts

    7
  • Joined

  • Last visited

Fitamin4ik's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. Всем привет, помогите пожалуйста. Есть скрипт голода local lp = getLocalPlayer() local screenwidth,screenheight = guiGetScreenSize() local foodBarX = math.floor(screenwidth / 1.1707) - 1 local foodBarY = math.floor(screenheight / 6.6666) - 1 local foodBarWidth = math.floor(screenwidth / 10.37) local foodBarHeight = math.floor(screenheight / 51.42) local foodBarY = foodBarY - 0.02962962962963 * screenheight / 2 - foodBarHeight / 2 local showingFoodBar = false function showHungerBar() if tonumber ( getElementData ( lp, "LoggedIn" ) ) == 1 and not isCursorShowing () then if not showingFoodBar then addEventHandler ( "onClientRender", getRootElement(), drawFoodBar ) showingFoodBar = true end end end addEventHandler("onClientPlayerSpawn",getRootElement(),function () showHungerBar() end) function drawFoodBar() if isPedDead(lp) == false then local x, y, width, height = foodBarX, foodBarY, foodBarWidth, foodBarHeight local hunger = getHungerState(lp) / 100 local spaceBarSize = screenwidth / ( 1920 / 5 ) local hungerWidth = ( width - spaceBarSize * 2 ) * hunger hungerWidth = spaceBarSize + hungerWidth dxDrawImage ( x, y, width, height, "images/hunger_empty.png", 0, 0, 0, nil, true ) dxDrawImageSection ( x-1, y-1, hungerWidth, height, 1, 1, hungerWidth, height, "images/hunger_full.png", 0, 0, 0, nil, true ) end end function hungerDeathFix () if source == lp then setHungerState(lp, 40) end end addEventHandler ( "onClientPlayerWasted", getRootElement(), hungerDeathFix ) function hideHungerBar() if showingFoodBar then removeEventHandler ( "onClientRender", getRootElement(), drawFoodBar ) showingFoodBar = false end end function moreHunger() local curhunger = getHungerState(lp) - 1 if curhunger < 0 then curhunger = 0 end setHungerState ( lp, curhunger ) drawFoodBar() if curhunger == 33 then outputChatBox ( "Вам необходимо поесть!", 125, 0, 0 ) elseif curhunger < 25 then local loss = math.floor((25-curhunger)/2*20)/10 setHungerState(lp, getHungerState(lp) - loss) end showHungerBar() end setTimer ( moreHunger, 50000, -1 ) function getHungerState(player) if (player == lp) then return tonumber(getElementData(player, "Hunger")) end end function setHungerState(player, value) setElementData(player, "Hunger", getHungerState(player)+value) if getHungerState(player) > 100 then setElementData(player, "Hunger", 100) end showHungerBar() end Всё работает нормально, начинает работать только после удачной авторизации и через 50 секунд (setTimer). Как сделать так, чтобы изображения появились сразу после входа (onPlayerLogin) ? Не могу понять...
  2. Всё равно пункты исчезают((( --[[ 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 ]
  3. Пробовал, пункты исчезают. Массив так создавал. 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
  4. Здравствуйте, есть меню (клиент). Названия пунктов в меню берутся из функции 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
  5. Спасибо ребят, подскажите еще, как исправить это? [2015-05-10 17:34:33] WARNING: brpExports/s_exports.lua:100: Bad argument @ 'getElementData' [Expected element at argument 1, got boolean] [2015-05-10 17:34:33] WARNING: brpExports/s_exports.lua:100: Bad argument @ 'getElementData' [Expected element at argument 1, got boolean] function doesPlayerOwnVehicle(vehicle, player) return getElementData(vehicle, "vehicle.owner") == getElementData(player, "accountname") end
  6. Ребят, беда, помогите пожалуйста. Ошибки в консоле, как исправить? Код:
×
×
  • Create New...