Raised This Month: $ Target: $400
 0% 

[L4D2] Remove shove penalty when equip pistols?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ddd123
Senior Member
Join Date: May 2021
Old 04-16-2022 , 08:03   [L4D2] Remove shove penalty when equip pistols?
Reply With Quote #1

Hi, i change shove penalty and cooldown (z_gun_swing_coop_max_penalty 10, z_gun_swing_coop_min_penalty 0) to make it sure less spam using shove on every weapons

But i want to make no shove penalty/cooldown on pistol(and magnum/double pistol) to make pistols can be useful if you want to shove from saving incapped survivors

Since, I'm no big coder but after checking this script I think this code can help with removing shove penalty and cooldown.
Code:
int shovePenalty = GetEntProp(client, Prop_Send, "m_iShovePenalty");
if (shovePenalty > g_iShoveMinPenalty)
SetEntProp(client, Prop_Send, "m_iShovePenalty", g_iShoveMinPenalty);
My problem is, how do you enable this code when i using Pistol, Double Pistol and Magnum and disable when you equip something else?

Last edited by ddd123; 04-16-2022 at 08:40.
ddd123 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 04-16-2022 , 09:10   Re: [L4D2] Remove shove penalty when equip pistols?
Reply With Quote #2

Probably you will have to listen to something like OnPlayerRunCmd and reset the client prop for these weapons

Check my plugin [L4D2] Gnome and Cola Shove Damage,
it has a cvar that makes the cola/gnome with an unlimited shove.

PHP Code:
SetEntProp(clientProp_Send"m_iShovePenalty"g_iShoveMinPenalty); 
I don't remember much but I think you have to set it to "max -1" where max is your z_gun_swing_coop_min_penalty cvar.
Otherwise people can swap weapons and use it as a "glitch" for unlimited shove with any weapon.
__________________

Last edited by Marttt; 04-16-2022 at 09:11.
Marttt is offline
ddd123
Senior Member
Join Date: May 2021
Old 04-16-2022 , 12:30   Re: [L4D2] Remove shove penalty when equip pistols?
Reply With Quote #3

Quote:
Originally Posted by Marttt View Post
Probably you will have to listen to something like OnPlayerRunCmd and reset the client prop for these weapons

Check my plugin [L4D2] Gnome and Cola Shove Damage,
it has a cvar that makes the cola/gnome with an unlimited shove.

PHP Code:
SetEntProp(clientProp_Send"m_iShovePenalty"g_iShoveMinPenalty); 
Thank you
Okay, i combine and edit with Martt's script and Timocop's script and i think it work okay, i guess?

I feel like i get more crash and game close without error even more when i go to next chapter after i have this plugin or maybe the other plugins causing this trouble (or maybe coincidence, i really dont know)

Can someone check the script if everything is okay or you can improve more and better without crashes?

Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

new Handle:hConVar_NoShoveEnabled = INVALID_HANDLE;
new Handle:hConVar_NoShoveWeapons = INVALID_HANDLE;

new bool:bEnabled = true;
new String:sAllowedWeapons[64][32];
new iAllowedWeaponsCount = 64;
new iPerf_AllowedWeapon[MAXPLAYERS+1] = 0; //For very good Performance in a loop! [0 = Nothing | 1 = True | 2 = False]
new iPerf_ActiveWeapon[MAXPLAYERS+1] = -1; // For "iPerf_AllowedWeapon"
static int    g_iShoveMinPenalty;

public Plugin:myinfo = 
{
	name = "No shove Pistols",
	author = "ddd123, original code:Timocop and Marttt",
	description = "No shove Pistol (or any weapons)",
	version = "1.0",
	url = "https://forums.alliedmods.net/showthread.php?t=337368"
}

