Jump to content

Mira da sniper


Recommended Posts

Boa Tarde, preciso de ajuda nessa função aqui

 

Eu tentei fazer com que a a skin da arma nao apareça na mira, mas ainda continua aparecendo quando eu miro rápido 
 

local state
local objects = {}
bindKey ( "aim_weapon", "both", function ( _, state ) 
    if getPedWeaponSlot ( localPlayer ) == 6 then 
        if ( state == "down" ) then 
		    alpha = 0 
        elseif ( state == "up" ) then 
		    alpha = 255 
        end 
        state = state
    	for i, v in ipairs ( getElementsByType ( "object", root, true ) ) do 
        	if isElementAttachedToBone ( v ) then 
				local id = getElementModel ( v ) 
            	if ( id == 3026 ) or ( id == 2401 ) or ( id == 2384 ) or ( id == 2407 ) or ( id == 1248 ) or ( id == 2399 ) or ( id == 1252 ) or ( id == 1575 ) or
            	   ( id == 1576 ) or ( id == 1835 ) or ( id == 2189 ) or ( id == 1832 ) or ( id == 1833 ) or ( id == 1834 ) or ( id == 1837 ) or ( id == 1838 ) or
            	   ( id == 2725 ) or ( id == 1816 ) or ( id == 2644 ) or ( id == 1767 ) or ( id == 2726 ) then
            	   table.insert(objects, v)
                	setElementAlpha ( v, alpha )
                end
            end
        end
        setTimer(verifyAlpha(alpha), 200, 1)
    end 
end)

function verifyAlpha(n)
	if (state == "down") then
		for i, object in pairs(objects) do
			if ( not getElementAlpha(object) == n) then
				setElementAlpha(object, n)
				table.remove(objects, i)
			end
		end
	end 
end

 

Link to comment
  • Moderators

Não sei se dá pra corrigir isso, mas acredito que não tenha muita importância já que mostra a textura só quando clica rápido pra mirar.

Acho melhor você tirar esse loop em todos objetos do server cada vez que mira, isso pode estar dando um atraso pra ocultar. Se for possível, tente obter todos objetos anexados ao jogador.

E também, a função setTimer está errada; deve ser assim:

setTimer(verifyAlpha, 200, 1, alpha)

Edited by DNL291
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...