AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Super KnockBack (https://forums.alliedmods.net/showthread.php?t=231475)

Moshe123 12-15-2013 00:16

Super KnockBack
 
hello all,

i need code for super knock back if i shooting player with dgl he got super knock back like fly back

sorry for my bad english.

ANTICHRISTUS 12-15-2013 16:34

Re: Super KnockBack
 
really hard, wait.. the keyword is knockback.. so if I only search it in titles, I will not find the correct plugin.. Pump Knockback (v3x & Chronic)

it's not hard to change the weapon, just search this line in the .sma
PHP Code:

if(weapon == CSW_M3

and change it to the one you want to use.

Don_Collione 12-15-2013 22:11

Re: Super KnockBack
 
Quote:

Originally Posted by ANTICHRISTUS (Post 2072466)
really hard, wait.. the keyword is knockback.. so if I only search it in titles, I will not find the correct plugin.. Pump Knockback (v3x & Chronic)

it's not hard to change the weapon, just search this line in the .sma
PHP Code:

if(weapon == CSW_M3

and change it to the one you want to use.

Exactly. Good idie. One problem. He want fly knokback, when he attacked the enemies. Need more force power.

PHP Code:

#include <amxmodx>
#include <engine>

#define PLUGIN    "Pump Knockback (when shot by one)"
#define VERSION    "1.0"
#define AUTHOR    "v3x & Chronic"

new cvar_pump_active cvar_pump_force;

public 
plugin_init()
{
    
register_plugin(PLUGIN VERSION AUTHOR);

    
register_event("Damage" "event_Damage" "b" "2>0");

    
cvar_pump_active   register_cvar("pump_knockback" "1"); // turn on/off
    
cvar_pump_force       register_cvar("pump_force"     "20"); // knockback power
}

public 
event_Damage(id)
{
    if(!
get_pcvar_num(cvar_pump_active))
        return 
PLUGIN_CONTINUE;

    if(!
is_user_alive(id))
        return 
PLUGIN_CONTINUE;

    new 
weapon attacker get_user_attacker(id weapon);

    if(!
is_user_alive(attacker))
        return 
PLUGIN_CONTINUE;

    if(
weapon == CSW_DEAGLE// selected weapon
    
{
        new 
Float:vec[3];
        new 
Float:oldvelo[3];
        
get_user_velocity(idoldvelo);
        
create_velocity_vector(id attacker vec);
        
vec[0] += oldvelo[0];
        
vec[1] += oldvelo[1];
        
set_user_velocity(id vec);
    }

    return 
PLUGIN_CONTINUE;
}

// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!
is_user_alive(victim) || !is_user_alive(attacker))
        return 
0;

    new 
Float:vicorigin[3];
    new 
Float:attorigin[3];
    
entity_get_vector(victim   EV_VEC_origin vicorigin);
    
entity_get_vector(attacker EV_VEC_origin attorigin);

    new 
Float:origin2[3]
    
origin2[0] = vicorigin[0] - attorigin[0];
    
origin2[1] = vicorigin[1] - attorigin[1];

    new 
Float:largestnum 0.0;

    if(
floatabs(origin2[0])>largestnumlargestnum floatabs(origin2[0]);
    if(
floatabs(origin2[1])>largestnumlargestnum floatabs(origin2[1]);

    
origin2[0] /= largestnum;
    
origin2[1] /= largestnum;

    
velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_pump_force) * 3000) ) / get_entity_distance(victim attacker);
    
velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_pump_force) * 3000) ) / get_entity_distance(victim attacker);
    if(
velocity[0] <= 20.0 || velocity[1] <= 20.0)
        
velocity[2] = random_float(200.0 275.0);

    return 
1;



Moshe123 12-18-2013 08:22

Re: Super KnockBack
 
Quote:

Originally Posted by ANTICHRISTUS (Post 2072466)
really hard, wait.. the keyword is knockback.. so if I only search it in titles, I will not find the correct plugin.. Pump Knockback (v3x & Chronic)

it's not hard to change the weapon, just search this line in the .sma
PHP Code:

if(weapon == CSW_M3

and change it to the one you want to use.

i tried this but that not work on deagle

Quote:

Originally Posted by Don_Collione (Post 2072542)
Exactly. Good idie. One problem. He want fly knokback, when he attacked the enemies. Need more force power.

PHP Code:

#include <amxmodx>
#include <engine>

#define PLUGIN    "Pump Knockback (when shot by one)"
#define VERSION    "1.0"
#define AUTHOR    "v3x & Chronic"

new cvar_pump_active cvar_pump_force;

public 
plugin_init()
{
    
register_plugin(PLUGIN VERSION AUTHOR);

    
register_event("Damage" "event_Damage" "b" "2>0");

    
cvar_pump_active   register_cvar("pump_knockback" "1"); // turn on/off
    
cvar_pump_force       register_cvar("pump_force"     "20"); // knockback power
}

public 
event_Damage(id)
{
    if(!
get_pcvar_num(cvar_pump_active))
        return 
PLUGIN_CONTINUE;

    if(!
is_user_alive(id))
        return 
PLUGIN_CONTINUE;

    new 
weapon attacker get_user_attacker(id weapon);

    if(!
is_user_alive(attacker))
        return 
PLUGIN_CONTINUE;

    if(
weapon == CSW_DEAGLE// selected weapon
    
{
        new 
Float:vec[3];
        new 
Float:oldvelo[3];
        
get_user_velocity(idoldvelo);
        
create_velocity_vector(id attacker vec);
        
vec[0] += oldvelo[0];
        
vec[1] += oldvelo[1];
        
set_user_velocity(id vec);
    }

    return 
PLUGIN_CONTINUE;
}

// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!
is_user_alive(victim) || !is_user_alive(attacker))
        return 
0;

    new 
Float:vicorigin[3];
    new 
Float:attorigin[3];
    
entity_get_vector(victim   EV_VEC_origin vicorigin);
    
entity_get_vector(attacker EV_VEC_origin attorigin);

    new 
Float:origin2[3]
    
origin2[0] = vicorigin[0] - attorigin[0];
    
origin2[1] = vicorigin[1] - attorigin[1];

    new 
Float:largestnum 0.0;

    if(
floatabs(origin2[0])>largestnumlargestnum floatabs(origin2[0]);
    if(
floatabs(origin2[1])>largestnumlargestnum floatabs(origin2[1]);

    
origin2[0] /= largestnum;
    
origin2[1] /= largestnum;

    
velocity[0] = ( origin2[0] * (get_pcvar_float(cvar_pump_force) * 3000) ) / get_entity_distance(victim attacker);
    
velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_pump_force) * 3000) ) / get_entity_distance(victim attacker);
    if(
velocity[0] <= 20.0 || velocity[1] <= 20.0)
        
velocity[2] = random_float(200.0 275.0);

    return 
1;



ty i checked that that fly back? the player move far away?

ANTICHRISTUS 12-18-2013 13:01

Re: Super KnockBack
 
Quote:

Originally Posted by Moshe123 (Post 2073468)
i tried this but that not work on deagle

by changing if(weapon == CSW_M3) :arrow: if(weapon == CSW_DEAGLE) :?:
already tested it with the knife and works wonderfully, but long time ago (before new updates).


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

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