Gallagher Posted November 29, 2013 Share Posted November 29, 2013 (edited) hello! I would like to ask for help again. How do I put a bind on this image? When the Player tighten "o" or another button the image appears, and when he presses the image disappears again. Thank you! local myImage = guiCreateStaticImage ( 0.45, 0.48, 0.2, 0.5, "myimage.png", true ) Edited November 30, 2013 by Guest Link to comment
TAPL Posted November 29, 2013 Share Posted November 29, 2013 bindKey("o", "down", function() guiSetVisible(myImage, not guiGetVisible(myImage)) end) Link to comment
Gallagher Posted November 29, 2013 Author Share Posted November 29, 2013 bindKey("o", "down", function() guiSetVisible(myImage, not guiGetVisible(myImage)) end) Thank you again. you work hard for that post, should win an award! Link to comment
Gallagher Posted November 29, 2013 Author Share Posted November 29, 2013 You're welcome. I put in a bind "mouse 2", and it works, but I wanted the image to disappear when I loose the mouse2, it is possible to make the image appear only while tightening "mouse2"? thanks Link to comment
Castillo Posted November 29, 2013 Share Posted November 29, 2013 bindKey ( "mouse2", "both", function ( _, state ) guiSetVisible ( myImage, ( state == "down" and true or false ) ) end ) Link to comment
Gallagher Posted November 30, 2013 Author Share Posted November 30, 2013 bindKey ( "mouse2", "both", function ( _, state ) guiSetVisible ( myImage, ( state == "down" and true or false ) ) end ) thank you it works! I now have another problem, the image disrupts the crosshairs of some weapons such as Sniper Rifle, Rocket Launcher and others. would add a prohibition so that the image is not displayed when you are with a Rocket Launcher? prohibit the id of the weapon? thanks again Link to comment
Gallagher Posted November 30, 2013 Author Share Posted November 30, 2013 getPedWeapon could not do in a way that works: ( anyway thanks Link to comment
Gallagher Posted November 30, 2013 Author Share Posted November 30, 2013 Post what you tried. weapon = getPedWeapon( getLocalPlayer() ) if ( weapon==34 ) then destroyElement I think I'm almost there, what would be the function to destroy the image? Link to comment
TAPL Posted November 30, 2013 Share Posted November 30, 2013 No, you don't need to destroy the image. bindKey("mouse2", "both", function(_, state) if (getPedWeapon(localPlayer) ~= 34) then guiSetVisible(myImage, (state == "down" and true or false)) end end) Link to comment
Gallagher Posted November 30, 2013 Author Share Posted November 30, 2013 No, you don't need to destroy the image. bindKey("mouse2", "both", function(_, state) if (getPedWeapon(localPlayer) ~= 34) then guiSetVisible(myImage, (state == "down" and true or false)) end end) works, but as I put other weapons too? if (getPedWeapon (localPlayer) = 34 or 43 or 35) then did not work. Link to comment
TAPL Posted November 30, 2013 Share Posted November 30, 2013 Use table easier. disAllowed = {[34] = true, [43] = true, [35] = true} bindKey("mouse2", "both", function(_, state) if not (disAllowed[getPedWeapon(localPlayer)]) then guiSetVisible(myImage, (state == "down" and true or false)) end end) Link to comment
Gallagher Posted November 30, 2013 Author Share Posted November 30, 2013 Use table easier. disAllowed = {[34] = true, [43] = true, [35] = true} bindKey("mouse2", "both", function(_, state) if not (disAllowed[getPedWeapon(localPlayer)]) then guiSetVisible(myImage, (state == "down" and true or false)) end end) did not work, the image does not disappear Link to comment
TAPL Posted November 30, 2013 Share Posted November 30, 2013 Work with me, make sure you copied full code from line 1 till line 8. Link to comment
Gallagher Posted November 30, 2013 Author Share Posted November 30, 2013 Work with me, make sure you copied full code from line 1 till line 8. worked, thanks. You deserve an award, what's your address? I'll send you a gift! !! @ 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