Jump to content

[HELP] Screen size, yet another problem


LabiVila

Recommended Posts

local fonts = dxCreateFont ("fonts.ttf", 20) 
local x,y = guiGetScreenSize () 
local nm 
  
function mapInformations (mapInfo) 
    startingPositionOfMapRectangle = 0 
    name = mapInfo.name or "Not defined" 
     
    lengthOfCurrentMap = (string.len (name)*10) - (string.len (name) + (string.len (name) / 2))  
    startingPositionOfMapName = ( - string.len (name) * 10) 
  
    addEventHandler ("onClientRender", root, animation) 
    addEventHandler ("onClientRender", root, drawThisMap) 
end 
addEvent ("onClientMapStarting", true) 
addEventHandler ("onClientMapStarting", getRootElement(), mapInformations) 
  
function removeMapInfo () 
    removeEventHandler ("onClientRender", root, drawThisMap) 
    removeEventHandler ("onClientRender", root, animation) 
    removeEventHandler ("onClientRender", root, drawNextmap) 
    removeEventHandler ("onClientRender", root, animTextNM) 
end 
addEvent ("onClientMapStopping", true) 
addEventHandler ("onClientMapStopping", getRootElement(), removeMapInfo) 
  
function drawThisMap () 
    dxDrawRectangle (0, (740/768)*y, (startingPositionOfMapRectangle/1366)*x, (25/768)*y, tocolor (0, 0, 0, 155)) -- current map 
    dxDrawRectangle ((startingPositionOfMapRectangle/1366)*x, (740/768)*y, (5/1366)*x, (25/768)*y, tocolor (255, 113, 3, 155)) -- current map  
    dxDrawText (name, (startingPositionOfMapName/1366)*x, (744/768)*y, x, y, tocolor (255, 255, 255, 175), 0.5, fonts) 
end 
  
function drawNextmap () 
    dxDrawRectangle (0, (710/768)*y, (lengthOfNextmap/1366)*x, (25/768)*y, tocolor (0, 0, 0, 155)) -- next map  
    dxDrawRectangle ((lengthOfNextmap/1366)*x, (710/768)*y, (5/1366)*x, (25/768)*y, tocolor (255, 113, 3, 155)) -- next map 
    dxDrawText (nm, (startingPositionOfNextmap/1366)*x, (714/768)*y, x, y, tocolor (255, 255, 255, 175), 0.5, fonts) 
end 
  
function passMapName (nextmap) 
    nextMapRectangleStart = 0 
    nm = nextmap 
     
    lengthOfNextmap = (string.len (nm)*10) - (string.len (nm) + (string.len (nm) / 2)) 
    startingPositionOfNextmap = ( - string.len (nm) * 10) 
     
    addEventHandler ("onClientRender", root, drawNextmap)  
    addEventHandler ("onClientRender", root, animTextNM) 
end 
addEvent ("nextMapName", true) 
addEventHandler ("nextMapName", getRootElement(), passMapName) 
  
function animation () 
    if (startingPositionOfMapRectangle < lengthOfCurrentMap) then 
        startingPositionOfMapRectangle = startingPositionOfMapRectangle + 4 
    end 
    if (startingPositionOfMapName < 10) then -- stops at 10 coord 
        startingPositionOfMapName = startingPositionOfMapName + 4 
    end 
end 
  
function animTextNM () 
    if (startingPositionOfNextmap < 10) then 
        startingPositionOfNextmap = startingPositionOfNextmap + 4 
    end 
    if (nextMapRectangleStart < lengthOfNextmap) then 
        nextMapRectangleStart = nextMapRectangleStart + 4  
    end 
end 

I was just wondering, what's wrong here? Why isn't it working?

Link to comment

Thanks for answering, I see it was my bad for not writing the reason (I'm surprised with myself lol, I thought I did)... however, the code is working so well, however, it doesn't fit in every screen resolution. It is supposed to fit every, but I really don't know what's wrong. I've already searched a lot of topics about this but couldn't really find the problem (almost all were same as mine)

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...