Matevsz Posted December 4, 2015 Share Posted December 4, 2015 Hello, I have a problem when I'm in the car I have it on the counter 120 km / h, even when you do not go. When I go quickly this tip comes after a counter (max 260). Screenshot: Code: [code] g_root = getRootElement() g_rootElement = getResourceRootElement( getThisResource() ) g_Player = getLocalPlayer() c_EnableScaling = true c_XOffset = 10 c_YOffset = 10 c_ImageW = 200 c_ImageH = 200 c_BarW = 0 c_BarH = 0 c_BarYOffset = 70 c_FireTimeMs = 5000 c_BarAlpha = 120 c_BarFlashInterval = 300 g_tFireStart = nil function drawNeedle() if not isPedInVehicle(g_Player) then hideSpeedometer() end local vehSpeed = getVehicleSpeed() if vehHealth and (vehHealth > 0) then local hp = (vehHealth-250)/750 local curBarLen = hp*g_BarW if curBarLen < 1 then curBarLen = 1 end local r = 255*(1 - hp)/0.5 if r > 255 then r = 255 end local g = 255*hp/0.5 if g > 255 then g = 255 end if g < 0 then g = 0 end if hp >= 0 then g_tFireStart = nil dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, curBarLen, g_BarH, tocolor(r, g, 0, c_BarAlpha)) else if not g_tFireStart then g_tFireStart = getTickCount() end local firePerc = (c_FireTimeMs - (getTickCount() - g_tFireStart)) / c_FireTimeMs if firePerc < 0 then firePerc = 0 end local a = c_BarAlpha if (getTickCount()/c_BarFlashInterval)%2 > 1 then a = 0 end dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, firePerc*g_BarW, g_BarH, tocolor(255, 0, 0, a)) end end dxDrawImage(x, y, g_ImageW, g_ImageH, "needle.png", vehSpeed, 0, 0, white, true) end function showSpeedometer() guiSetVisible(disc, true) addEventHandler("onClientRender", g_root, drawNeedle) end function hideSpeedometer() guiSetVisible( disc, false) removeEventHandler("onClientRender", g_root, drawNeedle) end function getVehicleSpeed() if isPedInVehicle(g_Player) then local vx, vy, vz = getElementVelocity(getPedOccupiedVehicle(g_Player)) return math.sqrt(vx^2 + vy^2 + vz^2) * 161 end return 0 end addEventHandler("onClientVehicleEnter", g_root, function(thePlayer) if thePlayer == g_Player then showSpeedometer() end end ) addEventHandler("onClientVehicleStartExit", g_root, function(thePlayer) if thePlayer == g_Player then hideSpeedometer() end end ) function round(num) return math.floor(num + 0.3) end function initGui() if disc then destroyElement(disc) end g_screenWidth, g_screenHeight = guiGetScreenSize() local scale if c_EnableScaling then scale = (g_screenWidth/1000 + g_screenHeight/850)/2 else scale = 1 end g_XOffset = round(c_XOffset*scale) g_YOffset = round(c_YOffset*scale) g_ImageW = round(c_ImageW*scale) g_ImageH = round(c_ImageH*scale) g_BarW = round(c_BarW*scale) g_BarH = round(c_BarH*scale) g_BarYOffset = round(c_BarYOffset*scale) disc = guiCreateStaticImage(g_screenWidth - g_ImageW - g_XOffset, g_screenHeight - g_ImageH - g_YOffset, g_ImageW, g_ImageH, "disc.png", false) x, y = guiGetPosition(disc, false) end addEventHandler("onClientResourceStart", g_rootElement, function () initGui() guiSetVisible(disc, false) setTimer(function() local w, h = guiGetScreenSize() if (w ~= g_screenWidth) or (h ~= g_screenHeight) then initGui() end end, 500, 0) if isPedInVehicle(g_Player) then showSpeedometer() end end ) [/code] Link to comment
.:HyPeX:. Posted December 4, 2015 Share Posted December 4, 2015 Depends on the image, If the image is vertical by default, then on a rotation (speed) 0 it will be on the 120. I'm not sure whats the correct rotation on that image of your speedo, you'll need to play with it (I randomized 120degrees). Try adjusting it g_root = getRootElement() g_rootElement = getResourceRootElement( getThisResource() ) g_Player = getLocalPlayer() c_EnableScaling = true c_XOffset = 10 c_YOffset = 10 c_ImageW = 200 c_ImageH = 200 c_BarW = 0 c_BarH = 0 c_BarYOffset = 70 c_FireTimeMs = 5000 c_BarAlpha = 120 c_BarFlashInterval = 300 g_tFireStart = nil function drawNeedle() if not isPedInVehicle(g_Player) then hideSpeedometer() end local vehSpeed = getVehicleSpeed() if vehHealth and (vehHealth > 0) then local hp = (vehHealth-250)/750 local curBarLen = hp*g_BarW if curBarLen < 1 then curBarLen = 1 end local r = 255*(1 - hp)/0.5 if r > 255 then r = 255 end local g = 255*hp/0.5 if g > 255 then g = 255 end if g < 0 then g = 0 end if hp >= 0 then g_tFireStart = nil dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, curBarLen, g_BarH, tocolor(r, g, 0, c_BarAlpha)) else if not g_tFireStart then g_tFireStart = getTickCount() end local firePerc = (c_FireTimeMs - (getTickCount() - g_tFireStart)) / c_FireTimeMs if firePerc < 0 then firePerc = 0 end local a = c_BarAlpha if (getTickCount()/c_BarFlashInterval)%2 > 1 then a = 0 end dxDrawRectangle(x + g_ImageW/2 - g_BarW/2, y + g_BarYOffset, firePerc*g_BarW, g_BarH, tocolor(255, 0, 0, a)) end end dxDrawImage(x, y, g_ImageW, g_ImageH, "needle.png", vehSpeed -120, 0, 0, white, true) end function showSpeedometer() guiSetVisible(disc, true) addEventHandler("onClientRender", g_root, drawNeedle) end function hideSpeedometer() guiSetVisible( disc, false) removeEventHandler("onClientRender", g_root, drawNeedle) end function getVehicleSpeed() if isPedInVehicle(g_Player) then local vx, vy, vz = getElementVelocity(getPedOccupiedVehicle(g_Player)) return math.sqrt(vx^2 + vy^2 + vz^2) * 161 end return 0 end addEventHandler("onClientVehicleEnter", g_root, function(thePlayer) if thePlayer == g_Player then showSpeedometer() end end ) addEventHandler("onClientVehicleStartExit", g_root, function(thePlayer) if thePlayer == g_Player then hideSpeedometer() end end ) function round(num) return math.floor(num + 0.3) end function initGui() if disc then destroyElement(disc) end g_screenWidth, g_screenHeight = guiGetScreenSize() local scale if c_EnableScaling then scale = (g_screenWidth/1000 + g_screenHeight/850)/2 else scale = 1 end g_XOffset = round(c_XOffset*scale) g_YOffset = round(c_YOffset*scale) g_ImageW = round(c_ImageW*scale) g_ImageH = round(c_ImageH*scale) g_BarW = round(c_BarW*scale) g_BarH = round(c_BarH*scale) g_BarYOffset = round(c_BarYOffset*scale) disc = guiCreateStaticImage(g_screenWidth - g_ImageW - g_XOffset, g_screenHeight - g_ImageH - g_YOffset, g_ImageW, g_ImageH, "disc.png", false) x, y = guiGetPosition(disc, false) end addEventHandler("onClientResourceStart", g_rootElement, function () initGui() guiSetVisible(disc, false) setTimer(function() local w, h = guiGetScreenSize() if (w ~= g_screenWidth) or (h ~= g_screenHeight) then initGui() end end, 500, 0) if isPedInVehicle(g_Player) then showSpeedometer() end end ) Link to comment
Matevsz Posted December 4, 2015 Author Share Posted December 4, 2015 It is better so, only as I stand in a place that speed is 10 km / h Ok.. -130 its cool. Thanks Tell me why as I switch radio stations in my car are those of ordinary radios a subtitles but Internet radio is without subtitles Sorry for bad english [code] local textRadio = "" local currentRadio = "" local currentIndex = 1 local lastGTAChannel = 0 local localPlayer = getLocalPlayer() local sx,sy = guiGetScreenSize () local loltimer = nil local templol = false local radios = {"Radio wylaczone", "Radio Eska Warszawa", "Radio Viva", "Radio Dj Top 50", "Radio Hardstyle", "Radio Polski Hip-Hop ", "Radio Reggae", "Radio Music Party", "Radio Chillout", "Radio RMF FM", "Radio Disco Polo", "Radio Fresh Remix", "Radio Party", "Radio RMF MAXX", } local radioPaths = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, "http://www.radio.pionier.net.pl/stream.pls?radio=eskawarszawamp3", -- eska warszawa "http://static.gaduradio.pl/64.m3u", -- viva "http://polskastacja.pl/play/aac_djtop50.pls", -- dj top 50 "http://listen.di.fm/public3/hardstyle.pls", -- hardstyle "http://www.polskastacja.pl/play/aac_hiphop.pls", -- polski hip-hop "http://www.partyvibe.com:8000/listen.pls", -- reggae "http://4stream.pl:18124/", -- music party "http://85.25.86.69:8100/", -- Radio Chillout "http://217.74.72.11:8000/rmf_fm", -- Radio RMF FM "http://178.32.161.114:9100", -- Radio Disco Polo "http://4stream.pl:18206/listen.pls", -- Radio Fresh Remix "http://www.radioparty.pl:8010/listen.pls", -- Radio Party "http://www.miastomuzyki.pl/n/rmfmaxxx.pls", -- RMF MAXX } local playRadioThing = nil function resetTimer () textRadio = "" end addEventHandler("onClientResourceStart",getResourceRootElement(), function() outputChatBox ("") showPlayerHudComponent ("radio",false) setRadioChannel (0) bindKey ("radio_next","down", function(key,state) local nextIndex = ((currentIndex)%(#radioPaths)) +1 currentIndex = nextIndex local radio = radioPaths[nextIndex] textRadio = radios[nextIndex] if loltimer and isTimer (loltimer) then killTimer (loltimer) end loltimer = setTimer (resetTimer,1000,1) if type (radio) == "number" then setRadioChannel (radio) if playRadioThing then stopSound (playRadioThing) end else setRadioChannel (0) if playRadioThing then stopSound (playRadioThing) end playRadioThing = playSound (radio) end end ) bindKey ("radio_previous","down", -- radio_previous , cofanie kanału function(key,state) local nextIndex = ((currentIndex -2)%(#radioPaths)) +1 currentIndex = nextIndex local radio = radioPaths[nextIndex] textRadio = radios[nextIndex] if loltimer and isTimer (loltimer) then killTimer (loltimer) end loltimer = setTimer (resetTimer,1000,1) if type (radio) == "number" then setRadioChannel (radio) if playRadioThing then stopSound (playRadioThing) end else setRadioChannel (0) if playRadioThing then stopSound (playRadioThing) end playRadioThing = playSound (radio) end end ) end) addEventHandler ("onClientVehicleStartExit",getRootElement(), function(player) if localPlayer == player then if playRadioThing then stopSound (playRadioThing) end setRadioChannel (0) textRadio = "" end end) addEventHandler ("onClientVehicleExit",getRootElement(), function(player) if localPlayer == player then if playRadioThing then stopSound (playRadioThing) end setRadioChannel (0) textRadio = "" end end) function renderRadio () dxDrawText (textRadio,0,0,sx,96,-922761116,2,"sans","center","center",false,false,true) end addEventHandler ("onClientRender",getRootElement(),renderRadio) addEventHandler ("onClientVehicleEnter",getRootElement(), function(player) if localPlayer == player then local radio = radioPaths[currentIndex] textRadio = radios[currentIndex] if loltimer and isTimer (loltimer) then killTimer (loltimer) end loltimer = setTimer (resetTimer,1000,1) if type (radio) == "number" then setRadioChannel (radio) if playRadioThing then stopSound (playRadioThing) end else setRadioChannel (0) if playRadioThing then stopSound (playRadioThing) end playRadioThing = playSound (radio) end end end) _setRadioChannel = setRadioChannel function setRadioChannel (index) templol = true _setRadioChannel (index) end addEventHandler ("onClientPlayerRadioSwitch",getRootElement(), function() if templol == true then if not isPedInVehicle (localPlayer) then setRadioChannel (0) end templol = false else cancelEvent (true) if not isPedInVehicle (localPlayer) then setRadioChannel (0) end end end) addEventHandler("onClientElementDestroy",getRootElement(), function() if source and getElementType (source) == "vehicle" then if source == getPedOccupiedVehicle (localPlayer) then if playRadioThing then stopSound (playRadioThing) end setRadioChannel (0) textRadio = "" end end end) addEventHandler("onClientVehicleExplode",getRootElement(), function() if source and getElementType (source) == "vehicle" then if source == getPedOccupiedVehicle (localPlayer) then if playRadioThing then stopSound (playRadioThing) end setRadioChannel (0) textRadio = "" end end end) function scroll (key, keystate) if canUse == true then if isTimer (scrollTimer) == false then scrollTimer = setTimer ( function () scrollTimer = nil end ,scrollLimit,1 ) if key == "radio_next" or key == "mouse_wheel_up" then -- scroll forwards setRadioStation ("next") elseif key == "radio_previous" or key == "mouse_wheel_down" then -- scroll backwards setRadioStation ("back") end else exSetRadioChannel (lastGTAChannel) end end end bindKey ("radio_next", "both", scroll) bindKey ("radio_previous", "both", scroll) function setRadioStation (st) if (usedStationsCount==0) then if tonumber(st) and st==0 then end end if tonumber(st) then if currentStation then stopSound (currentStation) end if st >= usedStationsCount then currentStationID = usedStationsCount else currentStationID = st end if st == 0 then exSetRadioChannel (0) currentStation = nil stName = "Radio off" stType = 0 else stName = stationsNames[usedStations[currentStationID]] stType = tonumber(stationType[stName]) if stName then if stType == 0 then currentStation = Link to comment
.:HyPeX:. Posted December 4, 2015 Share Posted December 4, 2015 The code is quite big and i cant find any errors overhead, could you try to explain better what the issue is so i know what i'm looking for? Link to comment
raynner Posted December 4, 2015 Share Posted December 4, 2015 It is better so, only as I stand in a place that speed is 10 km / hOk.. -130 its cool. Thanks Tell me why as I switch radio stations in my car are those of ordinary radios a subtitles but Internet radio is without subtitles Sorry for bad english How to push the "R" is music to the station but you do not see the subtitles, but as you can see already subtitle it is goes normal music of Grand Theft Auto: San Andreas Friend'll give you a tip that a friend gave me not use the 3D radio script this community for them this full of bugs and also this Bugando other scripts I was working in jobs of scripts it was finalized more to turn on the radio pressing "R" it did happen in a way that you have had to done the job Link to comment
Matevsz Posted December 4, 2015 Author Share Posted December 4, 2015 I push the "R" and flies music from the radio, but i can not see the subtitles up later continue to push the "R" is flying a normal radio with San Andreas and i see the subtitles and should be the other way around Sorry for english Link to comment
Matevsz Posted December 6, 2015 Author Share Posted December 6, 2015 And as usual stations to remove from the normal game Gta San Andreas in MTA?? Then maybe see subtitles for internet radio stations? 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