Jump to content

[Help] Change StaticImage


Recommended Posts

18154210a870455821830c05e65a93bco.png

hi all, i would like to know how to make when i click the botton change the StaticImage ...

( I just want to change it for another one in the same position ) ..

another one image :

IMAGENGOBERNADOR = guiCreateStaticImage(225, 242, 208, 219, "mono2.png", false, PANEL)

  
GUIEditor = { 
    label = {} 
} 
  
  
         if showw == false then 
     
        local screenWidth, screenHeight = guiGetScreenSize() 
local windowWidth, windowHeight = 661, 528 
local left = (screenWidth-windowWidth)/2 
local top = (screenHeight-windowHeight)/2 
         
         
        PANEL = guiCreateWindow(left,top,windowWidth,windowHeight, "", false) 
        guiWindowSetSizable(PANEL, false) 
  
  
        BANNER = guiCreateStaticImage(9, 18, 642, 163, "banner.png", false, PANEL) 
        IMAGENRICK = guiCreateStaticImage(225, 242, 208, 219, "mono.png", false, PANEL) 
         
  
        GUIEditor.label[1] = guiCreateLabel(260, 208, 163, 34, "Selecciona un Personaje", false, PANEL) 
        guiSetFont(GUIEditor.label[1], "default-bold-small") 
        guiLabelSetColor(GUIEditor.label[1], 173, 244, 98)     
        BOTONLEFT = guiCreateButton(190, 350, 26, 23, "", false, PANEL) 
        guiSetAlpha(BOTONLEFT, 0.20) 
        BOTONRIGHT = guiCreateButton(440, 350, 26, 23, "", false, PANEL) 
        guiSetAlpha(BOTONRIGHT, 0.20) 
        BOTONIMAGEN = guiCreateButton(225, 242, 208, 219, "", false, PANEL) 
        guiSetAlpha(BOTONIMAGEN, 0.20) 
  
  
  
  
    showw = false 
            showCursor(true) 
             
end  

Link to comment

I added this at end but doesn't work :( what's wrong?

function gob( ) 
     
    guiSetVisible( IMAGENRICK, true ) 
    guiSetVisible( IMAGENGOBERNADOR, false ) 
    end 
     
  
            addEventHandler("onClientGUIClick", BOTONRIGHT , gob, false) 

Link to comment
Works!! but if i want to add another one third image.. how to change the second image to the third?

use :

else 

and see this :

Button = guiCreateButton(30,340,113,46,"choose",false); 
Pic = guiCreateStaticImage(230,30,134,289,"1.png",false); 
local load = load 
addEventHandler("onClientGUIClick",Button, 
    function ( ) 
    if not ( load ) then 
                guiStaticImageLoadImage ( Pic, "1.png" ); 
                load = not load; 
        else 
                guiStaticImageLoadImage ( Pic, "2.png" ); 
                load = not load; 
        end; 
    end,false 
); 

Link to comment

local images = { "1.png","2.png","3.png" } 
local id = 1 
  
addEventHandler("onClientGUIClick",BOTONRIGHT, 
    function ( ) 
        if id then 
            id = id + 1 
    else 
            id = id - 1 
        end 
    if id < 1 then 
            id = #images      
    end  
        if id > #images then 
            id = 1        
    end  
   guiStaticImageLoadImage ( BOTONRIGHT , images [ id ] ) 
end,false 
) 

Try it .

Link to comment
    Button = guiCreateButton(30,340,113,46,"choose",false); 
    Pic = guiCreateStaticImage(230,30,134,289,"1.png",false); 
    local load = load 
    addEventHandler("onClientGUIClick",Button, 
        function ( ) 
        if not ( load ) then 
                    guiStaticImageLoadImage ( Pic, "1.png" ); 
                    load = not load; 
            else 
                    guiStaticImageLoadImage ( Pic, "2.png" ); 
                    load = not load; 
            end; 
        end,false 
    ); 

@Mr.Pres[T]ege @TheBesti took this code and works, Thank you su much !!

Link to comment

@Mr.Pres[T]ege

How showing the image if it's do not have x ,y,x and where is guiCreateStaticImage ?

    Button = guiCreateButton(30,340,113,46,"choose",false); 
    Pic = guiCreateStaticImage(230,30,134,289,"1.png",false); 
    local load = load 
    addEventHandler("onClientGUIClick",Button, 
        function ( ) 
        if not ( load ) then 
                    guiStaticImageLoadImage ( Pic, "1.png" ); 
                    load = not load; 
            else 
                    guiStaticImageLoadImage ( Pic, "2.png" ); 
                    load = not load; 
            end; 
        end,false 
    ); 

@Mr.Pres[T]ege @TheBesti took this code and works, Thank you su much !!

You're welcome.

Link to comment
@Mr.Pres[T]ege

How showing the image if it's do not have x ,y,x and where is guiCreateStaticImage ?

    Button = guiCreateButton(30,340,113,46,"choose",false); 
    Pic = guiCreateStaticImage(230,30,134,289,"1.png",false); 
    local load = load 
    addEventHandler("onClientGUIClick",Button, 
        function ( ) 
        if not ( load ) then 
                    guiStaticImageLoadImage ( Pic, "1.png" ); 
                    load = not load; 
            else 
                    guiStaticImageLoadImage ( Pic, "2.png" ); 
                    load = not load; 
            end; 
        end,false 
    ); 

@Mr.Pres[T]ege @TheBesti took this code and works, Thank you su much !!

You're welcome.

Read the example on the wiki:

guiStaticImageLoadImage 

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