Jump to content

[SNIPER BUG] DIMENSION SNIPER CHANGE


general999

Recommended Posts

So, I got this script ready, but the problem is that I run it, it works without giving an error, but as soon as I aim with a sniper ID 34, it gives this error message, I don't understand much about scripting so I don't know how to solve it or what could it be, can anyone help me?

OBS: it's a script so that when the PLAYER aims with the sniper, it changes dimensions, to be correcting the problem of the weapon appearing in front of the scope if you aim too fast.

 

local alpha = 255

bindKey ( "aim_weapon", "both", function ( _, state )
    if getPedWeaponSlot ( localPlayer ) == 6 then
        if ( state == "down" ) then
            alpha = 0
        elseif ( state == "up" ) then
            alpha = 255
        end
        for _, v in ipairs ( getElementsByType ( "object", root, true ) ) do
            if isElementAttachedToBone ( v ) then
                local id = getElementModel ( v )
                if ( id == 2584 ) then
                    setElementAlpha ( v, alpha )
                    setElementDimension(v, alpha == 0 and 9999 or getElementDimension(localPlayer))
                end
            end
        end
    end
end )
Link to comment
39 minutes ago, general999 said:
can you fix it for me buddy? I don't understand much about scripting... 

Well i think it should look something like this

local alpha = 255

bindKey ( "aim_weapon", "both", function ( _, state )
    if getPedWeaponSlot ( localPlayer ) == 6 then
        if ( state == "down" ) then
            alpha = 0
        elseif ( state == "up" ) then
            alpha = 255
        end
        for _, v in ipairs ( getElementsByType ( "object", root, true )) do
            if isElementAttached ( v ) then
                local id = getElementModel ( v )
                if ( id == 2584 ) then
                    setElementAlpha ( v, alpha )
                end
            end
        end
    end
end )

 

Edited by FlorinSzasz
Link to comment
  • 1 year later...

Hello guys, i know nothing about scripting and i also got the same problem

 

bindKey("aim_weapon","both",function(key,state)

 local weapon=getPedWeapon(localPlayer)

 if weapon==34 then

  local objs=getElementsByType("object",root,true)

  for i,obj in ipairs(objs) do

   if isElementAttachedToBone(obj) then

    local alpha=getElementAlpha(obj)

    if alpha==0 and state=="up" then

     setElementAlpha(obj,255)

    elseif alpha==255 and state=="down" then

     setElementAlpha(obj,0)

    end

   end

  end

 end

end)

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