Jump to content

guiCreateStaticImage? plz help


jkub

Recommended Posts

I have a picture I have put together for a bomb shop script I am working on and I have a basic gui for it Buit I can not figure out how to get the picture im using into the gui???

I am using the Gui Classes for pretty much the whole gui I got everything set up in the meta already First I tried the way it was in gui classes like

StaticImage:Create( int/float x, int/float y, int/float width, int/float height, string filename, [ bool relative = false, guielement parent = guiroot ] ) 

then I tried the original way from the wiki

elementname = guiCreateStaticImage ( x, y, width, height, filename, relative, parent ) 

etc... Here is the main part of the gui

function createGarageGui ( ) 
    garageWindow = Window:Create ( .02, .3, .3, .6, "Car Bombs", true ) 
    garageWindow:Visible ( false ) 
    garageWindow:Movable ( false ) 
    garageWindow:Sizable ( false ) 
    showCursor ( false ) 
    image = guiCreateStaticImage ( 0.5, 0.5, 0.5, 0.5, "bomb.png", true, garageWindow ) 
            btnClsGarageGui = garageWindow:AddButton ( .35, .9, .3, .05, "Close", true ) 
            btnEngineBomb = garageWindow:AddButton ( .25, .1, .5, .05, "Engine Bomb", true ) 
            btnRemoteBomb = garageWindow:AddButton ( .25, .2, .5, .05, "Remote Bomb", true ) 
            btnTimeBomb = garageWindow:AddButton ( .25, .3, .5, .05, "Time Bomb", true ) 
            btnDudBomb = garageWindow:AddButton ( .25, .4, .5, .05, "Dud Bomb", true ) 
end 
  
addEventHandler ( "clientRequestsOpenGarageGui", getRootElement(), 
    function ( ) 
        garageWindow:Visible ( true ) 
        showCursor ( true ) 
        guiBringToFront ( garageWindow, true ) 
         
            btnClsGarageGui:AddOnClick ( closeGarageGui ) 
            btnEngineBomb:AddOnClick ( requestEngineBomb ) 
            btnRemoteBomb:AddOnClick ( requestRemoteBomb ) 
            btnTimeBomb:AddOnClick ( requestTimeBomb ) 
            btnDudBomb:AddOnClick ( requestDudBomb ) 
    end 
) 

Edited by Guest
Link to comment

When you're using that GUI Classes and you have a window object (created with Window:Create) then to get actual GUI element to be used with native GUI functions, just use .gui variable of that window object (you can read more about it in "Useful information" section), like so:

garageWindow = Window:Create ( .02, .3, .3, .6, "Car Bombs", true ) 
img = guiCreateStaticImage(.5, .5, .5, .5, "bomb.png", true, garageWindow.gui) -- note the .gui 

But, you can use the GUI Classes for this as well (sorry for not documented all functions/methods but I don't really have time, even for MTA). To make an image within a window with the GUI Classes you can do this:

garageWindow = Window:Create ( .02, .3, .3, .6, "Car Bombs", true ) 
garageWindow:AddStaticImage( .5, .5, .5, .5, "bomb.png", true ) 

And again, sorry for unfinished documentation. You can take a look into wndtab_class.lua to find out all methods that you can use with Window and Tab objects (by saying objects I mean GUI element created with classes, in this case garageWindow).

Hope that will help.

Link to comment

Thanks:) the first method seemed to work. I had to move around some of my gui elements such as the buttons to get the pic to fit in their. I put it at the top and the text on the picture is kind of hard to read so im gonna make another picture for it with the text larger. How do I make the font size bigger on text labels Im trying to get some way for instructions when a player buys a time bomb or a dud bomb. Either a pic with the instrutions or somthin

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