Jump to content

dxDrawText problem


Recommended Posts

Posted

Hi, I wrote this client script:

showPlayerHudComponent("clock", false) 
  
function updateHud() 
    --outputChatBox("function test") -- It works 
    local screenWidth, screenHeight = getScreenSize() 
    --[[local realtime = getRealTime() 
    local hour = realtime.hour 
    local minute = realtime.minute]]-- 
    dxDrawText("00:00", screenWidth/2 - 1229, screenHeight/2 - 56, screenWidth, screenHeight) 
end 
  
--function timeHudF() 
    addEventHandler("onClientRender", getRootElement(), updateHud)   
--end 
  
--addEventHandler("timeHud", getRootElement(), timeHudF) 

The function is called, but dxDrawText doesn't work. Why?

Posted
screenWidth/2 - 1229 

maybe because of this ?

I setted + instead of -, but it doesn't work.

No matter what, it will be outside your screen. Remove "- 1229" at all. Plus yeah, it should be guiGetScreenSize(), not getScreenSize()

Posted
Line 5: getScreenSize should be guiGetScreenSize

Thanks, it works, but only if I leave

screenWidth/2 - 

and

screenHeight/2 - 

. The same if I write + instead of -, but it's a wrong position. Why?

No matter what, it will be outside your screen. Remove "- 1229" at all. Plus yeah, it should be guiGetScreenSize(), not getScreenSize()

If I do this, it sets a wrong position for the text.

Posted
showPlayerHudComponent("clock", false) 
local x,y = guiGetScreenSize() 
  
function updateHud() 
    --outputChatBox("function test") -- It works 
    local realtime = getRealTime() 
    local hour = realtime.hour 
    local minute = realtime.minute 
    dxDrawText("00:00",x - 100,y/2 - 56,x,y) -- Find your preferred position. 
end 
  
--function timeHudF() 
    addEventHandler("onClientRender", getRootElement(), updateHud)  
--end 
  
--addEventHandler("timeHud", getRootElement(), timeHudF) 

Posted
Try to use guieditor resource to get your preferred positions.

I used it, but I want the position for all resolutions.

showPlayerHudComponent("clock", false) 
local x,y = guiGetScreenSize() 
  
function updateHud() 
    --outputChatBox("function test") -- It works 
    local realtime = getRealTime() 
    local hour = realtime.hour 
    local minute = realtime.minute 
    dxDrawText("00:00",x - 100,y/2 - 56,x,y) -- Find your preferred position. 
end 
  
--function timeHudF() 
    addEventHandler("onClientRender", getRootElement(), updateHud)  
--end 
  
--addEventHandler("timeHud", getRootElement(), timeHudF) 

It doesn't work.

I tried the code written in the third post, but it doesn't work.

Posted (edited)
Don't copypaste, but try your own calculations + report if any debug errors appear.

I used 1229 instead of 100 and 56.

EDIT: Now it works, because I wrote Weight instead of Height, but it's a wrong position.

Edited by Guest
Posted
Give me your original positions from guieditor and the resolution where you used the guieditor.

GUIEditor = {

label = {}

}

addEventHandler("onClientResourceStart", resourceRoot,

function()

GUIEditor.label[1] = guiCreateLabel(1229, 56, 140, 48, "00:00", false)

end

)

My resolution is 1440x900.

Posted
local screenWidth, screenHeight = guiGetScreenSize() 
local sx, sy = screenWidth/1400, screenHeight/900 
  
--(...) 
guiCreateLabel(1229*sx, 56*sy, 140*sx, 48*sy, "00:00", false)  
  

The same with dx positions.

Posted
local screenWidth, screenHeight = guiGetScreenSize() 
local sx, sy = screenWidth/1400, screenHeight/900 
  
--(...) 
guiCreateLabel(1229*sx, 56*sy, 140*sx, 48*sy, "00:00", false)  
  

The same with dx positions.

Thanks! Now it works!

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