iPanda Posted February 5, 2014 Share Posted February 5, 2014 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
Anubhav Posted February 5, 2014 Share Posted February 5, 2014 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
iPanda Posted February 5, 2014 Author Share Posted February 5, 2014 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 IIYAMA Posted February 5, 2014 Moderators Share Posted February 5, 2014 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
Anubhav Posted February 5, 2014 Share Posted February 5, 2014 Whats the new error? add me on skype: anubhav.agarwal87 i will fix it on it. Link to comment
iPanda Posted February 5, 2014 Author Share Posted February 5, 2014 Whats the new error? add me on skype: anubhav.agarwal87 i will fix it on it. Unfortunately I do not speak English. I live in Russia and I use a translator Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now