Jump to content

Text bug


Guest

Recommended Posts

Guys i have this script 





 
function DXdraw()
--Variables
		local screenWidth, screenHeight = guiGetScreenSize ( )
setTimer(function()
triggerServerEvent("online",getLocalPlayer()) 
end, 10000, 1, true)
                
                local num = getElementData ( getLocalPlayer(), "numPlayers")
		local max = getElementData ( getLocalPlayer(), "maxPlayers")
  max= ' / ' ..max
	  num= ' ONLINE PLAYERS: ' ..num
	

dxDrawText(tostring(num),650, screenHeight - 14, screenWidth, screenHeight,tocolor(154, 149, 143, 252),1.00,"arial") 

dxDrawText(tostring(max),770, screenHeight - 14, screenWidth, screenHeight,tocolor(154, 149, 143, 252),1.00,"arial") 

-----------------------------------------------------------------------------------------------------------------------------------------

                 local ping = getPlayerPing ( getLocalPlayer(), "ping2")

end

addEventHandler("onClientRender", getRootElement(), DXdraw)

And this

addEventHandler("onClientRender", root,
    function()
        dxDrawRectangle(780, 147, 210, 20, tocolor(0, 0, 0, 193), false)
        dxDrawText(" #ff0000SERVER NAME #00ff00V3.0 #ffffff|#ff0000Made by:#00ff00Hyper", 776, 147, 990, 167, tocolor(255, 255, 255, 255), 1.00, dxfont0_PetitFormalScript, "center", "center", false, false, false, true, false)
    end
)

When i change my MTA resolution, Their positions change

and some of players can't even see them 

What should I do to put them in one place and see all the players in that place, even if they change thier resolutions

 

Link to comment

First of all, I'm very concerned about lines 9 through 11

setTimer(function()
triggerServerEvent("online",getLocalPlayer()) 
end, 10000, 1, true)

being inside a function called every frame. You're creating a new timer as frequently as 60 times a second for clients which run on 60 FPS. The code as you've written it simply delays the queries for online players by 10 seconds but still calls it as many times a second as the amount of frame rendered per second, rather than reducing the frequency to once every 10 seconds which you can do by setting a timer when the resource starts (onClientResourceStart or simply outside any function) with the interval set to 10000ms (as you have it now) and repetitions to 0 (infinite).

But to answer your question, when making resolutions relative, there are a couple approaches - the laziest is to simply change the numbers into fractions of the native resolution (on which they were designed) and multiplied by the one where they're displayed, for example the width of 780px can be made relative by using (780/1920)*screenW where 1920 is the native screen width, and screenW is the result of guiGetScreenSize()

Edited by MrTasty
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...