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

Pop grenade


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-10-2017 , 22:00   Pop grenade
Reply With Quote #1

Is possible make a plugin that allow players to use pop grenade like in CSGO?
If someone don't know whats this, i'll explain:

When someone use the left mouse for throw a grenade, it will fall far away.
When someone use the right mouse for throw a grenade, it will fall close to you.
When someone use both click for throw a grenade,it will fall a little further than the right button.

I just want to know how set the animation for throw the grenade.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

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

Last edited by EFFx; 01-11-2017 at 00:17.
EFFx is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-10-2017 , 22:45   Re: Pop grenade
Reply With Quote #2

Information update:

Thats what I have on this moment:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <engine>

#define PLUGIN    "Nade Velocity"
#define VERSION    "1.0"
#define AUTHOR    "hlstriker"

new const Grenades[] =
{
    
"models/w_hegrenade.mdl",
    
"models/w_flashbang.mdl",
    
"models/w_smokegrenade.mdl"
}

enum ClickTypes
{
    
Left,
    
Right,
    
Both
}

new 
ClickTypes:UserClickTypes[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_SetModel"fwd_SetModel")
}

public 
client_PreThink(id)
{
    new 
Button get_user_button(id)
    
    if(
Button IN_ATTACK)
    {
        
UserClickTypes[id] = Left
    
}
    else if(
Button IN_ATTACK2)
    {
        
UserClickTypes[id] = Right
    
}
    else if((
Button IN_ATTACK) && (Button IN_ATTACK2))
    {
        
UserClickTypes[id] = Both
    
}
}

public 
fwd_SetModel(iEnt, const szModel[])
{
    new 
bool:isGrenade
    
    
for(new i;sizeof Grenades;i++)
    {
        if(
equal(szModelGrenades[i]))
        {
            
isGrenade true
        
}
    }
    if(
isGrenade)
    {
        new 
id pev(iEnt,pev_owner)
        
        static 
Float:flVelocity[3], Float:flGravity[3]
        
        
pev(iEntpev_velocityflVelocity)
        
pev(iEntpev_gravityflGravity)
            
        switch(
UserClickTypes[id])
        {
            case 
Left:
            {
                
flVelocity[0] *= 1.0
                flVelocity
[1] *= 1.0
                flVelocity
[2] *= 1.0
                
                flGravity
[0] *= 1.0
                flGravity
[1] *= 1.0
                flGravity
[2] *= 1.0
            
}
            case 
Right:
            {
                
flVelocity[0] *= 0.5
                flVelocity
[1] *= 0.5
                flVelocity
[2] *= 0.5
                
                flGravity
[0] *= 1.5
                flGravity
[1] *= 1.5
                flGravity
[2] *= 1.5
            
}
            case 
Both:
            {
                
flVelocity[0] *= 0.7
                flVelocity
[1] *= 0.7
                flVelocity
[2] *= 0.7
                
                flGravity
[0] *= 1.5
                flGravity
[1] *= 1.5
                flGravity
[2] *= 1.5
            
}
        }
        
set_pev(iEntpev_velocityflVelocity)
        
set_pev(iEntpev_gravityflGravity)
    }

The format at setModel is working, I need just know how can I set the animation when the player is pressing the right button, and makes the grenade throw.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

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

Last edited by EFFx; 01-10-2017 at 23:14.
EFFx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-11-2017 , 10:03   Re: Pop grenade
Reply With Quote #3

Don't use PreThink for detecting a button.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <csx>
#include <fakemeta>
#include <xs>

enum
{
    
regular,
    
slower,
    
medium
}

const 
m_pPlayer  41
const XoCGrenade 4

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

new const 
Float:VelocityMultiplier[] =
{
    
1.0,
    
0.5,
    
0.7
}

new 
HandleThrowType[33]

public 
plugin_init()
{
    for(new 
isizeof GrenadeClassNamesi++)
    {
        
RegisterHam(Ham_Weapon_SecondaryAttackGrenadeClassNames[i], "CBasePlayerWpn_SecondaryAttack"false)
    }
}

public 
CBasePlayerWpn_SecondaryAttack(const grenadeEntity)
{
    if(
pev_valid(grenadeEntity))
    {
        new 
id get_pdata_cbase(grenadeEntitym_pPlayerXoCGrenade)
        new 
buttons pev(idpev_button)
        
        if(
buttons IN_ATTACK)
        {
            
HandleThrowType[id] = medium
        
}
        else 
        {
            
HandleThrowType[id] = slower
        
}
        
        
ExecuteHamB(Ham_Weapon_PrimaryAttackgrenadeEntity)
    }
}

public 
grenade_throw(idgrenadeEntitygrenadeWeaponIndex
{
    if(
pev_valid(grenadeEntity))
    {
        new 
Float:grenadeVelocity[3]
        
pev(grenadeEntitypev_velocitygrenadeVelocity)
        
        new 
Float:multiplier VelocityMultiplier[HandleThrowType[id]]
        
xs_vec_mul_scalar(grenadeVelocitymultipliergrenadeVelocity)
        
set_pev(grenadeEntitypev_velocitygrenadeVelocity)
    
        
HandleThrowType[id] = regular
    
}

__________________
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-11-2017 , 12:24   Re: Pop grenade
Reply With Quote #4

Thank you. Its working perfect.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx 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 03:07.


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