hennesy Posted August 14, 2017 Share Posted August 14, 2017 Здравствуйте, суть проблемы,при работе бензина со спидометром,почему то,нет именно такого меню,подскажите или направьте,где может быть ошибка и связано ли это,со спидометром на бензин который я скачал,тогда,как адаптировать спидометр,что указать и еще без спидометра,автозаправки вообще не работают на сервере Quote local fuelWindow = {}; for k,v in pairs(fuelMarkers) do local marker = createMarker(v[1],v[2],v[3],"corona",3,200,100,0,150) setElementData(marker,"fuelstation",true) end addEventHandler ( "onClientMarkerHit", getRootElement(), function(ply) if ply == localPlayer then if getElementData(source,"fuelstation") then local veh = getPedOccupiedVehicle(ply) if veh and getVehicleController(veh) == ply then initFuelWindow() end end end end) function initFuelWindow() local veh = getPedOccupiedVehicle(localPlayer) if isElement(fuelWindow) then if veh then setElementFrozen(veh,false) end showCursor(false) destroyElement(fuelWindow) else if veh then setElementFrozen(veh,true) showCursor(true) fuelWindow = guiCreateWindow(0.4,0.3,0.2,0.3,"Заправка",true) local btn = {} local labels = {} local fuelData = getVehicleFuelInfo(getElementModel(veh)) local currentFuel = nil local currentAmount = getElementData(veh,"fuel") local fillAmount = 0 btn[1] = guiCreateButton(0.05,0.1,0.2,0.1,fuelTypes[1][1],true,fuelWindow) btn[2] = guiCreateButton(0.05,0.25,0.2,0.1,fuelTypes[2][1],true,fuelWindow) btn[3] = guiCreateButton(0.05,0.4,0.2,0.1,fuelTypes[3][1],true,fuelWindow) btn[4] = guiCreateButton(0.05,0.55,0.2,0.1,fuelTypes[4][1],true,fuelWindow) btn[5] = guiCreateButton(0.75,0.1,0.2,0.1,fuelTypes[5][1],true,fuelWindow) btn[6] = guiCreateButton(0.75,0.25,0.2,0.1,fuelTypes[6][1],true,fuelWindow) btn[7] = guiCreateButton(0.75,0.4,0.2,0.1,fuelTypes[7][1],true,fuelWindow) btn[8] = guiCreateButton(0.75,0.55,0.2,0.1,fuelTypes[8][1],true,fuelWindow) labels[1] = guiCreateLabel(0.3,0.1,0.3,0.1,fuelTypes[1][2].." руб.",true,fuelWindow) labels[2] = guiCreateLabel(0.3,0.25,0.3,0.1,fuelTypes[2][2].." руб.",true,fuelWindow) labels[3] = guiCreateLabel(0.3,0.4,0.3,0.1,fuelTypes[3][2].." руб.",true,fuelWindow) labels[4] = guiCreateLabel(0.3,0.55,0.3,0.1,fuelTypes[4][2].." руб.",true,fuelWindow) labels[5] = guiCreateLabel(0.42,0.1,0.3,0.1,fuelTypes[5][2].." руб.",true,fuelWindow) labels[6] = guiCreateLabel(0.42,0.25,0.3,0.1,fuelTypes[6][2].." руб.",true,fuelWindow) labels[7] = guiCreateLabel(0.42,0.4,0.3,0.1,fuelTypes[7][2].." руб.",true,fuelWindow) labels[8] = guiCreateLabel(0.42,0.55,0.3,0.1,fuelTypes[8][2].." руб.",true,fuelWindow) local scroll = guiCreateScrollBar(0.1,0.7,0.8,0.07,true,true,fuelWindow) local btnCancel = guiCreateButton(0.05,0.85,0.3,0.1,"Отмена",true,fuelWindow) local btnFill = guiCreateButton(0.65,0.85,0.3,0.1,"Заправить",true,fuelWindow) for k,v in pairs(labels) do guiLabelSetVerticalAlign( v, "center" ) if k > 4 then guiLabelSetHorizontalAlign( v, "right") end end for k,v in pairs(btn) do guiSetEnabled(v,false) for key,val in pairs(fuelData[3]) do if val == k then if not currentFuel then currentFuel = k end guiSetEnabled(v,true) end end end local amountLabel = guiCreateLabel(0.2,0.78,0.6,0.1,fillAmount.." л. ("..fuelTypes[currentFuel][1]..")\n0 руб",true,fuelWindow) guiLabelSetHorizontalAlign( amountLabel, "center" ) addEventHandler("onClientGUIScroll",scroll,function() local n = guiScrollBarGetScrollPosition( scroll )*0.01 fillAmount = math.floor((fuelData[1]-currentAmount)*n) guiSetText(amountLabel,fillAmount.." л. ("..fuelTypes[currentFuel][1]..")\n"..fillAmount*fuelTypes[currentFuel][2].." руб") if getPlayerMoney(localPlayer) < fillAmount*fuelTypes[currentFuel][2] or fillAmount == 0 then guiSetEnabled(btnFill,false) else guiSetEnabled(btnFill,true) end end) addEventHandler("onClientGUIClick",fuelWindow,function() for k,v in pairs(btn) do if v == source then currentFuel = k guiSetText(amountLabel,fillAmount.." л. ("..fuelTypes[currentFuel][1]..")\n"..fillAmount*fuelTypes[currentFuel][2].." руб") end end if source == btnCancel then initFuelWindow() elseif source == btnFill then triggerServerEvent("fillVeh2",localPlayer,veh,currentFuel,fillAmount) initFuelWindow() end end) end end end --initFuelWindow() function checkFuel() local veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then if not getElementData(veh,"fuel") then return end if getElementData(veh,"fuel") <= 1 then setVehicleEngineState(veh,false) end end end addEventHandler('onClientPreRender',root,checkFuel) Link to comment
CharlySHOMAN Posted August 15, 2017 Share Posted August 15, 2017 Слабо понял, в чем проблема (потому что объяснять надо понятнее). 1. По поводу менюшки - я попробовал у себя запустить, у меня запустилось. Ты должен обязательно на авто подъехать к маркеру. 2. Про какой спидометр речь идёт - я не понял. Скорее всего у тебя это не работает, потому что как-то конфликтует с другими скриптами. Попробуй посмотреть отладку ( \MTA San Andreas 1.5\MTA\logs\clientscript.txt ). И ещё не понятно, откуда берется таблица fuelMarkers (может у тебя этой таблицы нет, проверь). 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