alcholistu Posted July 9, 2013 Share Posted July 9, 2013 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
aim-killer Posted July 9, 2013 Share Posted July 9, 2013 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
50p Posted July 9, 2013 Share Posted July 9, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now