Raised This Month: $ Target: $400
 0% 

Need Some Help I Got A problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-11-2009 , 09:32   Need Some Help I Got A problem
Reply With Quote #1

I Made A plugin unlock_baseballbat for gunxpmod first time compiled i bought it model was baseball bat but when hit it zombie doesn't knock back when zombie hited me i get knock back help pls :/ Its For Zombie Swarm Humans Can Only use This Baseball bat can some Correct this ?

Code:

Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <gunxpmod>
#include <xs>

new PLUGIN_NAME[]     = "Unlock : BaseBall Bat"
new PLUGIN_AUTHOR[]     = "DoviuX"
new PLUGIN_VERSION[]     = "1.0"

new g_pCvarKnockBack

new const BAT_MDL[] =     "models/UmbrellaSwarm/v_BaseBallBat.mdl";

new damage_baseballbat
new g_maxplayers
new bool:g_BASEBALLBAT[33] 

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
    register_gxm_item("BaseBall Bat", "Big KnockBack", 80)

    g_pCvarKnockBack = register_cvar("baseball_knockback", "15")

    damage_baseballbat = register_cvar("gxm_damage_bat","2.0"); // damage multiplier
    register_event("CurWeapon",    "Event_CurWeaponbat", "be", "1=1")

    RegisterHam(Ham_TakeDamage, "player", "Player_TakeDamage", 1)
    RegisterHam(Ham_TakeDamage, "player", "Ham_Damagebat");

    g_maxplayers = get_maxplayers();
}
public plugin_precache()  
{
    engfunc(EngFunc_PrecacheModel, BAT_MDL);
}
public gxm_item_enabled(id) {
    g_BASEBALLBAT[id] = true
}
public client_connect(id) 
{
    g_BASEBALLBAT[id] = false
}
public Ham_DamageEL(id, inflictor, attacker, Float:damage, damagebits) 
{
    if ( !(1 <= attacker <= g_maxplayers) || !g_BASEBALLBAT[attacker])
            return HAM_IGNORED; 

    new weapon2 = get_user_weapon(attacker, _, _);
    if( weapon2 == CSW_KNIFE)
    {
        SetHamParamFloat(4, damage * get_pcvar_float(damage_baseballbat)); //Ellt damage
        return HAM_HANDLED;
    }
    return HAM_IGNORED;
}
public Event_CurWeaponbat(id) 
{
    if (!g_BASEBALLBAT[id])
    return PLUGIN_CONTINUE;

    new Gun = read_data(2) 
    
    if( Gun == CSW_KNIFE)
    {
        set_pev(id, pev_viewmodel2, BAT_MDL)
    }
    return PLUGIN_CONTINUE;
}
public Player_TakeDamage(id, idinflictor, idattacker, Float:flDamage, damagebits)
{
    if(    !idattacker
    ||    id == idattacker
    ||    idinflictor != idattacker//    )
    ||    get_user_weapon(idattacker) != g_BASEBALLBAT    )
    {
        return
    }

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

    pev(id, pev_origin, fDir)
    pev(idattacker, pev_origin, fOrigin)

    xs_vec_sub(fDir, fOrigin, fDir)
    xs_vec_normalize(fDir, fDir)

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

    pev(id, pev_velocity, fVelocity)
    xs_vec_mul_scalar(fDir, flDamage, fDir)
    xs_vec_add(fVelocity, fDir, fVelocity)
    set_pev(id, pev_velocity, fVelocity)
}

Last edited by DoviuX; 08-11-2009 at 09:36.
DoviuX is offline
Send a message via Skype™ to DoviuX
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-11-2009 , 11:07   Re: Need Some Help I Got A problem
Reply With Quote #2

Wait, how you can test something which don't compile ? The code above doesn't compile.

