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

Pop Grenade


Post New Thread Reply   
 
Thread Tools Display Modes
Lyklor
Junior Member
Join Date: Apr 2013
Location: Belgium
Old 05-26-2018 , 01:37   Re: Pop Grenade
Reply With Quote #11

Ty, but players can throw grenades at freezetime. How to fix it?

Last edited by Lyklor; 05-26-2018 at 01:38.
Lyklor is offline
wilianmaique
BANNED
Join Date: Nov 2016
Old 05-26-2018 , 18:37   Re: Pop Grenade
Reply With Quote #12

NICE

Last edited by wilianmaique; 06-09-2019 at 12:40.
wilianmaique is offline
Send a message via Skype™ to wilianmaique
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-27-2018 , 05:25   Re: Pop Grenade
Reply With Quote #13

"removed unnecesary variables" a.k.a introduced magic numbers which is bad practice and killed readability.
__________________
HamletEagle is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-14-2018 , 06:11   Re: Pop Grenade
Reply With Quote #14

For approval:
What is the reason to use CurWeapon here? If you are trying to reset the throw type, then hook ItemDeploy on grenade and do HandleThrowType[id] = normal. Remeber to use m_pPlayer to retrieve "id" from the grenade.
__________________

Last edited by HamletEagle; 08-14-2018 at 06:12.
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 08-14-2018 , 07:54   Re: Pop Grenade
Reply With Quote #15

Changes done.

Quote:
Originally Posted by Lyklor View Post
Ty, but players can throw grenades at freezetime. How to fix it?
Fixed.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Siska1
Senior Member
Join Date: Feb 2020
Location: BedRock
Old 03-08-2023 , 10:34   Re: Pop Grenade
Reply With Quote #16

This plugin works perfectly, but it doesn't work together with molotov. For Russians, the plugin works with molotov, but there are bugs. Can you do something about it?

The problem here is that when I press the right button, it remembers it and then I can't throw the grenade normally. I go to throw it, but I take out another weapon and then I take out the grenade again, but the right button is memorized.

Code:
#include <amxmodx>
#include <hamsandwich>
#include <reapi>

// Порядковый номер анимации броска
#define ANIM_NUM 		2

enum { 
	normal, 
	slower, 
	medium 
};

new const g_GrenadeClassNames[][] = { 
	"weapon_flashbang", 
	"weapon_hegrenade", 
	"weapon_smokegrenade" 
};

new const Float:g_VelocityMultiplier[] = { 
	1.0, 
	0.5, 
	0.75 
};

new g_HandleThrowType[MAX_CLIENTS + 1];
new Float:g_flLastAttack[MAX_CLIENTS + 1];

public plugin_init() {
	register_plugin("[ReAPI] Pop Grenades", "2.3", "EFFx & HamletEagle & Minni Mouse");

	for(new i; i < sizeof(g_GrenadeClassNames); i++) {
		RegisterHam(Ham_Weapon_SecondaryAttack, g_GrenadeClassNames[i], "Weapon_SecAttack_Pre", .Post = false);
	}

	RegisterHookChain(RG_CBasePlayer_ThrowGrenade, "Player_ThrowGrenade_Pre", .post = false);
}

public Weapon_SecAttack_Pre(pWeapon) {
	if(get_member_game(m_bFreezePeriod)) {
		return HAM_IGNORED;
	}

	if(is_nullent(pWeapon)) {
		return HAM_IGNORED;
	}

	static pPlayer, Float:flCurTime;
	pPlayer = get_member(pWeapon, m_pPlayer);
	flCurTime = get_gametime();

	if(g_flLastAttack[pPlayer] > flCurTime) {
		return HAM_IGNORED;
	}
		
	g_HandleThrowType[pPlayer] = (get_entvar(pPlayer, var_button) & IN_ATTACK) ? medium : slower;
		
	ExecuteHamB(Ham_Weapon_PrimaryAttack, pWeapon);

	g_flLastAttack[pPlayer] = flCurTime + 1.5;

	return HAM_IGNORED;
}

public Player_ThrowGrenade_Pre(pPlayer, grenade, Float:vecSrc[3], Float:vecThrow[3], Float:time, usEvent) {
	if(is_nullent(grenade)) {
		return HC_CONTINUE;
	}

	new Float:flMultiplier = g_VelocityMultiplier[g_HandleThrowType[pPlayer]];

	vecThrow[0] *= flMultiplier;
	vecThrow[1] *= flMultiplier;
	vecThrow[2] *= flMultiplier;

	set_entvar(grenade, var_velocity, vecThrow);

	if(g_HandleThrowType[pPlayer] == slower) {
		rg_send_grenade_anim(pPlayer, ANIM_NUM);
	}

	g_HandleThrowType[pPlayer] = normal;

	return HC_CONTINUE;
}

stock rg_send_grenade_anim(const pPlayer, const iAnimation) {
	set_entvar(pPlayer, var_weaponanim, iAnimation);

	message_begin(MSG_ONE, SVC_WEAPONANIM, .player = pPlayer);
	write_byte(iAnimation);
	write_byte(0);
	message_end();
}
__________________
Siska1 is offline
Send a message via Skype™ to Siska1
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 03-09-2023 , 01:14   Re: Pop Grenade
Reply With Quote #17

In the default plugin it already does that, the ReAPI guy forgot to add it.

PHP Code:
    for(new isizeof(g_GrenadeClassNames); i++) {
        
RegisterHam(Ham_Item_Deployg_GrenadeClassNames[i], "CBasePlayerWpn_Deploy"false)
        
RegisterHam(Ham_Weapon_SecondaryAttackg_GrenadeClassNames[i], "Weapon_SecAttack_Pre", .Post false);
    } 
PHP Code:
public CBasePlayerWpn_Deploy(pWeapon)
{
    
g_HandleThrowType[get_member(pWeaponm_pPlayer)] = normal

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 03-09-2023 at 01:18.
EFFx is offline
Siska1
Senior Member
Join Date: Feb 2020
Location: BedRock
Old 03-13-2023 , 22:57   Re: Pop Grenade
Reply With Quote #18

Magnificent, thank you very much...
__________________
Siska1 is offline
Send a message via Skype™ to Siska1
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 20:00.


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