Garry's Mod Wiki

GM:PlayerSwitchFlashlight

boolean GM:PlayerSwitchFlashlight( Player ply, boolean enabled )

Description

Called whenever a player attempts to either turn on or off their flashlight, returning false will deny the change.

Also gets called when using Player:Flashlight.

Arguments

1 Player ply
The player who attempts to change their flashlight state.
2 boolean enabled
The new state the player requested, true for on, false for off.

Returns

1 boolean
Can toggle the flashlight or not

Example

Only allow the flashlight for admins, you can also use Player:AllowFlashlight for that.

hook.Add( "PlayerSwitchFlashlight", "BlockFlashLight", function( ply, enabled ) return ply:IsAdmin() -- Allow the player to use their flashlight if they are an admin end )

Page Links


Special Pages


Wikis

?

Render Time: 54ms

DB GetPage 4
Generate Html 15
SaveChanges (1) 24
Render Body 0
Render Sidebar 9