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

[L4D & L4D2] Multiple Equipments


Post New Thread Reply   
 
Thread Tools Display Modes
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-11-2016 , 04:44   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #171

Quote:
Originally Posted by MasterMind420 View Post
Added M60 reserve ammo workaround, just needs a reload animation when the clip empties. Eventually i'll get to it.
You don't have to, m60's reloading animation is just the same as the m16's. Although I noticed some plugins use m_iClip1 for the reserve ammo, but for me I use:
Code:
SetEntProp(gun, Prop_Send, "m_iExtraPrimaryAmmo", GetConVarInt(FindConVar("ammo_m60_max")), 4);
but when I use:
Code:
SetEntProp(gun, Prop_Data, "m_iClip1", GetConVarInt(FindConVar("ammo_m60_max")), 1);
it just messes up or creates a glitch in the game that instead of really 999 or any value of the reserved ammo, the current ammo displayed on the game is only limited to 231 and when it becomes zero then you try to shoot, it will display ?34 and eventually that would be a cause for server crash.

I know I tried. And also if you want players to have reserve ammo if they press +USE on ammo piles for grenade launchers and m60s, add this one (It also has fix for weapons with reduced current ammo):
Code:
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
	if (buttons & IN_USE && !buttondelay[client])
	{
		buttondelay[client] = true;
		CreateTimer(2.0, ResetDelay, client); // to prevent multiple checkings..
		
		new gun = GetClientAimTarget(client, false);
		if (gun < 32)
		{
			return Plugin_Continue;
		}
		
		if (!IsValidEdict(gun))
		{
			return Plugin_Continue;
		}
		
		decl String:ent_name[64];
		GetEdictClassname(gun, ent_name, sizeof(ent_name));
		
		new oldgun = GetPlayerWeaponSlot(client, 0);
		if (!IsValidEdict(oldgun))
		{
			return Plugin_Continue;
		}
		
		decl String:currentgunname[64];
		GetEdictClassname(oldgun, currentgunname, sizeof(currentgunname));
		
		if (StrEqual(ent_name, "weapon_ammo_spawn", false))
		{
			if (StrEqual(currentgunname, "weapon_grenade_launcher", false))
			{
				new iAmmoOffset = FindDataMapOffs(client, "m_iAmmo");
				SetEntData(client, iAmmoOffset + (68), GetConVarInt(FindConVar("ammo_grenadelauncher_max")));
			}
			else if (StrEqual(currentgunname, "weapon_rifle_m60", false))
			{
				SetEntProp(oldgun, Prop_Send, "m_iExtraPrimaryAmmo", GetConVarInt(FindConVar("ammo_m60_max")), 4);
			}
		}
		
		if (!StrEqual(ent_name, currentgunname))
		{
			return Plugin_Continue;
		}
		
                // fix for weapons to have extra reserve ammo proportional to the reduced current ammo
                // (i.e Scout sniper has 140 reserve ammo and current ammo is 12, when ammo piles are used, reserve ammo will be 183 since its max reserved ammo is 180 and max current ammo is 15)
		new iAmmoOffset = FindDataMapOffs(client, "m_iAmmo");
		decl offsettoadd, maxammo;
		
		if (StrEqual(ent_name, "weapon_rifle", false) || StrEqual(ent_name, "weapon_rifle_ak47", false) || StrEqual(ent_name, "weapon_rifle_desert", false) || StrEqual(ent_name, "weapon_rifle_sg552", false))
		{
			offsettoadd = 12;
			maxammo = GetConVarInt(FindConVar("ammo_assaultrifle_max"));	
		}
		else if (StrEqual(ent_name, "weapon_smg", false) || StrEqual(ent_name, "weapon_smg_silenced", false) || StrEqual(ent_name, "weapon_smg_mp5", false))
		{
			offsettoadd = 20;
			maxammo = GetConVarInt(FindConVar("ammo_smg_max"));
		}		
		else if (StrEqual(ent_name, "weapon_pumpshotgun", false) || StrEqual(ent_name, "weapon_shotgun_chrome", false))
		{
			offsettoadd = 28;
			maxammo = GetConVarInt(FindConVar("ammo_shotgun_max"));
		}
		else if (StrEqual(ent_name, "weapon_autoshotgun", false) || StrEqual(ent_name, "weapon_shotgun_spas", false))
		{
			offsettoadd = 32;
			maxammo = GetConVarInt(FindConVar("ammo_autoshotgun_max"));
		}
		else if (StrEqual(ent_name, "weapon_hunting_rifle", false))
		{
			offsettoadd = 36;
			maxammo = GetConVarInt(FindConVar("ammo_huntingrifle_max"));
		}
		else if (StrEqual(ent_name, "weapon_sniper_military", false) || StrEqual(ent_name, "weapon_sniper_awp", false) || StrEqual(ent_name, "weapon_sniper_scout", false))
		{
			offsettoadd = 40;
			maxammo = GetConVarInt(FindConVar("ammo_sniperrifle_max"));
		}
		else if (StrEqual(ent_name, "weapon_grenade_launcher", false))
		{
			offsettoadd = 68;
			maxammo = GetConVarInt(FindConVar("ammo_grenadelauncher_max"));
		}
		else // don't add m60 to this, another server crash will happen.
		{
			return Plugin_Continue;
		}
		
                // if reserved ammo plus taken current ammo is exact to max reserved ammo, don't add anymore.
		new currentammo = GetEntData(client, (iAmmoOffset + (offsettoadd)));
		if (currentammo >= maxammo)
		{
			return Plugin_Continue;
		}
	}
	
	return Plugin_Continue;
}

