Jump to content

dxDrawText problem


Recommended Posts

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?

Link to comment
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.

Link to comment
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) 

Link to comment
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.

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