FuriouZ Posted January 19, 2013 Share Posted January 19, 2013 Hey! I have problem,that if i play server in 800x600 resolution then all is fine. but if i play 1366x768 then speedometer,clock and healthbar isn't in right place. Help as fast as you can please ,thank you! Code: speedomeeter: function speed ( ) addEventHandler ( "onClientRender", root, getspeed ) end addEventHandler ("onClientVehicleEnter", root, speed) function wylacz ( ) removeEventHandler ( "onClientRender", root, getspeed ) end addEventHandler("onClientVehicleExit", root, wylacz) function hud ( ) if isPedInVehicle (localPlayer) == false then return end sx, sy, sz = getElementVelocity (getPedOccupiedVehicle(localPlayer)) kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180) dxDrawText(""..tostring(kmhs).."",10,540,758,364.0,tocolor(255,255,255,255),0.9,Digital,"right","top",false,false,false) dxDrawText ( "km/h",760,549,296.0,364.0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false) end addEventHandler("onClientRender",getRootElement(),hud) clock: addEventHandler("onClientRender",root, function() local hours = getRealTime().hour local minutes = getRealTime().minute dxDrawText(hours..":"..minutes,28,560,10,10,tocolor(255,255,255,255),0.5,Digital) end ) 800x600px 1366x768px Link to comment
GTX Posted January 19, 2013 Share Posted January 19, 2013 guiGetScreenSize -- Check out: Using guiGetScreenSize to fit GUI & DX drawing in all resolutions Link to comment
FuriouZ Posted January 19, 2013 Author Share Posted January 19, 2013 guiGetScreenSize -- Check out: Using guiGetScreenSize to fit GUI & DX drawing in all resolutions Explain more please I'm not very good scripter,just started it Link to comment
GTX Posted January 19, 2013 Share Posted January 19, 2013 All you have to do is calculate positions: Clock: 28/800 = 0.035 560/600 = 0.933 10/800 = 0.0125 10/600 = 0.0166 local x, y = guiGetScreenSize() dxDrawText(hours..":"..minutes,x*0.035,y*0.933,x*0.0125,y*0.0166,tocolor(255,255,255,255),0.5,Digital) Do the same for others. Link to comment
FuriouZ Posted January 19, 2013 Author Share Posted January 19, 2013 All you have to do is calculate positions:Clock: 28/800 = 0.035 560/600 = 0.933 10/800 = 0.0125 10/600 = 0.0166 local x, y = guiGetScreenSize() dxDrawText(hours..":"..minutes,x*0.035,y*0.933,x*0.0125,y*0.0166,tocolor(255,255,255,255),0.5,Digital) Do the same for others. Thank you wery much !! i got it working 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