Jump to content

PLZ HELP, I'm resolution noob


Slim

Recommended Posts

The resolution for everything is offset unless I turn it up all the way.
I dunno if the fix would b a complicated code or not, but if anybody can provide the small edit or helpful explanation I can re position everything myself

sX,sY = guiGetScreenSize()
function dxDrawLinedRectangle(posX,posY, sizeX,sizeY, color)
 dxDrawLine(posX,posY, posX,posY+sizeY, color) -- Izquierda
 dxDrawLine(posX,posY, posX+sizeX,posY, color) -- Arriba
 
 dxDrawLine(posX+sizeX,posY, posX+sizeX,posY+sizeY, color) -- Derecha
 dxDrawLine(posX,posY+sizeY, posX+sizeX,posY+sizeY, color) -- Abajo
end



function calculateScale()
	if sX <= 800 and sY <=600 then
		return 0.25
	elseif sX<=1024 and sY <=768 then
		return 0.3
	elseif sX<=1280 and sY <=720 then
		return 0.35
	elseif sX<=1400 and sY <=900 then
		return 0.4
	elseif sX<=1650 and sY <=1000 then
		return 0.45
	else 
		return 0.5
	end
end

scale = calculateScale()



raceInterface = {
	font = false,
	fontScale = 0,
	mapname = "",
	nextmap = "",
	fps = 0,
	spectators = 0,
	alpha = 0,
	tick = 0,
	state = false,
	positionX = sX,
	colors = {255,0,0},
	timeleft = "0:00:00",
	timepassed = "0:00:00",
	mapInfo = {
		tick = 0,
		state = true,
		positionX = sX,
		timer = false,
	}
}



function renderMapinfoInterface()
	if getElementData(localPlayer,"loginState") then return end
	local tick = getTickCount() - raceInterface.mapInfo.tick
	local progress = math.min(tick/500,1)
	if raceInterface.mapInfo.state then
		raceInterface.mapInfo.positionX = interpolateBetween(raceInterface.mapInfo.positionX,0,0,sX*0.75,0,0,progress,"OutQuad")
	else
		raceInterface.mapInfo.positionX = interpolateBetween(raceInterface.mapInfo.positionX,0,0,sX,0,0,progress,"Linear")
		if progress == 1 then return end
	end
	local posX = raceInterface.mapInfo.positionX
	if g_MapInfo then
		local alpha = raceInterface.alpha/255
		local red,green,blue = unpack(raceInterface.colors)
		local posY = sY*0.7
		dxDrawRectangle(posX+200,posY-4,sX*0.22,sY*0.16,tocolor(0,0,0,100*alpha))
		dxDrawLinedRectangle(posX+200,posY-4,sX*0.22,sY*0.16,tocolor(255,0,0))
		dxDrawRectangle(posX+200,posY-4,sX*0.15,sY*0.03,tocolor(0,0,0))
		dxDrawLinedRectangle(posX+200,posY-4,sX*0.15,sY*0.03,tocolor(255,0,0))

		local mapname = g_MapInfo.name or "Undefinied"
		local author = g_MapInfo.author or "No author"
		local lastTime = g_MapInfo.lastTimePlayedText or "Never played yet!"
		local playedCount = g_MapInfo.playedCount or 0
		local hunters = g_MapInfo.huntersReached or 0
		local toptimes = g_MapInfo.toptimesReached or 0
		local posX = posX+sX*0.035
			
		
		dxDrawText(mapname..author,posX+140,posY-9,posX+sX*0.2,posY+sY*0.03,tocolor(255,0,0*alpha),raceInterface.fontScale*0.109,raceInterface.font,"left","Center",true,false,false,true)
		
		
		dxDrawText("#ff0000Author #ffffff- "..author,posX+139,posY+60,posX+sX*0.25,posY+sY*0.025,tocolor(red,green,blue,255*alpha),raceInterface.fontScale*0.1,raceInterface.font,"left","Center",true,false,false,true)
		local posY = posY+sY*0.025
		dxDrawText("#ff0000Last time played #ffffff- "..lastTime,posX+139,posY+60,posX+sX*0.25,posY+sY*0.025,tocolor(red,green,blue,255*alpha),raceInterface.fontScale*0.1,raceInterface.font,"left","Center",true,false,false,true)
		local posY = posY+sY*0.025
		dxDrawText("#ff0000Played count #ffffff- "..playedCount,posX+139,posY+60,posX+sX*0.25,posY+sY*0.025,tocolor(red,green,blue,255*alpha),raceInterface.fontScale*0.1,raceInterface.font,"left","Center",true,false,false,true)
		local posY = posY+sY*0.025
		dxDrawText("#ff0000Hunters #ffffff- "..hunters,posX+139,posY+60,posX+sX*0.25,posY+sY*0.025,tocolor(red,green,blue,255*alpha),raceInterface.fontScale*0.1,raceInterface.font,"left","Center",true,false,false,true)
		local posY = posY+sY*0.025
		dxDrawText("#ff0000Toptimes #ffffff- "..toptimes,posX+139,posY+60,posX+sX*0.25,posY+sY*0.025,tocolor(red,green,blue,255*alpha),raceInterface.fontScale*0.1,raceInterface.font,"left","Center",true,false,false,true)
	end
