AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Pop Grenade (https://forums.alliedmods.net/showthread.php?t=292795)

EFFx 01-14-2017 14:15

Pop Grenade
 
1 Attachment(s)
POP GRENADE



First release: 01/14/2017
Last update: 08/14/2018


- Description
This plugin allow you use Pop grenades like CSGO.
If you don't know whats Pop grenades, i'll explain:

When you click with your left mouse (+ATTACK), your grenade will be throwed with your normal distance.
When you click with your right mouse (+ATTACK2), your grenade will be throwed more slower, closer to you.
When you click with both mouses, your grenade will be throwed with medium distance.

- Change Log
Spoiler


- Credits
° HamletEagle - For the code.

Napoleon_be 01-16-2017 10:57

Re: Pop Grenade
 
So hamleteagle made this?

EFFx 01-16-2017 13:48

Re: Pop Grenade
 
Yea.

WhiteFang1319 11-03-2017 07:50

Re: Pop Grenade
 
Hey. I used this plugin and noticed a bug. When I hold right click and I don't want to use the slow throw so I switch out to another weapon ( like knife with the button q ) and then I use left click the nade is thrown slowly than normal. Can you edit it so that when it's switched to another weapon the player's holding ( left/right/both) is reset?

EFFx 11-03-2017 11:49

Re: Pop Grenade
 
Ty for notice, it's fixed.

thEsp 11-03-2017 14:23

Reply
 
Good Plugin keep working..

WhiteFang1319 11-04-2017 02:52

Re: Pop Grenade
 
Quote:

Originally Posted by EFFx (Post 2558298)
Ty for notice, it's fixed.

Thank you. It works properly now :D

suhdude 11-14-2017 23:20

Re: Pop Grenade
 
This is so great! Thanks.

suhdude 11-17-2017 21:09

Re: Pop Grenade
 
Noticed a bug, from out of nowhere any nade I throw just gets stuck in the air in front of me.

EFFx 11-18-2017 10:45

Re: Pop Grenade
 
Not sure what you're talkin' about. I don't get this bug, may be another one conflicting. Did u get log message?

Lyklor 05-26-2018 01:37

Re: Pop Grenade
 
Ty, but players can throw grenades at freezetime. How to fix it?

wilianmaique 05-26-2018 18:37

Re: Pop Grenade
 
NICE

HamletEagle 05-27-2018 05:25

Re: Pop Grenade
 
"removed unnecesary variables" a.k.a introduced magic numbers which is bad practice and killed readability.

HamletEagle 08-14-2018 06:11

Re: Pop Grenade
 
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.

EFFx 08-14-2018 07:54

Re: Pop Grenade
 
Changes done.

Quote:

Originally Posted by Lyklor (Post 2593899)
Ty, but players can throw grenades at freezetime. How to fix it?

Fixed.

Siska1 03-08-2023 10:34

Re: Pop Grenade
 
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();
}


EFFx 03-09-2023 01:14

Re: Pop Grenade
 
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



Siska1 03-13-2023 22:57

Re: Pop Grenade
 
Magnificent, thank you very much...


All times are GMT -4. The time now is 02:02.

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