Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
|
02-12-2019
, 20:27
[L4D1 & L4D2] Laser that never sucks (useful upgrades)
|
#1
|
Author: Figa (fork by Dragokas)
Description:
These are 4 upgrades any client can manually enable/disable at any time:
- Laser Sight
- Night Vision
- Silencer (L4D1 only)
- Fast Reload (L4D1 only)
All upgrades are made permanently per-client, not per-weapon (and saved to cookies, loaded on client re-join).
Why one more plugin?
- Most plugins for laser in L4D1 cause clients to crash on some servers. This fork uses SDK-method that works fine all the time.
Restrictions:
- for L4D2 only Laser & Night Vision are available at the moment.
- for L4D2 it is impossible to remove crosshair due to the protected client-side command "crosshair 0". I also tried to change the different hud properties of the client, but they don't have the desired effect.
Specific:
- Plugin is blocking perk sound automatically when you equip the upgrade.
- atm, plugin cannot block the secondary sound (in L4D2) and game hint (on-screen message and sound) (L4D2) when you equip/re-equip weapon with upgrade. Need help.
Commands: sm_laser - Toggle Laser Sight
sm_laseron - Turn on the laser
sm_laseroff - Turn off the laser
sm_night - Toggle Night Vision
sm_silent - Toggle Silencer (L4D1 only)
sm_silencer - same
sm_reload - Toggle Fast Reload (L4D1 only)
Settings (ConVars): - cfg/sourcemod/l4d_useful_upgrades.cfg:
l4d_enable_silencer - def.: 1 - Enable Toggle Silencer Upgrade; 0 - Disable This Upgrade
l4d_enable_laser_sight - def.: 1 - Enable Toggle Laser Sight Upgrade; 0 - Disable This Upgrade
l4d_enable_night_vision - def.: 1 - Enable Toggle Night Vision Upgrade; 0 - Disable This Upgrade
l4d_enable_fast_reload - def.: 1 - Enable Toggle Fast Reload Upgrade; 0 - Disable This Upgrade
l4d_force_spawn_silencer - def.: 0 - Force Silencer Upgrade on spawn (0 - No, 1 - Yes)
l4d_force_spawn_laser_sight - def.: 0 - Force Laser Sight Upgrade on spawn (0 - No, 1 - Yes)
l4d_force_spawn_night_vision - def.: 0 - Force Night Vision Upgrade on spawn (0 - No, 1 - Yes)
l4d_force_spawn_fast_reload - def.: 1 - Force Fast Reload Upgrade on spawn (0 - No, 1 - Yes)
l4d_force_join_silencer - def.: 1 - Force Silencer Upgrade on first join (0 - No, 1 - Yes)
l4d_force_join_laser_sight - def.: 1 - Force Laser Sight Upgrade on first join (0 - No, 1 - Yes)
l4d_force_join_night_vision - def.: 0 - Force Night Vision Upgrade on first join (0 - No, 1 - Yes)
l4d_force_join_fast_reload - def.: 1 - Force Fast Reload Upgrade on first join (0 - No, 1 - Yes)
l4d_upgrades_remove_dropped_laser - def.: 1 - Auto switch off laser on the dropped weapon (0 - No, 1 - Yes) (L4D2 only)
- cfg/server.cfg (L4D1)
sm_cvar survivor_upgrade_reload_shotgun_duration "0.6" // default value - control shotgun reload speed if upgrade is enabled
sm_cvar survivor_upgrade_reload_duration "1" // default value - control other weapons reload animation speed if upgrade is enabled
Natives & Forwards
Spoiler
PHP Code:
forward void OnUpgradeChanged(int iClient, int iUpgrade);
native int UU_GetUpgrades(int iClient);
native int UU_SetUpgrades(int iClient, int iUpgradeBits);
public void UU_AddUpgrade(int iClient, int iUpgradeBits)
public void UU_RemoveUpgrade(int iClient, int iUpgradeBits)
For details, see: include/ useful_upgrades.inc file.
Usage sample:
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#undef REQUIRE_PLUGIN
#include <useful_upgrades>
public void OnPluginStart()
{
RegConsoleCmd("sm_al", CmdAddLaser, "Adds laser");
RegConsoleCmd("sm_rl", CmdRemoveLaser, "Removes laser");
RegConsoleCmd("sm_special", CmdSpecial, "Set laser, fast reload and silencer, removes night vision");
RegConsoleCmd("sm_print", CmdPrint, "Prints currently equipped upgrades");
}
public Action CmdAddLaser(int client, int args)
{
if( IsUpgradesLoaded() )
{
UU_AddUpgrade(client, LASER_BIT);
}
else {
ReplyToCommand(client, "Upgrades are unavailable!");
}
return Plugin_Handled;
}
public Action CmdRemoveLaser(int client, int args)
{
if( IsUpgradesLoaded() )
{
UU_RemoveUpgrade(client, LASER_BIT);
}
else {
ReplyToCommand(client, "Upgrades are unavailable!");
}
return Plugin_Handled;
}
public Action CmdSpecial(int client, int args)
{
if( IsUpgradesLoaded() )
{
UU_SetUpgrades(client, LASER_BIT | RELOAD_BIT | SILENCER_BIT); // &~ NIGHT_BIT
}
else {
ReplyToCommand(client, "Upgrades are unavailable!");
}
return Plugin_Handled;
}
public Action CmdPrint(int client, int args)
{
if( IsUpgradesLoaded() )
{
int iUpgradeBits = UU_GetUpgrades(client);
ReplyToCommand(client, "You have the following upgrades: (bits %i, 0x%X)", iUpgradeBits, iUpgradeBits);
if( iUpgradeBits & LASER_BIT )
{
ReplyToCommand(client, "Laser");
}
if( iUpgradeBits & RELOAD_BIT )
{
ReplyToCommand(client, "Fast reload");
}
if( iUpgradeBits & SILENCER_BIT )
{
ReplyToCommand(client, "Silencer");
}
if( iUpgradeBits & NIGHT_BIT )
{
ReplyToCommand(client, "Night vision");
}
}
else {
ReplyToCommand(client, "Upgrades are unavailable!");
}
return Plugin_Handled;
}
bool IsUpgradesLoaded()
{
return GetFeatureStatus(FeatureType_Native, "UU_SetUpgrades") == FeatureStatus_Available;
}
Translations: - English
- Russian
- Spanish
Credits: - Figa - original author
- Whosat - for SDK-method of laser activation
- AlexMy - helping with crash fix
- SilverShot - helping with crash fix and for patch example
- Krivous Anatolii (The Trick) - resolving Windows crash in NOP patch
- dcx2 - for code to manipulate laser on the weapon in L4D2.
TODO:
- disable annoying instructor hints in L4d2.
- find a method to enable laser for any weapon in L4d2.
DonateDonates are very appreciated and welcomed for further inspiration, make me happy, and make next updates came out more often:
- Patreon (Paypal)
- BitCoin
- Ю.Money
__________________
Last edited by Dragokas; 02-08-2023 at 08:50.
|
|