Raised This Month: $ Target: $400
 0% 

help me knockback


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
B7PK
Member
Join Date: Apr 2016
Location: palestine
Old 05-10-2016 , 17:19   help me knockback
Reply With Quote #1

hello guys.
i need make my knockback like knockback in this server 94.23.2.29:27015 or 74.201.57.112:27015 or 63.251.20.47:27015

my knockback (full code)

PHP Code:
/*================================================================================
    
    ----------------------
    -*- [ZP] Knockback -*-
    ----------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <xs>
#include <amx_settings_api>
#include <cs_ham_bots_api>
#include <zp50_class_zombie>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_ASSASSIN "zp50_class_assassin"
#include <zp50_class_assassin>

// Settings file
new const ZP_SETTINGS_FILE[] = "zombieplague.ini"

// Knockback Power values for weapons
// Note: negative values will disable knockback power for the weapon
new Float:kb_weapon_power[] = 
{
    -
1.0,    // ---
    
2.4,    // P228
    
-1.0,    // ---
    
6.5,    // SCOUT
    
-1.0,    // ---
    
8.0,    // XM1014
    
-1.0,    // ---
    
2.3,    // MAC10
    
5.0,    // AUG
    
-1.0,    // ---
    
2.4,    // ELITE
    
2.0,    // FIVESEVEN
    
2.4,    // UMP45
    
5.3,    // SG550
    
5.5,    // GALIL
    
5.5,    // FAMAS
    
2.2,    // USP
    
2.0,    // GLOCK18
    
10.0,    // AWP
    
2.5,    // MP5NAVY
    
5.2,    // M249
    
8.0,    // M3
    
5.0,    // M4A1
    
2.4,    // TMP
    
6.5,    // G3SG1
    
-1.0,    // ---
    
5.3,    // DEAGLE
    
5.0,    // SG552
    
6.0,    // AK47
    
-1.0,    // ---
    
2.0        // P90
}

// Weapon entity names (uppercase)
new const WEAPONENTNAMES_UP[][] = { """WEAPON_P228""""WEAPON_SCOUT""WEAPON_HEGRENADE""WEAPON_XM1014""WEAPON_C4""WEAPON_MAC10",
            
"WEAPON_AUG""WEAPON_SMOKEGRENADE""WEAPON_ELITE""WEAPON_FIVESEVEN""WEAPON_UMP45""WEAPON_SG550",
            
"WEAPON_GALIL""WEAPON_FAMAS""WEAPON_USP""WEAPON_GLOCK18""WEAPON_AWP""WEAPON_MP5NAVY""WEAPON_M249",
            
"WEAPON_M3""WEAPON_M4A1""WEAPON_TMP""WEAPON_G3SG1""WEAPON_FLASHBANG""WEAPON_DEAGLE""WEAPON_SG552",
            
"WEAPON_AK47""WEAPON_KNIFE""WEAPON_P90" }

new 
cvar_knockback_damagecvar_knockback_powercvar_knockback_obey_class
new cvar_knockback_zvelcvar_knockback_duckingcvar_knockback_distance
new cvar_knockback_nemesiscvar_knockback_assassin

public plugin_init()
{
    
register_plugin("[ZP] Knockback"ZP_VERSION_STRING"ZP Dev Team")
    
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack_Post"1)
    
RegisterHamBots(Ham_TraceAttack"fw_TraceAttack_Post"1)
    
    
cvar_knockback_damage register_cvar("zp_knockback_damage""1")
    
cvar_knockback_power register_cvar("zp_knockback_power""1")
    
cvar_knockback_obey_class register_cvar("zp_knockback_obey_class""1")
    
cvar_knockback_zvel register_cvar("zp_knockback_zvel""0")
    
cvar_knockback_ducking register_cvar("zp_knockback_ducking""0.25")
    
cvar_knockback_distance register_cvar("zp_knockback_distance""500")
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library))
        
cvar_knockback_nemesis register_cvar("zp_knockback_nemesis""0.25")

    
// Assassin Class loaded?
    
if (LibraryExists(LIBRARY_ASSASSINLibType_Library))
        
cvar_knockback_assassin register_cvar("zp_knockback_assassin""0.25")
}

public 
plugin_precache()
{
    new 
index
    
for (index 1index sizeof WEAPONENTNAMES_UPindex++)
    {
        if (
kb_weapon_power[index] == -1.0)
            continue;
        
        if (!
amx_load_setting_float(ZP_SETTINGS_FILE"Knockback Power for Weapons"WEAPONENTNAMES_UP[index][7], kb_weapon_power[index]))
            
amx_save_setting_float(ZP_SETTINGS_FILE"Knockback Power for Weapons"WEAPONENTNAMES_UP[index][7], kb_weapon_power[index])
    }
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}
public 
module_filter(const module[])
{
    if (
equal(moduleLIBRARY_NEMESIS) || equal(moduleLIBRARY_ASSASSIN))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}

// Ham Trace Attack Post Forward
public fw_TraceAttack_Post(victimattackerFloat:damageFloat:direction[3], tracehandledamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_alive(attacker))
        return;
    
    
// Victim isn't zombie or attacker isn't human
    
if (!zp_core_is_zombie(victim) || zp_core_is_zombie(attacker))
        return;
    
    
// Not bullet damage
    
if (!(damage_type DMG_BULLET))
        return;
    
    
// Knockback only if damage is done to victim
    
if (damage <= 0.0 || GetHamReturnStatus() == HAM_SUPERCEDE || get_tr2(tracehandleTR_pHit) != victim)
        return;
    
    
// Nemesis knockback disabled, nothing else to do here
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(victim) && get_pcvar_float(cvar_knockback_nemesis) == 0.0)
        return;

    
// Assassin knockback disabled, nothing else to do here
    
if (LibraryExists(LIBRARY_ASSASSINLibType_Library) && zp_class_assassin_get(victim) && get_pcvar_float(cvar_knockback_assassin) == 0.0)
        return;
    
    
// Get whether the victim is in a crouch state
    
new ducking pev(victimpev_flags) & (FL_DUCKING FL_ONGROUND) == (FL_DUCKING FL_ONGROUND)
    
    
// Zombie knockback when ducking disabled
    
if (ducking && get_pcvar_float(cvar_knockback_ducking) == 0.0)
        return;
    
    
// Get distance between players
    
static origin1[3], origin2[3]
    
get_user_origin(victimorigin1)
    
get_user_origin(attackerorigin2)
    
    
// Max distance exceeded
    
if (get_distance(origin1origin2) > get_pcvar_num(cvar_knockback_distance))
        return ;
    
    
// Get victim's velocity
    
static Float:velocity[3]
    
pev(victimpev_velocityvelocity)
    
    
// Use damage on knockback calculation
    
if (get_pcvar_num(cvar_knockback_damage))
        
xs_vec_mul_scalar(directiondamagedirection)
    
    
// Get attacker's weapon id
    
new attacker_weapon get_user_weapon(attacker)
    
    
// Use weapon power on knockback calculation
    
if (get_pcvar_num(cvar_knockback_power) && kb_weapon_power[attacker_weapon] > 0.0)
        
xs_vec_mul_scalar(directionkb_weapon_power[attacker_weapon], direction)
    
    
// Apply ducking knockback multiplier
    
if (ducking)
        
xs_vec_mul_scalar(directionget_pcvar_float(cvar_knockback_ducking), direction)
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(victim))
    {
        
// Apply nemesis knockback multiplier
        
xs_vec_mul_scalar(directionget_pcvar_float(cvar_knockback_nemesis), direction)
    }
    
// Assassin Class loaded?
    
else if (LibraryExists(LIBRARY_ASSASSINLibType_Library) && zp_class_assassin_get(victim))
    {
        
// Apply assassin knockback multiplier
        
xs_vec_mul_scalar(directionget_pcvar_float(cvar_knockback_assassin), direction)
    }
    else if (
get_pcvar_num(cvar_knockback_obey_class))
    {
        
// Apply zombie class knockback multiplier
        
xs_vec_mul_scalar(directionzp_class_zombie_get_kb(zp_class_zombie_get_current(victim)), direction)
    }
    
    
// Add up the new vector
    
xs_vec_add(velocitydirectiondirection)
    
    
// Should knockback also affect vertical velocity?
    
if (!get_pcvar_num(cvar_knockback_zvel))
        
direction[2] = velocity[2]
    
    
// Set the knockback'd victim's velocity
    
set_pev(victimpev_velocitydirection)

please help
__________________
B7PK is offline
abood alnjjar
Member
Join Date: Oct 2015
Location: palestine
Old 05-11-2016 , 01:07   Re: help me knockback
Reply With Quote #2

Try..

cvar_knockback_damage = register_cvar("zp_knockback_damage", "1")
cvar_knockback_power = register_cvar("zp_knockback_power", "1")
cvar_knockback_obey_class = register_cvar("zp_knockback_obey_class", "1")
cvar_knockback_zvel = register_cvar("zp_knockback_zvel", "0")
cvar_knockback_ducking = register_cvar("zp_knockback_ducking", "0.25")
cvar_knockback_distance = register_cvar("zp_knockback_distance", "400")
__________________
abood alnjjar is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-11-2016 , 09:18   Re: help me knockback
Reply With Quote #3

Quote:
Originally Posted by abood alnjjar View Post
Try..

cvar_knockback_damage = register_cvar("zp_knockback_damage", "1")
cvar_knockback_power = register_cvar("zp_knockback_power", "1")
cvar_knockback_obey_class = register_cvar("zp_knockback_obey_class", "1")
cvar_knockback_zvel = register_cvar("zp_knockback_zvel", "0")
cvar_knockback_ducking = register_cvar("zp_knockback_ducking", "0.25")
cvar_knockback_distance = register_cvar("zp_knockback_distance", "400")
Have you heard about amxx.cfg file?
No need to register cvars with custom values because they can be set in amxx.cfg
siriusmd99 is offline
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 18:33.


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