Jump to content

[BUG] Crosshair weapon


Recommended Posts

Good Morning I need a help on a Crosshair system is a sniper aiming system, some must know it I want to put a blocking function to appear when the player jumps, why when he jumps the crosshair is in front. .. already tried putting a system isClientBindKey more did not work also the bug continues ... what should I do? 

What did i do wrong in it? can you help me? thank you
function on_weapon_aimed(key,state)
  if (pressed) then return end
  outputChatBox("off")
  if getPedWeapon(getLocalPlayer())== 34 then
    if state == "down" then
      weap1 = getElementData(getLocalPlayer(),"currentweapon_2")
      for i,weaponData in pairs(weaponTable)do
        if weap1 == weaponData[1] then
          cross = CH[weap1]
        end
      end
      setPlayerHudComponentVisible("crosshair",false)
      addEventHandler("onClientHUDRender",getRootElement(),render_crosshair)
    else 
      cross = false
      removeEventHandler("onClientHUDRender",getRootElement(),render_crosshair)
    end
  end
end 

addEventHandler( "onClientKey", getRootElement(),function(button,press) 
  if button == "lsfhit" then
      pressed = true
       outputChatBox("ON")
      setTimer(function() pressed = false end, 50000, 1)
  end
end)

 

Edited by Dutchman101
edited title tag & code box to fit section guidelines
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...