You have added it seems "get_user_weapon(idattacker) != g_BASEBALLBAT" , but it can't work. g_BASEBALLBAT is used to know if player holds a bat and not the weapon id.
__________________
Arkshine is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-11-2009 , 11:40   Re: Need Some Help I Got A problem
Reply With Quote #3

okey i made easier way but stil zombies dont get knock back :/

Code:

Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <gunxpmod>
#include <xs>

new PLUGIN_NAME[] 	= "Unlock : BaseBall Bat"
new PLUGIN_AUTHOR[] 	= "DoviuX"
new PLUGIN_VERSION[] 	= "1.0"


new const BAT_MDL[] = 	"models/UmbrellaSwarm/v_BaseBallBat.mdl";

new damage_baseballbat
new g_maxplayers
new bool:g_BASEBALLBAT[33] 

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
	register_gxm_item("BaseBall Bat", "Big KnockBack", 80)

	damage_baseballbat = register_cvar("gxm_damage_bat","2.0"); // damage multiplier
	register_event("CurWeapon",	"Event_CurWeaponbat", "be", "1=1")

	RegisterHam(Ham_TakeDamage, "player", "Ham_damagebat");

	g_maxplayers = get_maxplayers();
}
public plugin_precache()  
{
	engfunc(EngFunc_PrecacheModel, BAT_MDL);
}
public gxm_item_enabled(id) {
	g_BASEBALLBAT[id] = true
}
public client_connect(id) 
{
	g_BASEBALLBAT[id] = false
}
public Ham_Damagebat(id, inflictor, attacker, Float:Damage, damagebits) 
{
	if ( !(1 <= attacker <= g_maxplayers) || !g_BASEBALLBAT[attacker])
        	return HAM_IGNORED; 

	new weapon2 = get_user_weapon(attacker, _, _);
	if( weapon2 == CSW_KNIFE)
	{
		SetHamParamFloat(4, damage * get_pcvar_float(damage_baseballbat)); //bat kb
		return HAM_HANDLED;
	}
	return HAM_IGNORED;
}
public Event_CurWeaponbat(id) 
{
	if (!g_BASEBALLBAT[id])
	return PLUGIN_CONTINUE;

	new Gun = read_data(2) 
	
	if( Gun == CSW_KNIFE)
	{
		set_pev(id, pev_viewmodel2, BAT_MDL)
	}
	return PLUGIN_CONTINUE;
}
DoviuX is offline
Send a message via Skype™ to DoviuX
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-11-2009 , 11:57   Re: Need Some Help I Got A problem
Reply With Quote #4

There is no code knock back code in your last code.
__________________
Arkshine is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-11-2009 , 12:10   Re: Need Some Help I Got A problem
Reply With Quote #5

Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <gunxpmod>
#include <xs>

new PLUGIN_NAME[] 	= "Unlock : Baseball Bat"
new PLUGIN_AUTHOR[] 	= "DoviuX"
new PLUGIN_VERSION[] 	= "1.0"

new g_KnockBack
new g_baseballbat

new const BAT_MDL[] = 	"models/UmbrellaSwarm/v_BaseBallBat.mdl";

new bool:g_BASEBALLBAT[33] 

