Garry's Mod

Garry's Mod

660 ratings
Better Flashlight
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Effects
Addon Tags: Fun, Roleplay, Scenic
File Size
Posted
Updated
377.361 KB
13 Feb @ 11:43am
28 Feb @ 11:56am
6 Change Notes ( view )

Subscribe to download
Better Flashlight

Description
A simple script to enhance the HL2 flashlight, in third person the flashlight will always come from the player's view instead of the player model's hand, gives players the ability to choose a custom color and texture for it (if allowed by the server), and some more

For Developers
This addon overrides the behavior of the default flashlight, but I made sure you can still check for the player's flashlight.

Instead of using Player:FlashlightIsOn() you can use Player:GetNWBool("FlashlightIsOn"), Player:FlashlightIsOn() will always return false if the user is using this addon

The addon respects the Player:CanUseFlashlight() property and runs the PlayerSwitchFlashlight event to check if the player can switch it's flashlight on or off.

As for sound, it does not use or add a custom sound, it uses the default HL2 soundscript "HL2Player.FlashLightOn" and "HL2Player.FlashLightOff", so basic sound replacements should work.

Client Console Variables
Name
Default
Purpose
cl_flashlight_only_local_shadows
1
If set to 1, only the local player's flashlight will cast shadows, having a lot of shadow-casting flashlights can become really expensive on performance (there's a limit on how many projected textures (i.e flashlights and other fancy lights) that cast shadows can exist at once, read more here: https://developer.valvesoftware.com/wiki/Env_projectedtexture#Caveats_and_Fixes in GMod this limit is 8)
cl_flashlight_hl2_obstruction_check
1
If set to 1, while in first person the flashlight will "pullback" when too close to a wall or object
cl_flashlight_disable_in_vehicle
0
If set to 1, when you get into a vehicle you wont be able to toggle ON or OFF your flashlight (if it's ON you will be able to turn it OFF)
cl_flashlight_disable_in_vehicle_only_driver
1
Works with setting above, the restriction will only apply if you are the driver of the vehicle
cl_flashlight_follows_viewpunch
1
If set to 1, the flashlight will follow a player's viewpunch (view nudges when shooting or getting hit)
cl_flashlight_thirdperson_near_z
46
The higher this value, the further away shadows from a player's flashlight will start in third person. This prevents the player's arms or weapons from casting shadows
cl_flashlight_firstperson_angle_lerp
0
If set to a number above 0, while in first person the flashlight's angle will smoothly turn instead of being locked to the player's view angles
cl_flashlight_thirdperson_glow_follows_bone
""
The glow and beam of the flashlight while in third person will try to follow the bone specified. Empty means they will follow the player's view position. You can see common bone names here: https://wiki.facepunch.com/gmod/ValveBiped_Bones
cl_flashlight_config_color
255 255 255
The custom color used for your flashlight, if custom colors are allowed. There are 3 convars for each color component, r, g and b. A 4th convar exists for alpha but it is not used, it is there for technical reasons
cl_flashlight_config_texture
"effects/flashlight001"
The custom texture used for your flashlight, if custom textures are allowed
cl_flashlight_thirdperson_show_glow
1
If set to 1, while in third person a player's flashlight will emit a bright glow when looked at like the lamps spawned by the lamp tool
cl_flashlight_thirdperson_show_beam
1
If set to 1, while in third person a player's flashlight will emit a beam
cl_flashlight_thirdperson_beam_max_alpha
100
The maximum alpha reached by a player's flashlight beam, the beam fades away when looking at the flashlight directly and gets more visible when looked at from the side

Server Console Variables
Name
Default
Purpose
sv_flashlight_override_default
1
Enable or disable overriding the default flashlight
sv_flashlight_allow_colors
1
Allow if players can set their own flashlight's color (if not allowed, the default flashlight color will be used)
sv_flashlight_allow_textures
1
Allow if players can set their own flashlight's texture (if not allowed, the default flashlight texture will be used)
sv_flashlight_default_color
255 255 255
The default color used for flashlights if custom colors are not allowed. There are 3 convars for each color component, r, g and b. A 4th convar exists for alpha but it is not used, it is there for technical reasons
sv_flashlight_default_texture
"effects/flashlight001"
The default texture used for flashlights if custom textures are not allowed
Popular Discussions View All (1)
0
23 Mar @ 9:18am
Flickering Light When Looking at Water
Talon
54 Comments
LqmKim 20 Jun @ 9:23pm 
can you add the flashlioght fov to make it big or small
Lombaxtard 27 Apr @ 10:02am 
Can this be made compatible with TFA? If a TFA weapon has flashlight attachment, whenever you turn it on you can't turn your flashlight off, not even the sound plays
Annex 26 Apr @ 11:56pm 
broken on some of the player models, it shows their sillouhette really dark contrasted behind the light (also looks buggy with TacRP Weapons mod.)
GermanPlasma 13 Apr @ 3:07pm 
Flashlight does not seem to activate at all in TTT2. Have to set sv_flashlight_override_default to 0 to get the old flashlight back, at 1 it just doesn't do anything sadly.
Lombaxtard 13 Apr @ 9:57am 
Flashlight stays ON when you die. Is that intended?
Talon 23 Mar @ 8:56am 
Okay, after a decent while since I last used this, it seems it does work better than I remember. However, the light still for some reason flickers when near bodies of water. Not entirely sure why because I did even try turning down water reflections down to simple in the case it was something related to that.
TheDesertRoad 5 Mar @ 9:34pm 
Well, for some people like me a compatibility with that feature would be great!
Liokindy  [author] 5 Mar @ 8:06pm 
I thought that was a hated feature
TheDesertRoad 5 Mar @ 6:15pm 
Good addon, but it is incompatible with flashlight's battery addons light AUX Power or even the default flashlight power
Liokindy  [author] 5 Mar @ 12:25pm 
@Arcius It's supposed to be similar to the default flashlight, but I guess I can add it