Raised This Month: $ Target: $400
 0% 

Creating knockback.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-25-2009 , 10:13   Re: Creating knocback.
Reply With Quote #1

Try this :

PHP Code:
/*    Copyright © 2009, ConnorMcLeod

    Knife KnockBack is free software;
    you can redistribute it and/or modify it under the terms of the
    GNU General Public License as published by the Free Software Foundation.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Knife KnockBack; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>

#define PLUGIN "Knife KnockBack"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

new g_pCvarKnockBack

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
g_pCvarKnockBack register_cvar("amx_knife_knockback""10")

    
RegisterHam(Ham_TakeDamage"player""Player_TakeDamage"1)
}

public 
Player_TakeDamage(ididinflictoridattackerFloat:flDamagedamagebits)
{
    if(    !
idattacker
    
||    id == idattacker
    
||    idinflictor != idattacker//    )
    
||    get_user_weapon(idattacker) != CSW_KNIFE    )
    {
        return
    }

    new 
Float:fDir[3], Float:fOrigin[3], Float:fVelocity[3]

    
pev(idpev_originfDir)
    
pev(idattackerpev_originfOrigin)

    
xs_vec_sub(fDirfOriginfDir)
    
xs_vec_normalize(fDirfDir)

    
flDamage *= get_pcvar_num(g_pCvarKnockBack)
    if( 
flDamage 1500.0 )
        
flDamage 1500.0

    pev
(idpev_velocityfVelocity)
    
xs_vec_mul_scalar(fDirflDamagefDir)
    
xs_vec_add(fVelocityfDirfVelocity)
    
set_pev(idpev_velocityfVelocity)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 01:38.


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