public OnPluginStart()
{

	hConVar_NoShoveEnabled = CreateConVar("l4d_noshovepistols_enabled", "1", "1 - enable / 0 - disable", FCVAR_REPLICATED | FCVAR_NOTIFY );
	hConVar_NoShoveWeapons = CreateConVar("l4d_noshovepistols_weapons", "weapon_pistol;weapon_magnum;weapon_pistol_magnum;magnum", "allow weapons, Use ';' to add more",  FCVAR_REPLICATED | FCVAR_NOTIFY);
	HookConVarChange(hConVar_NoShoveEnabled, ConVarChanged);
	HookConVarChange(hConVar_NoShoveWeapons, ConVarChanged);
	
	AutoExecConfig(true, "l4d_noshove_pistols");
	
	WeaponStringCalculation();
}

public ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
	if(convar == hConVar_NoShoveEnabled)
	{
		bEnabled = GetConVarBool(hConVar_NoShoveEnabled);
	}
	else if(convar == hConVar_NoShoveWeapons)
	{
		WeaponStringCalculation();
	}
}

WeaponStringCalculation()
{
	decl String:sConVarAllowedWeapons[256];
	GetConVarString(hConVar_NoShoveWeapons, sConVarAllowedWeapons, sizeof(sConVarAllowedWeapons));
	
	new iWeaponNumbers = ReplaceString(sConVarAllowedWeapons, sizeof(sConVarAllowedWeapons), ";", ";", false);
	iAllowedWeaponsCount = iWeaponNumbers;

	ExplodeString(sConVarAllowedWeapons, ";", sAllowedWeapons, iWeaponNumbers + 1, 32);
}

public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{ 
	if(!bEnabled)
	return Plugin_Continue;

	if (buttons & IN_ATTACK2)
	{
		if(!IsClientInGame(client)
			|| !IsPlayerAlive(client)
			|| GetClientTeam(client) != 2)
		return Plugin_Continue;

		new iActiveWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
		new bWeaponChanged = ((iActiveWeapon != iPerf_ActiveWeapon[client]) || (iPerf_ActiveWeapon[client] == -1));
		iPerf_ActiveWeapon[client] = iActiveWeapon;
		
		if(bWeaponChanged)
		{
			iPerf_AllowedWeapon[client] = 0;
		}
		
		if(!IsAllowedWeapon(client))
		return Plugin_Continue;

		int shovePenalty = GetEntProp(client, Prop_Send, "m_iShovePenalty");
		if (shovePenalty > g_iShoveMinPenalty)
		{
			SetEntProp(client, Prop_Send, "m_iShovePenalty", g_iShoveMinPenalty);
		}
	}
	/* else
	{
		if(iPerf_AllowedWeapon[client])
		iPerf_AllowedWeapon[client] = 0;
	} */
	return Plugin_Continue;
}

stock bool:IsAllowedWeapon(client)
{
	if(iPerf_AllowedWeapon[client] == 1)
	return true;
	else if(iPerf_AllowedWeapon[client] == 2)
	return false;
	
	decl String:sCurrentWeaponName[32];
	GetClientWeapon(client, sCurrentWeaponName, sizeof(sCurrentWeaponName));
	
	for(new i = 0; i <= iAllowedWeaponsCount; i++)
	{
		if(StrEqual(sAllowedWeapons[i], sCurrentWeaponName, false))
		{
			iPerf_AllowedWeapon[client] = 1;
			return true;
		}
		
	}
	
	iPerf_AllowedWeapon[client] = 2;
	return false;
}
I accidentally name the script "no shove pistols" instead "no shove cooldown/penalty on pistols" but ehhh still only remove the cooldown/penalty

______________________
EDIT: NVM, i think it was other plugins cause the issue
Attached Files
File Type: sp Get Plugin or Get Source (No shove Pistols.sp - 9 views - 3.5 KB)

Last edited by ddd123; 04-17-2022 at 14:55. Reason: smx not required
ddd123 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 04-16-2022 , 16:36   Re: [L4D2] Remove shove penalty when equip pistols?
Reply With Quote #4

Didn't get are you having issues with the script?

Btw you never set a value for "g_iShoveMinPenalty" so it will always be "0"

I usually listen and track which weapon the client is using on "WeaponSwitchPost" because on OnPlayerRunCmd fires too many times in a second. (basically every frame if the client is pressing some button)
__________________
Marttt 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 22:01.


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