Raised This Month: $ Target: $400
 0% 

Unlock_knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
emperial159
Member
Join Date: Feb 2011
Old 06-08-2011 , 11:46   Unlock_knife
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <engine>
#include <gunxpmod>
#include <hamsandwich>
#include <fakemeta>
 
#define PLUGIN  "Knife Knockback"
#define VERSION "1.0"
#define AUTHOR  "xbatista"
 
#define IsPlayer(%1)  ( 1 <= %1 <= g_maxplayers )
 
new cvar_knock
 
new const KNIFE_MDL[] = "models/gunxpmod/v_baseballbat.mdl";   
 
new 
g_maxplayers
new damage_knife
new bool:g_KNIFE[33]
public 
plugin_init()
{
    
register_plugin(PLUGIN VERSION AUTHOR);
    
register_cvar("unlock_knife"VERSIONFCVAR_SERVER)
    
RegisterHam(Ham_TakeDamage"player""Ham_DamageKNIFE")
 
    
register_event("CurWeapon""Event_CurWeaponKNIFE""be""1=1")
    
register_event("Damage" "event_Damage" "b" "2>0");
 
    
register_gxm_item("Basball bat""Knife knockback, Power"65)
 
    
damage_knife register_cvar("gxm_damage_knife","0.5"); // damage multiplier
 
    
cvar_knock     register_cvar("zp_knife_power" "9");
    
g_maxplayers get_maxplayers();
}
public 
gxm_item_enabled(id) {
    
g_KNIFE[id] = true
}
public 
client_connect(id)
{
    
g_KNIFE[id] = false
}
public 
Event_CurWeaponKNIFE(id)
{
    if (!
g_KNIFE[id])
        return 
PLUGIN_CONTINUE;
 
    new 
Gun read_data(2)
   
    if( 
Gun == CSW_KNIFE && get_user_team(id) == 2)
    {
        
set_pev(idpev_viewmodel2KNIFE_MDL)
    }
    return 
PLUGIN_CONTINUE;
}
public 
event_Damage(id)
{
    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 (!
g_KNIFE[attacker])
        return 
PLUGIN_CONTINUE;
 
    if(
weapon == CSW_KNIFE && get_user_team(attacker) == 2)
    {
        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;
}
public 
Ham_DamageKNIFE(idinflictorattackerFloat:damagedamagebits)
{
    if ( !(
<= attacker <= g_maxplayers) || !g_KNIFE[attacker])
            return 
HAM_IGNORED;
 
    new 
weaponx get_user_weapon(attacker__);
    if( 
weaponx == CSW_KNIFE && get_user_team(attacker) == 2)
    {
        
SetHamParamFloat(4damage get_pcvar_float(damage_knife)); //Knife damage
        
return HAM_HANDLED;
    }
    return 
HAM_IGNORED;
}
// Stock by the one and only, Chronic :P
stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!
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_knock) * 3000) ) / get_entity_distance(victim attacker);
    
velocity[1] = ( origin2[1] * (get_pcvar_float(cvar_knock) * 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;
}
public 
plugin_precache()
{
    
engfunc(EngFunc_PrecacheModelKNIFE_MDL);

It's a bug when someone buyed a knife and he drop the he and he quickly has changed the knife and dmg are 5k... But when you changed a gun the dmg are 458... Help me
emperial159 is offline
Old 06-09-2011, 00:18
emperial159
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
Old 06-09-2011, 02:35
emperial159
This message has been deleted by emperial159.
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:52.


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