Jump to content

closed


Gallagher

Recommended Posts

Posted (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 by Guest
Posted
bindKey("o", "down", 
function() 
    guiSetVisible(myImage, not guiGetVisible(myImage)) 
end) 

Thank you again.

you work hard for that post, should win an award! :)

Posted
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

Posted
bindKey ( "mouse2", "both", 
    function ( _, state ) 
        guiSetVisible ( myImage, ( state == "down" and true or false ) ) 
    end 
) 

Posted
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

Posted
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?

Posted

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) 

Posted
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.

Posted

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) 

Posted
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

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...