Jump to content

gui image problem


John Smith

Recommended Posts

hey guys im trying to change image when my cursor enters a button's position but the image isnt changing at all and no debugscript 3 errors

function buttonEnter () 
       
      if source == freeRoomButton then 
      freeRoom = nil 
         freeRoomAnimImg = guiCreateStaticImage(500,500,675,122,"files/images/freeroam_hover.png",false,lobbyWindow) 
      end 
       
      if source == sumoButton then 
      sumoRoom = nil 
      sumoAnimImg = guiCreateStaticImage(500,300,675,122,"files/images/sumo_hover.png",false,lobbyWindow) 
      end 
       
end 
addEventHandler( "onClientMouseEnter", getRootElement(),buttonEnter) 
  
  
  
  
function buttonExit () 
      if source == freeRoomButton then 
         freeRoomAnimImg = nil 
         freeRoom = guiCreateStaticImage(500,500,675,122,"files/images/freeroam.png",false,lobbyWindow) 
         end 
          
      if source == sumoButton then 
      sumoAnimImg = nil 
      sumoRoom = guiCreateStaticImage(500,300,675,122,"files/images/sumo.png",false,lobbyWindow) 
      end 
end 
addEventHandler( "onClientMouseLeave", getRootElement(),buttonExit) 

please help if you know how i could fix this

edit: i have discovered by debugging that when this events work only once and then when i enter the button again it doesnt work

Link to comment

i tried this

function buttonEnter () 
       
      if source == freeRoomButton then 
       
         freeRoomAnimImg = guiCreateStaticImage(500,500,675,122,"files/images/freeroam_hover.png",false,lobbyWindow) 
         fh = guiStaticImageLoadImage(freeRoom,"files/images/freeroam_hover.png") 
         outputDebugString("freeroam anim image") 
      else return end 
       
      if source == sumoButton then 
       
      sumoAnimImg = guiCreateStaticImage(500,300,675,122,"files/images/sumo_hover.png",false,lobbyWindow) 
      sh = guiStaticImageLoadImage(sumoRoom,"files/images/sumo_hover.png") 
      outputDebugString("sumo anim image") 
      else return end 
       
end 
addEventHandler( "onClientMouseEnter", getRootElement(),buttonEnter) 
  
  
  
  
function buttonExit () 
      if source == freeRoomButton then 
       
         freeRoom = guiCreateStaticImage(500,500,675,122,"files/images/freeroam.png",false,lobbyWindow) 
         nf = guiStaticImageLoadImage(freeRoomAnimImg,"files/images/freeroam.png") 
         outputDebugString("freeroam image") 
         end 
          
      if source == sumoButton then 
       
      sumoRoom = guiCreateStaticImage(500,300,675,122,"files/images/sumo.png",false,lobbyWindow) 
      ns = guiStaticImageLoadImage(sumoAnimImg,"files/images/sumo.png") -- line 90 
      outputDebugString("sumo image") 
      end 
end 
addEventHandler( "onClientMouseLeave", getRootElement(),buttonExit) 

it outputs in debug that event was triggered but works only once and image doesnt change at all

only error:90 bad argument guiStaticImageLoadImage

(gui element is nil and idk how its nil)

Link to comment

i have done this

function buttonEnter () 
       
      if source == freeRoomButton then 
       
         --freeRoomAnimImg = guiCreateStaticImage(500,500,675,122,"files/images/freeroam_hover.png",false,lobbyWindow) 
         fh = guiStaticImageLoadImage(freeRoom,"files/images/freeroam_hover.png") 
         outputDebugString("freeroam anim image") 
      else return end 
       
      if source == sumoButton then 
       
      --sumoAnimImg = guiCreateStaticImage(500,300,675,122,"files/images/sumo_hover.png",false,lobbyWindow) 
      sh = guiStaticImageLoadImage(sumoRoom,"files/images/sumo_hover.png") 
      outputDebugString("sumo anim image") 
      else return end 
       
end 
addEventHandler( "onClientMouseEnter", getRootElement(),buttonEnter) 
  
  
  
  
function buttonExit () 
      if source == freeRoomButton then 
       
         --freeRoom = guiCreateStaticImage(500,500,675,122,"files/images/freeroam.png",false,lobbyWindow) 
         nf = guiStaticImageLoadImage(freeRoomAnimImg,"files/images/freeroam.png") 
         outputDebugString("freeroam image") 
         end 
          
      if source == sumoButton then 
       
      --sumoRoom = guiCreateStaticImage(500,300,675,122,"files/images/sumo.png",false,lobbyWindow) 
      ns = guiStaticImageLoadImage(sumoAnimImg,"files/images/sumo.png") 
      outputDebugString("sumo image") 
      end 
end 
addEventHandler( "onClientMouseLeave", getRootElement(),buttonExit) 

now it makes image for freeroam but doesnt remove it when i leave it, and sumo image doesnt work at all when i move my cursor to it

Link to comment
  
function buttonEnter () 
      
      if source == freeRoomButton then 
      
         --freeRoomAnimImg = guiCreateStaticImage(500,500,675,122,"files/images/freeroam_hover.png",false,lobbyWindow) 
         fh = guiStaticImageLoadImage(freeRoom,"files/images/freeroam_hover.png") 
         outputDebugString("freeroam anim image") 
      else return end 
      
      if source == sumoButton then 
      
      --sumoAnimImg = guiCreateStaticImage(500,300,675,122,"files/images/sumo_hover.png",false,lobbyWindow) 
      sh = guiStaticImageLoadImage(sumoRoom,"files/images/sumo_hover.png") 
      outputDebugString("sumo anim image") 
      else return end 
      
end 
addEventHandler( "onClientMouseEnter", getRootElement(),buttonEnter) 
  
  
  
  
function buttonExit () 
      if source == freeRoomButton then 
      
         freeRoom = guiCreateStaticImage(500,500,675,122,"files/images/freeroam.png",false,lobbyWindow) 
         guiStaticImageLoadImage(freeRoom ,"files/images/freeroam.png") 
         outputDebugString("freeroam image") 
         end 
          
      if source == sumoButton then 
      
      sumoRoom = guiCreateStaticImage(500,300,675,122,"files/images/sumo.png",false,lobbyWindow) 
      guiStaticImageLoadImage(sumoRoom ,"files/images/sumo.png") 
      outputDebugString("sumo image") 
      end 
end 
addEventHandler( "onClientMouseLeave", getRootElement(),buttonExit) 
  

Link to comment

sumo image outputs in debugscript INFO: sumo image

and theres no sumo anim image text when i leave the button

and freeroam changes picture only ONCE and after that when i reach freeroam button it doesnt change the picture anymore

edit: i have noticed that problem is that picture is being drawn over a button so i cant reach the button as image is "hiding" it but not sure how to make it that image changes when i hit gui image element

Link to comment

try this .. :

addEventHandler( "onClientMouseEnter", resourceRoot, function (   ) 
   if ( source == freeRoomButton ) then 
      guiStaticImageLoadImage ( freeRoom, "files/images/freeroam_hover.png" ) 
   elseif ( source == sumoButton ) then 
      guiStaticImageLoadImage ( sumoRoom, "files/images/sumo_hover.png" ) 
   end 
end )    
  
  
addEventHandler( "onClientMouseLeave", resourceRoot, function (   ) 
   if ( source == freeRoomButton ) then 
      guiStaticImageLoadImage ( freeRoom,"files/images/freeroam.png") 
   elseif ( source == sumoButton ) then 
      guiStaticImageLoadImage ( sumoRoom, "files/images/sumo.png" ) 
   end 
end )    
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...