Last edited by cravenge; 04-11-2016 at 05:24.
cravenge is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-11-2016 , 05:18   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #172

Okay, I looked at your gun control plugin code but something bothered me when I saw this one:
Code:
new PrimType = GetEntProp(oldgun, Prop_Data, "m_iPrimaryAmmoType");
SetEntProp(client, Prop_Send, "m_iAmmo", - GetConVarInt(M60AmmoReserveCVAR), _, PrimType);
SetEntProp(client, Prop_Send, "m_iAmmo", GetConVarInt(M60AmmoReserveCVAR), _, PrimType);
SetEntProp(oldgun, Prop_Data, "m_iClip1", - GetConVarInt(M60AmmoCVAR), 1);
SetEntProp(oldgun, Prop_Data, "m_iClip1", GetConVarInt(M60AmmoCVAR), 1);
SetEntPropFloat(oldgun, Prop_Send, "m_flNextPrimaryAttack", GetGameTime());
PrintHintText(client, "M60 Reloaded");
I found it unusually odd.

You said you could reload m60 visually in game but what kind of visual (when pressing RELOAD, change the ammo count directly or you can reload with animation)? If you use my code from previous post, you can add reserve ammo and reload the m60 normally with animations but the animation will be like m16 reloading and with or without current ammo.

Also, I think you need to remove this one too as when I used it, I saw bots with weird animations when reloading:
Code:
new weapon = GetPlayerWeaponSlot(client, 0);
if(IsValidEdict(weapon))
{
	new String:sClassName[64];
	GetEdictClassname(weapon, sClassName, sizeof(sClassName));
	SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime());
	PrintHintText(client, "Grenade Launcher Reloaded");
}

Last edited by cravenge; 04-11-2016 at 05:25.
cravenge is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-11-2016 , 06:21   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #173

Anyways, I uploaded a variety of plugins which fixes all problems about M60s and Grenade Launchers. Mastermind, you can find the code I posted in that plugin.
cravenge is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-11-2016 , 12:27   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #174

I appreciate all the advice I will look into them. Especially grateful for SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", GetConVarInt(FindConVar("ammo_m60_max")), 4); I did not know that, good stuff...however I think you miss the purpose of what i'm doing. I don't want the M60 to be able to reload anytime, I want it to reload when it reaches the 1 bullet, stops the gun from firing, so it doesn't drop, then force it to reload. I attempted to prevent the reload using that tidbit of code, by placing arguments however it wouldn't seem to abide by them. If its in the code, you can reload period. Reloading inbetween is a mess and quite frankly not something code wise I wanna deal with, your code is fine, but why use extra code if I don't need to, as of right now it just pulls the reserve and keeps going, I would rather deal with that than people reloading and screwing up the drop fix.

new PrimType = GetEntProp(oldgun, Prop_Data, "m_iPrimaryAmmoType");
SetEntProp(client, Prop_Send, "m_iAmmo", - GetConVarInt(M60AmmoReserveCVAR), _, PrimType);
SetEntProp(client, Prop_Send, "m_iAmmo", GetConVarInt(M60AmmoReserveCVAR), _, PrimType);
SetEntProp(oldgun, Prop_Data, "m_iClip1", - GetConVarInt(M60AmmoCVAR), 1);
SetEntProp(oldgun, Prop_Data, "m_iClip1", GetConVarInt(M60AmmoCVAR), 1);
SetEntPropFloat(oldgun, Prop_Send, "m_flNextPrimaryAttack", GetGameTime()); This allows the gun to be fired again after the dropfix implemented
PrintHintText(client, "M60 Reloaded");

This section here is to reload at ammo pile reserve and clip, but also prevents abusing it, getting more ammo than allowed, simple remove all ammo from the gun then fully reload it with reserve and clip. Also reloading the M60 at ammo piles will always abide by what is set in the M60AmmoCVAR and M60AmmoReserveCVAR, if you change it to 200 and 100 or vice versa, it will always abide by that...

Thanks for the tip on the grenade launcher ammo reload, I will look into this, it is necessary because without it, there would be a problem with firing the grenade launcher after the 1 bullet fix implements, because it stops the gun from shooting, even after a reload at ammo pile, unless you shove, then strangely enough it works, however that is undesirable to do everytime you reload, so that code disables the 1 bullet stop code from Multiple Equipments, without it you would lose your switching ability in your primary slot because the weapon would go to 0 ammo and be unselectable, even the second primary would be unreachable...Any advice or tips is greatly appreciated...

Last edited by MasterMind420; 04-11-2016 at 12:41.
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-11-2016 , 13:53   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #175

