iPanda Posted February 5, 2014 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)
Anubhav Posted February 5, 2014 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 See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
iPanda Posted February 5, 2014 Author 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.
Moderators IIYAMA Posted February 5, 2014 Moderators 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) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Anubhav Posted February 5, 2014 Posted February 5, 2014 Whats the new error? add me on skype: anubhav.agarwal87 i will fix it on it. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
iPanda Posted February 5, 2014 Author 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
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