Garry's Mod

Garry's Mod

819 ratings
Better Flashlight [v1.0]
2
   
Award
Favorite
Favorited
Unfavorite
Content Type: Addon
Addon Type: Effects
Addon Tags: Fun, Roleplay, Scenic
File Size
Posted
Updated
376.202 KB
13 Feb @ 11:43am
20 Jul @ 3:55pm
8 Change Notes ( view )

Subscribe to download
Better Flashlight [v1.0]

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, 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 ConVars
Name
Default
Purpose
cl_betterflashlight_local_player_only_shadows
1
If set to 1, only your flashlight will cast shadows
cl_betterflashlight_local_player_only_hl2_style
0
If set to 1, only your flashlight will "pullback" when too close to a wall or object, ignoring other players settings
cl_betterflashlight_glow
1
If set to 1, player flashlights will emit a glow when looked at
cl_betterflashlight_beam
1
If set to 1, player flashlights will emit a visible beam
cl_betterflashlight_beam_alpha
100
The transparency of the beam of a player flashlight
cl_betterflashlight_config_r
255
Your flashlight's color. Red component
cl_betterflashlight_config_g
255
Your flashlight's color. Green component
cl_betterflashlight_config_b
255
Your flashlight's color. Blue component
cl_betterflashlight_config_a
255
Your flashlight's color. Alpha component. NOT USED.
cl_betterflashlight_config_near_z
96
Your flashlight's extra near-z distance, this will try to avoid casting your own shadow
cl_betterflashlight_config_angle_lerp
0
Your flashlight's smooth turning factor, 0 is disabled
cl_betterflashlight_config_fov
60
Your flashlight's field-of-view
cl_betterflashlight_config_texture
"effects/flashlight001"
Your flashlight's texture.
cl_betterflashlight_config_hl2_style
1
Your flashlight's HL2-style setting.

Server ConVars
Name
Default
Purpose
sv_betterflashlight_override_default
1
Enable or disable overriding the default flashlight
sv_betterflashlight_follow_viewpunch
1
If set to 1, player flashlights will follow their viewpunch
sv_betterflashlight_disable_in_vehicle
0
Not recommended, buggy. If set to 1, flashlight is always off when in a vehicle
sv_betterflashlight_disable_in_vehicle_only_driver
1
Works with setting above, the restriction will only apply if you are the driver of the vehicle
sv_betterflashlight_debug
0
Debug overlays, only works with sv_cheats and developer ConVars
115 Comments
Ozkii 16 Oct @ 10:07am 
please fix the NearZ option, the PM's shadow always gets cast now, unusable :(
thatrandom1one1guy 15 Oct @ 6:14pm 
PLEASE
thatrandom1one1guy 12 Oct @ 1:49pm 
ahem
Spicyballer 19 Sep @ 2:44am 
Please add an option to change a light distance. Many people are waiting for this, but almost no one is talking about it
CheekyRedder 15 Sep @ 4:37am 
I don't have any flashlight addons besides this one but it is pretty much unusable in firstperson due to it casting playermodel shadows, even with the default half-life 2 viewmodels. The NearZ option literally doesn't do anything, both through the menu and the console.
thatrandom1one1guy 9 Sep @ 7:30pm 
:steamhappy:
thatrandom1one1guy 9 Sep @ 7:30pm 
help a brotha out
thatrandom1one1guy 9 Sep @ 7:30pm 
so i dont know what the problem is
thatrandom1one1guy 9 Sep @ 7:29pm 
i try turning it on and off but it dosnt show even when i disabled it just makes my flashlight almost unable to see. Try using a brighter flashlight texture same thing
thatrandom1one1guy 7 Sep @ 7:42pm 
dont work