scienziato-pazzo Posted January 15, 2014 Posted January 15, 2014 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?
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 screenWidth/2 - 1229 maybe because of this ? I setted + instead of -, but it doesn't work.
Sasu Posted January 15, 2014 Posted January 15, 2014 Line 5: getScreenSize should be guiGetScreenSize
Gallardo9944 Posted January 15, 2014 Posted January 15, 2014 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()
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 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.
Wei Posted January 15, 2014 Posted January 15, 2014 You must calculate it. https://forum.multitheftauto.com/viewtopic.php?f=91&t=69692
Gallardo9944 Posted January 15, 2014 Posted January 15, 2014 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)
Sasu Posted January 15, 2014 Posted January 15, 2014 Try to use guieditor resource to get your preferred positions.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 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. You must calculate it. https://forum.multitheftauto.com/viewtopic.php?f=91&t=69692 I tried the code written in the third post, but it doesn't work.
Gallardo9944 Posted January 15, 2014 Posted January 15, 2014 Don't copypaste, but try your own calculations + report if any debug errors appear.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 (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 January 15, 2014 by Guest
Sasu Posted January 15, 2014 Posted January 15, 2014 Give me your original positions from guieditor and the resolution where you used the guieditor.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 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.
Sasu Posted January 15, 2014 Posted January 15, 2014 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.
scienziato-pazzo Posted January 15, 2014 Author Posted January 15, 2014 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now