Jump to content

Help fix bugs


iPanda

Recommended Posts

I want to make a picture when the player aims a weapon. When the player shoots the picture remains on the screen, but when he releases the key sights, the picture disappears automatically. I have the skeleton of this function, but it is unstable - it speaks flaw. Help to complete and fix bugs.

aim = guiCreateStaticImage(0.311, 0.454, 0.349, 0.626, "aim.png", true)  
guiSetVisible(aim, false) 
  
addEventHandler("onClientKey", root, function( button, press ) 
    local state = ( not guiGetVisible( aim )) 
    if ( button == "mouse2" ) then 
        guiSetVisible( aim, state ) 
    else 
        guiSetVisible( aim, false ) 
    end 
end) 

Link to comment
  
aim = guiCreateStaticImage(0.311, 0.454, 0.349, 0.626, "aim.png", true) 
guiSetVisible(aim, false) 
  
addEventHandler("onClientKey", root, function( button, press ) 
    local state = ( not guiGetVisible( aim )) 
    if ( button == "mouse2" ) then 
        guiSetVisible( aim, state ) 
       setTimer(removeImage,1000,0) 
   end 
end) 
function removeImage() 
        guiSetVisible( aim, false ) 
 end 
  

Link to comment
  
aim = guiCreateStaticImage(0.311, 0.454, 0.349, 0.626, "aim.png", true) 
guiSetVisible(aim, false) 
  
addEventHandler("onClientKey", root, function( button, press ) 
    local state = ( not guiGetVisible( aim )) 
    if ( button == "mouse2" ) then 
        guiSetVisible( aim, state ) 
       setTimer(removeImage,1000,0) 
   end 
end) 
function removeImage() 
        guiSetVisible( aim, false ) 
 end 
  

Thanks, but your example is not correct all the errors, only half of one.

Link to comment
  • Moderators

Try something like this.

  
local aim = guiCreateStaticImage(0.311, 0.454, 0.349, 0.626, "aim.png", true) 
guiSetVisible(aim, false) 
  
local convertButtonState={["down"]=true,["up"]=false} 
bindKey ("aim_weapon","both", 
function(key,state) 
 guiSetVisible( aim, convertButtonState[state] ) 
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...