Jump to content

dxDrawing - How to make it relative ?


papam77

Recommended Posts

function draw() 
local x,y = guiGetScreenSize() 
x = 1920 
y = 1080 
  
dxDrawText ( "Ahoj",631.6,611.0,732.0,766.0,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,false) 
end 
addEventHandler ( "onClientResourceStart", draw ) 

So this will be for every resolution ?

Link to comment

That doesn't make sense..

local x,y = guiGetScreenSize() 
dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,false) 

This will draw the text at the centre of the screen (it will start at the centre).

Btw. you got error in your addEventHandler... check the syntax on wiki.

Link to comment
What's your grade from maths? ...

Why would you divide it by 3 if you want centre? I can't explain it, its basic maths and logic as well

My math grade is 12 class. And i realy don't get your "/2". He asked how to make it relative not how to make it centered and the size half of the resolution....

How to make it :

place the window where you want. Like 400,300 on 1152x864 resolution. After that make the math using calculator.

X = 400/1152

Y = 300/864

Then in dxDraw you put. dxDrawImage(ScreenW*X,ScreenH*Y,.......) this will be at the same place on every resolution.

I hope you get it.

Link to comment

I use the Gui Editor for get the relative position.

Example i make the label for get the relative position type : 0.49, 0.65, 0.13, 0.03 ok so . . .

If i want use this on dxdraw i make this

  
local x,y = guiGetScreenSize() 
a = 0.49 
b = 0.65 
c = 0.13 
d = 0.03 
dxDrawText ( "text", a*x , b*y , c*x , d*y , ........... 
-- is only example 
  

Link to comment
function design () 
local x,y = guiGetScreenSize() 
dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) 
end 
  
  
local on=false 
  
function toggle() 
    if not on then 
addEventHandler ( "onClientRender", root, design ) 
on=true 
    else 
removeEventHandler ( "onClientRender", root, design ) 
on=false 
     end 
end 
  
addCommandHandler ("test", toggle ) 

P.S DxFunction's need "addEventHandler ( "onClientRender", root, function)" and not CommandHandler or other event's

Link to comment
Now i don't see it.

0 Errors

0 Warnings

Then try it simpel.

function design () 
local x,y = guiGetScreenSize() 
dxDrawText ( "Ahoj",x/2,y/2,x/2,y/2,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) 
end 
  
addEventHandler ( "onClientRender", root, design ) 

P.S it should work the first one to : first "test" command = show it , secound "test" command hide it :D

Link to comment

But here is little problem.

function design () 
local x,y = guiGetScreenSize() 
a = 0.23 
b = 0.21 
c = 0.19 
d = 0.04 
  
dxDrawText ( "TEXT",a*x,b*x,c*x,d*x,tocolor(0,255,255,255),1.0,"bankgothic","left","top",false,false,true) 
end 
  
addEventHandler ( "onClientRender", root, design ) 

http://eag-gaming.eu/uploads/problemeeee.png

Label output:

guiCreateLabel(0.23, 0.21, 0.19, 0.04, "", true)    

So why it isn't on the label's place?

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