public plugin_init()
{
	register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
	register_gxm_item("BaseBall Bat", "Big KnockBack", 80)

    	g_KnockBack = register_cvar("gxm_bat_knockback", "100")
	register_event("CurWeapon",	"Event_CurWeaponbat", "be", "1=1")

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

}
public plugin_precache()  
{
	engfunc(EngFunc_PrecacheModel, BAT_MDL);
}
public gxm_item_enabled(id) {
	g_BASEBALLBAT[id] = true
}
public client_connect(id) 
{
	g_BASEBALLBAT[id] = false
}
public Event_CurWeaponbat(id) 
{
	if (!g_BASEBALLBAT[id])
	return PLUGIN_CONTINUE;

	new Gun = read_data(2) 
	
	if( Gun == CSW_KNIFE)
	{
		set_pev(id, pev_viewmodel2, BAT_MDL)
	}
	return PLUGIN_CONTINUE;
}
public Player_TakeDamage(id, inflictor, attacker, Float:flDamage, damagebits)
{
    if(    !attacker
    ||    id == attacker
    ||    inflictor != attacker//    )
    ||    get_user_weapon(attacker) != g_baseballbat    )
    {
        return
    }

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

    pev(id, pev_origin, fDir)
    pev(attacker, pev_origin, fOrigin)

    xs_vec_sub(fDir, fOrigin, fDir)
    xs_vec_normalize(fDir, fDir)

    flDamage *= get_pcvar_num(g_KnockBack)
    if( flDamage > 1500.0 )
        flDamage = 1500.0

    pev(id, pev_velocity, fVelocity)
    xs_vec_mul_scalar(fDir, flDamage, fDir)
    xs_vec_add(fVelocity, fDir, fVelocity)
    set_pev(id, pev_velocity, fVelocity)
}
?
DoviuX is offline
Send a message via Skype™ to DoviuX
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-11-2009 , 12:14   Re: Need Some Help I Got A problem
Reply With Quote #6

Stop to give random code, and give the ACTUAL and WORKING code you're using on your server which gives you the issue written on the first post.
__________________
Arkshine is offline
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 08-11-2009 , 12:37   Re: Need Some Help I Got A problem
Reply With Quote #7

I Use This :

Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <gunxpmod>
#include <xs>

new PLUGIN_NAME[]     = "Unlock : Baseball Bat"
new PLUGIN_AUTHOR[]     = "DoviuX"
new PLUGIN_VERSION[]     = "1.0"

new g_pCvarKnockBack
new g_baseballbat

new const BAT_MDL[] =     "models/UmbrellaSwarm/v_BaseBallBat.mdl";

new bool:g_BASEBALLBAT[33] 

public plugin_init()
{
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
    register_gxm_item("BaseBall Bat", "Big KnockBack", 80)

        g_pCvarKnockBack = register_cvar("amx_bat_knockback", "10")
    register_event("CurWeapon",    "Event_CurWeaponbat", "be", "1=1")

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

}
public plugin_precache()  
{
    engfunc(EngFunc_PrecacheModel, BAT_MDL);
}
public gxm_item_enabled(id) {
    g_BASEBALLBAT[id] = true
}
public client_connect(id) 
{
    g_BASEBALLBAT[id] = false
}
public Event_CurWeaponbat(id) 
{
    if (!g_BASEBALLBAT[id])
    return PLUGIN_CONTINUE;

    new Gun = read_data(2) 
    
    if( Gun == CSW_KNIFE)
    {
        set_pev(id, pev_viewmodel2, BAT_MDL)
    }
    return PLUGIN_CONTINUE;
}
public Player_TakeDamage(id, inflictor, attacker, Float:flDamage, damagebits)
{
    if(    !attacker
    ||    id == attacker
    ||    inflictor != attacker//    )
    ||    get_user_weapon(attacker) != CSW_KNIFE    )
    {
        return
    }

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

    pev(id, pev_origin, fDir)
    pev(idattacker, pev_origin, fOrigin)

    xs_vec_sub(fDir, fOrigin, fDir)
    xs_vec_normalize(fDir, fDir)

    flDamage *= get_pcvar_num(g_KnockBack)
    if( flDamage > 1500.0 )
        flDamage = 1500.0

    pev(id, pev_velocity, fVelocity)
    xs_vec_mul_scalar(fDir, flDamage, fDir)
    xs_vec_add(fVelocity, fDir, fVelocity)
    set_pev(id, pev_velocity, fVelocity)
}
But Zombie Swarm Zombies Gets The Model of baseball bat when they buy an ugrade. And Knock Back Doesn't work :/
DoviuX is offline
Send a message via Skype™ to DoviuX
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 18:28.


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