Jump to content

Sniper Crosshair


Recommended Posts

Doesn't work :

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        showPlayerHudComponent ( source, "crosshair", false ) 
    if itemID == -34 then -- Sniper item id 
        showPlayerHudComponent ( source, "crosshair", true ) -- crosshair true for it 
    end 
end 
) 

I tried :

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
    if itemID == -34 then 
        showPlayerHudComponent ( source, "crosshair", true ) 
    end 
    if not itemID == -34 then 
        showPlayerHudComponent ( source, "crosshair", false ) 
    end 
end 
) 

and nothing

Any ideas ?

Link to comment

how about using onPlayerWeaponSwitch ?

this will work

addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), 
    function ( previousWeaponID, currentWeaponID ) 
    local player = source 
    local currentwep = currentWeaponID 
        if (currentwep == 34) then -- Sniper item id is 34 not -34 
            showPlayerHudComponent ( player, "crosshair", true ) 
        else 
            showPlayerHudComponent ( player, "crosshair", false ) 
        end 
    end 
) 

Link to comment
how about using onPlayerWeaponSwitch ?

this will work

addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), 
    function ( previousWeaponID, currentWeaponID ) 
    local player = source 
    local currentwep = currentWeaponID 
        if (currentwep == 34) then -- Sniper item id is 34 not -34 
            showPlayerHudComponent ( player, "crosshair", true ) 
        else 
            showPlayerHudComponent ( player, "crosshair", false ) 
        end 
    end 
) 

The code should work but your local variables are pointless. They are the same as params and source so there is no point re-assigning them to local vars.

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