end






function toggleMapInfo()
	if isTimer(raceInterface.mapInfo.timer) then
		killTimer(raceInterface.mapInfo.timer)
	end
	if raceInterface.mapInfo.state then
		closeInfo()
	else
		openInfo()
	end
end
bindKey("f6","up",toggleMapInfo)

function closeInfo()
	raceInterface.mapInfo.state = false
	raceInterface.mapInfo.tick = getTickCount()
end

function openInfo()
	raceInterface.mapInfo.state = true
	raceInterface.mapInfo.tick = getTickCount()
end

function openInfoByManager()
	openInfo()
	if isTimer(raceInterface.mapInfo.timer) then
		killTimer(raceInterface.mapInfo.timer)
	end
	raceInterface.mapInfo.timer = setTimer(closeInfo,7000,1)
end

900x600:
https://prnt.sc/faua1c

I can't remember the resolution of this screenshot but I hope you get the point and it helps :/
https://prnt.sc/fauiha

The MPH is suppose to be offset I haven't finished positioning that yet.
This is how it looks on my screen with max resolution :/
https://prnt.sc/fav2oj
https://prnt.sc/fav29a
https://prnt.sc/favak2

The radar and speedometer are images.
The rest is code generated.
I'm using an older racemode made by Apple, maybe from 2013-2014-2015 i dunno.
PLEASE somebody explain, inform me, teach me, provide me, with some sort of something ):
I think most of the BS code is for the slide effect.
I have a bad feeling this is hopeless..
I feel dumb but I'm sure this has happened to hundreds of people after they position stuff..

Edited by Justin|X5|
Link to comment

For every drawing (dxDrawRectangle, dxDrawLine et cetera) position use this:

screenWidth/2.4566

I used 2.4566 (random number) as an example, which you'd get by dividing the actual screen width you used for making the GUI (800?) with the GUI position number that suited in the resolution.

I know I explained it really :~ty, but hopefully this formula helps:

x=playersScreenWidth/(screenWidthUsedForMakingGUI/actualNumberForGUI)

 

Hard to explain :/

  • Like 1
Link to comment
1 minute ago, Justin|X5| said:

I feel really close to understanding but sadly not yet :/

local sX, sY = guiGetScreenSize() -- sX and sY are you screen

addEventHandler("onClientRender", root, function ()
    dxDrawRectangle(0,0,sX,sY,tocolor(255,255,255,150))-- this will draw a fully white background , because we start in x = 0 y = 0 and the width and the height are the ScreenSize 
    dxDrawRectangle(sX*0.5,sY*0.5, sX*0.05, sY*0.09,tocolor(255,0,0,255)) -- we used multiplication instead of division , it's the same thing.
    
    
    
end)

try to play with it a little bit to handle it , then it'll come very easy

  • Like 1
Link to comment
6 minutes ago, Justin|X5| said:

And to avoid free MTA resources that for some unworldy reason wouldn't have scaling codes in them
Which is most of them O.o

Well you don't necessarily need to avoid community resources. What I do is this:

1. I browse a bit at the free resources.

2. If something catches my eye I download it, test it and if I like it's idea I start editing 90% of it so that it works perfectly for my needs :D

3. Take ideas from a resource and make it myself if it's too bugged.

Edited by koragg
Adding scaling code is easy once you get how it's done as explained in the link I gave you :)
  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...