Jump to content

Image placing


DePemy

Recommended Posts

Posted

So, i wanted to make a custom Time Passed image with logo. But somehow i cant get the position right..

Anyone who can help me out?

Thanks in advance.

Code :

function showClientImage() 
   guiCreateStaticImage( 1920, 1080, 100, 100, "logo1.png", false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage ) 

Posted

Hmm here's pic of your script. I guess your monitor have native resolution of 1080p.

aitXV03.jpg

You should first get size of screen and then place an img :)

//Ok here's code if you don't understand. That should make it working

local x, y = guiGetScreenSize() 
function showClientImage() 
   guiCreateStaticImage( x-100, y-100, 100, 100, "logo1.png", false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage ) 

Posted

Very good. Altought my logo is very small now, and when i change the size, the positions isnt right again.. I understand what you said, but how can i figure out what the position number is? Now you used -100 . How do you know this?

Posted

You have to declare size of your image. It's pixel size so if your width of screen is variable "x" and you would like to show image on center then you have to do some math: "x/2 - halfsizeofimage"

Place img on center:

local x, y = guiGetScreenSize() 
function showClientImage() 
   guiCreateStaticImage( x/2-100, y/2-100, 200, 200, "logo1.png", false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), showClientImage ) 

You should read description of guiCreateStaticImage function.

First argument is horizontal position on screen, 2nd arg is vertical position, 3rd is width of ig, 4rd is height, ..."

Posted

You need to work on the positioning.

Could you post the code here?

  
-- it should be something like this 
local imgWidth, imgHeight = 200, 150 
guiCreateStaticImage ( x - imgWidth, 100, imgWidth, imgHeight, "logo1.png", false ) 
  

If the text above the image is relative to the screen size, you need to account for that.

Alternatively you can also make the image relative to its parent.

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