iPanda Posted July 24, 2013 Share Posted July 24, 2013 - I want to create a resource that allows you to activate Night Vision by pressing the "n", provided that the player has Night vision goggles. Here is my script, but it does not work for some reason. Throws an error that getPedWeapon - bad argument. -- Night Vision Googles local nightvision = false local googleVision = function ( key, player ) local googles = getPedWeapon ( player ) if key == "n" then if not ( googles == 44 ) then nightvision = false setCameraGoggleEffect("normal") else nightvision = true setCameraGoggleEffect("nightvision") setFarClipDistance(1000) end end end -- Resource start and key addEventHandler ( "onPlayerJoin",root, function ( ) bindKey ( source, "n", "down", googleVision ) end ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, player in ipairs ( getElementsByType ( "player" ) ) do bindKey ( player, "n", "down", googleVision ) end end ) Link to comment
Vector Posted July 24, 2013 Share Posted July 24, 2013 you are mixing client-side code with server-side code erroneusly. client-side only! local nightvision = false; addEventHandler ("onClientResourceStart", getResourceRootElement (getThisResource ()), function () bindKey ("n", "down", function () if not ( googles == 44 ) then nightvision = false setCameraGoggleEffect("normal") else nightvision = true setCameraGoggleEffect("nightvision") setFarClipDistance(1000) end; end); end); Link to comment
TAPL Posted July 24, 2013 Share Posted July 24, 2013 -- Client Side -- bindKey("n", "down", function () if getPedWeapon(localPlayer) == 44 then if getCameraGoggleEffect() == "normal" then setCameraGoggleEffect("nightvision") setFarClipDistance(1000) else setCameraGoggleEffect("normal") end end end) 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