My code manipulates the ammo count, doesn't actually reload...when you said you had issues with bots with that code in GunControl for the Grenade Launcher, what did you mean? While your getting more ammo at the ammo pile? or while bots get more ammo at the ammo pile? And do you use the plugin that allows bots to use M60 or Grenade Launcher?

I added this...

if(IsValidEdict(weapon) && !IsFakeClient(client))
{
new String:sClassName[64];
GetEdictClassname(weapon, sClassName, sizeof(sClassName));
SetEntPropFloat(weapon, Prop_Send, "m_flNextPrimaryAttack", GetGameTime());
PrintHintText(client, "Grenade Launcher Reloaded");
}

i've never seen that issue you described and i've reloaded at the ammo pile hundreds of times...but this may help if its the bots reloading...
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-11-2016 , 15:59   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #176

Ok so now that I better understand how adding reserve ammo to the M60 allows it to reload anytime, I need to find a way to block the reload until the bullets in the first clip reaches 1...I have an idea as how to using if (Clip ==1) and possibly blocking it during OnPlayerRunCmd...Some help with this would be great...lol i've been spending way too much time on this...

Last edited by MasterMind420; 04-11-2016 at 16:03.
MasterMind420 is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-14-2016 , 00:19   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #177

I'd like to present to you all...

I urge you all to download all three of these plugins, everything is working now.

VERSION 2.4 FEATURES
Added afk feature, now saves and loads equipment if you go afk.
Added reactivate feature, on map change you can freely switch items without having to pick anything up.
Added primary weapon workaround, all primary weapons now retain 1 bullet before the gun completely empties, so u can switch.
Added new thirdperson !eview auto feature, this command has been deactivated, when you switch to thirdpersonshoulder it will activate !eview.
Removed M60 code from the plugin, it's no longer necessary with Deathchaos's Prevent M60 Drop now working.

GUNCONTROL
Use GunControl from here it has been modified to work with Multiple Equipment.
Added a cvar for M60AmmoReserve into the config, no need to put it in server.cfg anymore.

PREVENT M60 DROP
Use Deathchaos's Prevent M60 Drop from here it has been modified to work with Multiple Equipment.

Please report any bugs you may experience and i'll fix them when I can. Enjoy!!!
Attached Files
File Type: smx l4d_multiple_equipment.smx (26.4 KB, 101 views)
File Type: sp Get Plugin or Get Source (l4d_multiple_equipment.sp - 236 views - 49.6 KB)
File Type: smx l4d2_prevent_m60_drop.smx (6.6 KB, 96 views)
File Type: sp Get Plugin or Get Source (l4d2_prevent_m60_drop.sp - 213 views - 5.1 KB)
File Type: smx l4d2_guncontrol.smx (12.8 KB, 95 views)
File Type: sp Get Plugin or Get Source (l4d2_guncontrol.sp - 225 views - 23.1 KB)

Last edited by MasterMind420; 04-14-2016 at 00:21.
MasterMind420 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 04-14-2016 , 01:35   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #178

Quote:
Originally Posted by MasterMind420 View Post
I'd like to present to you all...

I urge you all to download all three of these plugins, everything is working now.

VERSION 2.4 FEATURES
Added afk feature, now saves and loads equipment if you go afk.
Added reactivate feature, on map change you can freely switch items without having to pick anything up.
Added primary weapon workaround, all primary weapons now retain 1 bullet before the gun completely empties, so u can switch.
Added new thirdperson !eview auto feature, this command has been deactivated, when you switch to thirdpersonshoulder it will activate !eview.
Removed M60 code from the plugin, it's no longer necessary with Deathchaos's Prevent M60 Drop now working.

GUNCONTROL
Use GunControl from here it has been modified to work with Multiple Equipment.
Added a cvar for M60AmmoReserve into the config, no need to put it in server.cfg anymore.

PREVENT M60 DROP
Use Deathchaos's Prevent M60 Drop from here it has been modified to work with Multiple Equipment.

Please report any bugs you may experience and i'll fix them when I can. Enjoy!!!
So far, the bots with weird animation glitches are now gone. No bugs, no fixes needed. Good work!
cravenge is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-15-2016 , 03:11   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #179

I will be re-releasing version 2.4 sometime today, the afk save feature is now fixed, an oversight on my behalf. Also I have discovered that the plugin still doesn't activate on map change properly so I changed the way Multiple Equipment activates so it should fire every single time now, and seems to be corrected. I don't know if any new issues will arise because of this method but I will be thoroughly testing the plugin from now on before I release it...
MasterMind420 is offline
Sev
Veteran Member
Join Date: May 2010
Old 04-15-2016 , 21:48   Re: [L4D & L4D2] Multiple Equipments
Reply With Quote #180

The clipping still seems to be a problem, at least with the grenade launcher. Even if I switch to 3rd person, I'll have my grenade launcher in hand, plus my other weapon on my back PLUS the grenade launcher. Didn't check to see if a map change fixes it, but I still see the problem with the grenade launcher.
Sev is offline
Reply



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 11:00.


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