View Single Post
Author Message
dcx2
Senior Member
Join Date: Sep 2011
Old 12-10-2011 , 00:58   [L4D2] Keep Laser Sights (v1.4, 2023 April 11)
Reply With Quote #1

When I find laser sights, I want to keep them, even if I switch guns. Why can't I just take the laser sight off one and put it onto the other gun?

So I wrote this plugin. When a player drops a weapon, it checks to see if there's a laser sight on it. If there is, it removes the laser sight from the dropped gun and adds it to whatever gun was picked up.

This only works if you already have laser sights. It won't give you laser sights if you don't already have them.

This is my first plugin so let me know if there's anything I can do to improve it. Thanks to Mr. Zero for l4dstocks.

EDIT:

2011-Dec-18 (version 1.1): fixed "gun spawn spam glitch". Also added cvar to remove hint. 71 views

EDIT2:

Still a bit nooby at this sourcemod stuff. I realized that this plugin does not require SDKHooks. It uses sdktools instead, so the web compiler works fine, therefore I removed the precompiled smx.

EDIT3:

2012-Jan-7 (version 1.2): Added a cvar for mode; Swap, Keep, or Always. See below.

PLANS:

1) Preserve other upgrades (fire ammo, explosive ammo)

CVARS:

sm_keeplasers_enable - default 1 - enables this plugin
sm_keeplasers_nohint - default 1 - disables hint on receiving laser sights
sm_keeplasers_mode - default 0 -
0 = Swap laser sights from dropped gun to current gun; if no current gun (e.g. player died), old gun keeps lasers.
1 = Keep laser sights once found, even if player dies and respawns
2 = Always give players laser sights, even if they were never found
sm_keeplasers_debug - default 0 - print debugging output to chat

UPGRADING:

If upgrading, backup any modifications made to [game]/cfg/sourcemod/L4D2_KeepLasers.cfg, then delete that file and restart your server. The file will be auto-created again with the new cvars. Modify as needed.
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_keeplasers.sp - 720 views - 14.2 KB)

Last edited by dcx2; 04-11-2023 at 16:04. Reason: version 1.4
dcx2 is offline