Garry's Mod

Garry's Mod

701 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
377.476 KB
13 Feb @ 11:43am
7 Jul @ 2:42pm
7 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
81 Comments
Omen 18 Jul @ 7:37am 
when used in multiplayer it seems like it gets rid of flashlights entirely for clients that AREN'T the server owner and this error log would show up in their console

[Better Flashlight [v1.0]] lua/autorun/sh_better_flashlight.lua:247: attempt to index a nil value

unknown - lua/autorun/sh_better_flashlight.lua:247
unknown - lua/dlib/modules/hook.lua:904 (x738)
Liokindy  [author] 17 Jul @ 8:53pm 
@NyanCatGamer02 Noted. Seems like I forgot to change the convar
Liokindy  [author] 17 Jul @ 8:51pm 
@Enviyon That's supposed to be the default behavior of the flashlight, but it depends on the player-model, some can be done right and some can be bugged so the flashlight is at your feet
Liokindy  [author] 17 Jul @ 8:51pm 
@Dr. Doodle >:) There was. But it was kinda unintuitive went against the idea of making the flashlight always come from the player's POV
Liokindy  [author] 17 Jul @ 8:49pm 
@Topher2009 Noted. I'll try to fix it (I'll see if I can get help from some friends to test it out in multiplayer)
The_male07 16 Jul @ 7:19pm 
this is really cool cause i've always had kind of a problem with how dim the gmod flashlight is and i really like this cause it makes it brighter.
Megatron 15 Jul @ 5:17am 
The name of the map in the video?
Topher2009 14 Jul @ 3:41pm 
mod no longer works in multiplayer
Dr. Doodle >:) 12 Jul @ 4:47am 
Coulda sworn there was an option where you could customize where the light beam shines from...
snzh 11 Jul @ 8:29am 
downgrade