AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need Some Help I Got A problem (https://forums.alliedmods.net/showthread.php?t=99987)

DoviuX 08-11-2009 09:32

Need Some Help I Got A problem
 
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)
}


Arkshine 08-11-2009 11:07

Re: Need Some Help I Got A problem
 
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.

DoviuX 08-11-2009 11:40

Re: Need Some Help I Got A problem
 
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;
}


Arkshine 08-11-2009 11:57

Re: Need Some Help I Got A problem
 
There is no code knock back code in your last code.

DoviuX 08-11-2009 12:10

Re: Need Some Help I Got A problem
 
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)
}

?

Arkshine 08-11-2009 12:14

Re: Need Some Help I Got A problem
 
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.

DoviuX 08-11-2009 12:37

Re: Need Some Help I Got A problem
 
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 :/


All times are GMT -4. The time now is 18:28.

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