Raised This Month: $12 Target: $400
 3% 

[L4D & L4D2] Flashlight (2.31) [23-Jan-2024]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Plugin ID:
2693
Plugin Version:
2.31
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    144 
    Plugin Description:
    Attaches a flashlight to survivors. Spectators can have personal lights only they can see.
    Old 12-02-2011 , 17:53   [L4D & L4D2] Flashlight (2.31) [23-Jan-2024]
    Reply With Quote #1


    This plugin was originally part of the Flare and Light Package. I have seperated the Flare, Flashlight and Flare Gun into new plugins.



    Thanks:
    • SilentBr - for the idea and request.
    • Mr.RuyC - For recording videos and playing for hours and hours testing the plugin on his server.
    • nakashimakun - Who came up with the plugin name. Also tested the plugin on his server.
    • honorcode23, DJ_WEST, AtomicStryker, Boikinov, pimpinjuice and FoxMulder for source code (full credits inside the source).
    • NanX, japan555, CeeJ, Farmer, SilentBr, sapphire989, Visual77, Mr. Man and everyone else who helped testing, it's been fun!
    • disawar1 - Testing 2.0 and Russian translations.
    • Januto - Spanish translations.
    • Dont Fear The Reaper - German translations.



    Details:
    • Attaches flashlights to survivors.
    • Special Infected can now use. See the l4d_flashlight_users cvar.
    • Spectators and dead players can have a personal flashlight only they can see.
    • Saves clients flashlight color and on/off state.
    • Flashlight colors can be locked so players cannot change. Put the cvar l4d_flashlight_lock to 1 and it will force the colors to what you specified in the config.
    • Checks the command access overrides for "sm_light" as well as providing cvars to control access flags.



    Player commands:

    PHP Code:
    sm_light        // Toggle the attached flashlight. Usage: sm_light [R G B|off|random|bow|red|green|blue|purple|cyan|orange|white|pink|lime|maroon|teal|yellow|grey]
    sm_lightmenu    // Opens the flashlight color menu.

    sm_lightbow     // Toggle the attached flashlight with rainbow changing colors.

    // Examples:
    sm_light 255 0 0     // Makes your flashlight red
    sm_light purple      // Makes your flashlight purple 


    Admin Commands: (requires "z" flag)

    PHP Code:
    sm_lightclient // Turn on/off the flashlight on specified player. Usage: sm_lightclient <#user id|name> [R G B|off|random|bow|red|green|blue|purple|cyan|orange|white|pink|lime|maroon|teal|yellow|grey]

    // Examples:
    sm_lightclient Roch 0 0 255     // Makes Rochelle's light blue
    sm_lightclient Nick green       // Makes Nick's light green
    sm_lightclient @survivors       // Toggles the flashlights on all survivors. 


    CVars:

    Saved to l4d_flashlight.cfg in your servers \cfg\sourcemod\ folder.

    PHP Code:
    // 0=Plugin off, 1=Plugin on.
    l4d_flashlight_allow "1"

    // Brightness of the light for Survivors <10-255> (changes Distance value)
    // Minimum: "10.000000" Maximum: "255.000000"
    l4d_flashlight_bright "255.0"

    // Brightness of the light for Special Infected <10-255> (changes Distance value).
    // Minimum: "10.000000" Maximum: "255.000000"
    l4d_flashlight_brights "255.0"

    // The default light color. Three values between 0-255 separated by spaces. RGB Color255 - Red Green Blue.
    l4d_flashlight_colour "200 20 15"

    // Players with these flags may use the sm_light command. (Empty = all).
    l4d_flashlight_flags ""

    // 0=Off, 1=Show intro message to players entering spectator.
    l4d_flashlight_hints "1"

    // 0=Off, Show intro message in chat this many seconds after joining.
    // Minimum: "0.000000" Maximum: "120.000000"
    l4d_flashlight_intro "35.0"

    // 0=Let players set their flashlight color, 1=Force to cvar specified.
    l4d_flashlight_lock "0"

    // Turn on the plugin in these game modes, separate by commas (no spaces). (Empty = all).
    l4d_flashlight_modes ""

    // Turn off the plugin in these game modes, separate by commas (no spaces). (Empty = none).
    l4d_flashlight_modes_off ""

    // Turn on the plugin in these game modes. 0=All, 1=Coop, 2=Survival, 4=Versus, 8=Scavenge. Add numbers together.
    l4d_flashlight_modes_tog "0"

    // Empty = Allow all. 0=Block on all maps. Prevent displaying the model on these maps, separate by commas (no spaces).
    l4d_flashlight_precach "c1m3_mall"

    // Allow players to use the sm_lightbow command for rainbow changing colors. 0=Off. 1=Survivors. 2=Special Infected. 3=Both.
    l4d_flashlight_rainbow "3"

    // Speed of rainbow colors changing. Smaller value = slower. Larger value = faster.
    l4d_flashlight_rainbows "1.0"

    // 0=Off, 1=Save client preferences for flashlight color and state.
    l4d_flashlight_save "1"

    // 0=Off, 1=Spectators, 2=Survivors, 4=Infected, 7=All. Give personal flashlights when dead which only they can see.
    l4d_flashlight_spec "7"

    // 1=Survivors, 2=Infected, 3=All. Allow these players when alive to use the flashlight.
    l4d_flashlight_users "1"

    // Flashlight plugin version.
    l4d_flashlight_version 


    Changes:
    Code:
    2.31 (23-Jan-2024)
        - Fixed various issues when using the commands due to the rainbow update. Should toggle, turn off or change correctly for all commands.
        - Fixed issues with saving the light state on or off.
        - Updated and fixed the "chi" translation file. Thanks to "Shimo" for fixing.
    
    2.30 (21-Dec-2023)
        - The rainbow activated state will now save and load.
        - Commands "sm_light" and "sm_lightclient" now accept the option "bow" to turn on the rainbow.
        - Thanks to "Hawkins" and "JustMadMan" for help testing.
    
    2.29 (20-Dec-2023)
        - Added cvar "l4d_flashlight_rainbow" to allow or disallow rainbow changing colors.
        - Added cvar "l4d_flashlight_rainbows" to set the rainbow color speed.
        - Added command "sm_lightbow" to enable/disable the rainbow color.
        - Requested by "JustMadMan". Thanks to "King_OxO" for the code this was based on.
    
    2.28 (01-Oct-2023)
        - Now sets the clients saved color if they spawned before client prefs were loaded. Thanks to "kochiurun119" for reporting.
    
    2.27 (25-May-2023)
        - Fixed the default light color not setting when new players join. Thanks to "iciaria" for reporting.
    
    2.26 (22-Nov-2022)
        - No longer shows the flashlight of the player you're spectating. Thanks to "yabi" for reporting.
    
    2.25 (30-Sep-2022)
        - Plugin now deletes the client cookie if they no longer have access to use the flashlight. Requested by "maclarens".
    
    2.24 (19-Aug-2022)
        - Added cvar "l4d_flashlight_brights" to control the brightness of lights for Special Infected. Requested by "A1ekin".
        - Changed the light position on Special Infected and Spectators in an attempt to fix lighting the area. Thanks to "A1ekin" for reporting.
    
    2.23 (01-May-2022)
        - Added a 1 second delay before creating a light on spawn, to avoid the light flashing once. Thanks to "Ja-Forces" for reporting.
    
    2.22 (15-Jan-2022)
        - Fixed not saving light state across map changes. Thanks to "NoroHime" for reporting.
    
    2.21 (01-Jan-2022)
        - Fixed not setting the default color when "l4d_flashlight_default" is "1" and "l4d_flashlight_random" is "0". Thanks to "kalmas77" for reporting.
    
    2.20 (25-Dec-2021)
        - Fixed command "sm_light <color>" not changing the color. Thanks to "Shadowart" for reporting.
        - Fixed cvar "l4d_flashlight_default" not restricting bots when set to "1". Thanks to "Shadowart" for reporting.
    
    2.19 (09-Dec-2021)
        - Changes to fix warnings when compiling on SourceMod 1.11.
        - Changed command "sm_light" to accept "rand" or "random" as a parameter option to give a random light color. Requested by "NoroHime".
        - Code change includes completely random color instead of specified from the list. Uncomment and delete other code if you want this instead.
    
    2.18 (18-Sep-2021)
        - Menu now returns to the page it was on before selecting an option. Requested by " Shadowart".
    
    2.17 (04-Aug-2021)
        - Changed the plugin to allow bots to use the color cvar when _default cvar is enabled _random cvar was disabled.
    
    2.16 (31-Jul-2021)
        - Added cvar "l4d_flashlight_default" to turn on the flashlight by default when spawning.
        - Added cvar "l4d_flashlight_random" to give random colors when spawning.
    
    2.15 (11-Jul-2021)
        - Fixed the Special Infected light being visible to others. Thanks to "A1ekin" for reporting.
    
    2.14 (11-Jul-2021)
        - Added cvar "l4d_flashlight_users" to control if Survivors and Special Infected can use the plugins light.
        - Fixed the Survivors spectator light attaching to their dead body and not themselves.
    
    2.13 (01-Jul-2021)
        - Added a warning message to suggest installing the "Attachments API" and "Use Priority Patch" plugins if missing.
    
    2.12 (28-Apr-2021)
        - Changed command "sm_light" to accept "off" param to turn off the light. Thanks to "Dragokas" for requesting.
    
    2.11 (09-Oct-2020)
        - Changed "OnClientPostAdminCheck" to "OnClientPutInServer" - to fix any issues if Steam service is down.
    
    2.10 (18-Sep-2020)
        - Added cookie preferences to save player flashlight color and state. Thanks to "GoGetSomeSleep" for requesting.
        - Added cvar "l4d_flashlight_save" to control if the server can save and load client preferences.
    
    2.9 (10-May-2020)
        - Extra checks to prevent "IsAllowedGameMode" throwing errors.
        - Increased "l4d_flashlight_precach" cvar length, max usable length 485 (due to game limitations).
        - Various changes to tidy up code.
    
    2.8 (01-Apr-2020)
        - Fixed "IsAllowedGameMode" from throwing errors when the "_tog" cvar was changed before MapStart.
        - Removed "colors.inc" dependency.
        - Updated these translation file encodings to UTF-8 (to display all characters correctly): Hungarian (hu).
    
    2.7.1 (07-Jan-2020)
        - Fixed "sm_light" not working with color names because 2 args were the wrong way round. Thanks to "K4d4br4" for reporting.
    
    2.7 (19-Dec-2019)
        - Added command "sm_lightmenu" to display a menu and select light color. No translations support.
        - Added cvar "l4d_flashlight_precach" to prevent displaying the model on specific maps. Or "0" for all.
        - Added to "sm_light" and "sm_lightclient" additional colors by name: "cyan" "pink" "lime" "maroon" "teal" "grey".
    
    2.6.1 (21-Jul-2018)
        - Added Hungarian translations - Thanks to KasperH.
        - No other changes.
    
    2.6.1 (18-Jun-2018)
        - Fixed errors, thanks to "ReCreator" for reporting and testing.
    
    2.6 (05-May-2018)
        - Converted plugin source to the latest syntax utilizing methodmaps. Requires SourceMod 1.8 or newer.
        - Changed cvar "l4d_flashlight_modes_tog" now supports L4D1.
    
    2.5.1 (19-Nov-2015)
        - Fix to prevent garbage being passed into SetVariantString, as suggested by "KyleS".
    
    2.5 (25-May-2012)
        - Added more checks to events, preventing errors being logged.
    
    2.4 (22-May-2012)
        - Fixed cvar "l4d_flashlight_spec" enums mistake, thanks to "Dont Fear The Reaper".
        - Fixed errors being logged on player spawn event when clients were not in game.
    
    2.3 (22-May-2012)
        - Changed cvar "l4d_flashlight_spec". The cvar is now a bit flag, add the numbers together.
        - Fixed cvar "l4d_flashlight_spec" blocking alive survivors from using the flashlight.
    
    2.2 (20-May-2012)
        - Changed cvar "l4d_flashlight_spec". You can now specify which teams can use spectator lights.
        - Added German translations - Thanks to "Dont Fear The Reaper".
    
    2.1 (30-Mar-2012)
        - Added Spanish translations - Thanks to "Januto".
        - Added cvar "l4d_flashlight_modes_off" to control which game modes the plugin works in.
        - Added cvar "l4d_flashlight_modes_tog" same as above, but only works for L4D2.
        - Added cvar "l4d_flashlight_hints" which displays the "intro" message to spectators if spectator lights are enabled.
        - Changed the way "l4d_flashlight_flags" validates clients by checking they have one of the flags specified.
        - Fixed the "sm_lightclient" command not affecting all clients.
        - Fixed the "sm_light" command not working for spectators.
        - Fixed ghost players still having flashlights.
        - Small changes and fixes.
    
    2.0 (02-Dec-2011)
        - Plugin separated and taken from the "Flare and Light Package" plugin.
        - Added Russian translations - Thanks to "disawar1".
        - Added personal flashlights for spectators and dead players. The light is invisible to everyone else.
        - Added cvar "l4d_flashlight_spec" to control if spectators should have personal flashlights.
        - Added the following triggers to specify colors with sm_light: red, green, blue, purple, orange, yellow, white.
        - Saves players flashlight on/off state and colors on map change.
    
    1.0 (29-Jan-2011)
        - Initial release.


    Compiling:
    1. Put the plugins .sp file into your scripting folder and compile the plugin.


    Installation:
    • Download the .zip and extract the files to their respective folders in your servers \addons\sourcemod\ folder.
    • Install the Use Priority Patch plugin to prevent blocking +USE.
    • Optional: Install the Attachment_API plugin to fix attachment positions breaking on model change.

    Updating from 2.28 or older:
    • New cvars have been added: use the Cvar Configs Updater, or delete the old cvars config or manually add them.

    Current Translations: English (en), German (de), Hungarian (hu), Russian (ru), Spanish (es).
    Attached Files
    File Type: zip l4d_flashlight.zip (38.7 KB, 252 views)
    __________________

    Last edited by Silvers; 01-23-2024 at 10:16.
    Silvers is offline
    Dont Fear The Reaper
    Member
    Join Date: Nov 2011
    Old 12-17-2011 , 07:12   Re: [L4D & L4D2] Flashlight (2.0) [02-Dec-2011]
    Reply With Quote #2

    Great work once again

    I didn't notice any bugs so far. To support you a little bit i've attached the german translation. I'll look through your other plugins aswell to see if i can do it for them too since i'm using quite some of them (no need to mention we like them i guess, well now i did anyway )
    Attached Files
    File Type: txt flashlight.phrases.txt (508 Bytes, 1366 views)
    Dont Fear The Reaper is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 12-17-2011 , 07:57   Re: [L4D & L4D2] Flashlight (2.0) [02-Dec-2011]
    Reply With Quote #3

    Thank you very much
    __________________
    Silvers is offline
    TheHyena
    Junior Member
    Join Date: Dec 2011
    Old 02-10-2012 , 10:14   Re: [L4D & L4D2] Flashlight (2.0) [02-Dec-2011]
    Reply With Quote #4

    does this make it so that i can see others flashlights shine on objects? ie. Nick lighting up area ahead of me?
    TheHyena is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 02-10-2012 , 11:29   Re: [L4D & L4D2] Flashlight (2.0) [02-Dec-2011]
    Reply With Quote #5

    It attaches a flashlight to the survivors left hip. I've fixed the screenshot which was missing.
    __________________
    Silvers is offline
    bubbabyte
    Member
    Join Date: Jun 2010
    Old 02-24-2012 , 15:38   Re: [L4D & L4D2] Flashlight (2.0) [02-Dec-2011]
    Reply With Quote #6

    no matter what i do i cannot get this to be admin/donator only.. i set the flag to "z" in the cfg but still everyone is able to use it, what am i doing wrong?
    bubbabyte is offline
    asto
    Member
    Join Date: Aug 2010
    Old 03-01-2012 , 12:15   Re: [L4D & L4D2] Flashlight (2.0) [02-Dec-2011]
    Reply With Quote #7

    This plugin can be the solution for this problem:
    http://forums.alliedmods.net/showthread.php?t=149311

    This plugin would be the best if it could replace the original flashlight.

    Just need to change these things:
    1. Disable the original flashlight by mp_flashlight 0 cvar.
    2. Put the position of light to the player's eye/crosshair position.
    asto is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 03-30-2012 , 07:29   Re: [L4D & L4D2] Flashlight (2.1) [30-Mar-2012]
    Reply With Quote #8

    Plugin updated:

    2.1 (30-Mar-2012)
    - Added Spanish translations - Thanks to Januto.
    - Added cvar "l4d_flashlight_modes_off" to control which game modes the plugin works in.
    - Added cvar "l4d_flashlight_modes_tog" same as above, but only works for L4D2.
    - Added cvar "l4d_flashlight_hints" which displays the "intro" message to spectators if spectator lights are enabled.
    - Changed the way "l4d_flashlight_flags" validates clients by checking they have one of the flags specified.
    - Fixed the "sm_lightclient" command not affecting all clients.
    - Fixed the "sm_light" command not working for spectators.
    - Fixed ghost players still having flashlights.
    - Small changes and fixes.

    @bubbabyte this should fix the issue you were having.
    __________________
    Silvers is offline
    bubbabyte
    Member
    Join Date: Jun 2010
    Old 03-30-2012 , 14:26   Re: [L4D & L4D2] Flashlight (2.1) [30-Mar-2012]
    Reply With Quote #9

    yes it did, thanks so much for the update
    bubbabyte is offline
    Dont Fear The Reaper
    Member
    Join Date: Nov 2011
    Old 05-17-2012 , 14:43   Re: [L4D & L4D2] Flashlight (2.1) [30-Mar-2012]
    Reply With Quote #10

    In your "player_team" hook in line 403 you accidentally check "if( team == 0 ...)" instead of 1 for team spectator which prevents spectators to automatically get a light attached to them.

    And one error i got:
    Code:
    L 05/17/2012 - 00:19:36: Info (map "c4m4_milltown_b") (file "errors_20120517.log")
    L 05/17/2012 - 00:19:36: [SM] Native "GetClientTeam" reported: Client index 0 is invalid
    L 05/17/2012 - 00:19:36: [SM] Displaying call stack trace for plugin "l4d_flashlight.smx":
    L 05/17/2012 - 00:19:36: [SM]   [0]  Line 389, C:\SRCDS\left4dead2\left4dead2\addons\sourcemod\scripting\l4d_flashlight.sp::Event_Spawn()

    Last edited by Dont Fear The Reaper; 05-17-2012 at 14:50.
    Dont Fear The Reaper is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 21:26.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode