AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Knife Range (https://forums.alliedmods.net/showthread.php?t=325673)

AnimalMonster 07-02-2020 04:50

Knife Range
 
Hey everyone,
I tried researching for a plugin that should help me make attack range at knifes but all i found was a plugin Knife API but i want to extract a code and bcs there's too much code there i can't figure out what should i extract. If anyone has a code for that i am glad to know it :).

Napoleon_be 07-02-2020 11:40

Re: Knife Range
 
https://forums.alliedmods.net/showthread.php?p=825597

AnimalMonster 07-02-2020 13:14

Re: Knife Range
 
Quote:

Originally Posted by Napoleon_be (Post 2708266)

Nope , that s not what i mean, this code from hsk should help me:D
PHP Code:

#include <amxmodx>
#include <xs>
#include <fakemeta>

#define PLUGIN_NAME     "[Cs] Knife attack distance"
#define PLUGIN_VERSION    "1.0"
#define PLUGIN_AUTHOR    "HsK"

new g_knatt[33];

// Cvars
new cvar_knattdis_scvar_knattdis_b;

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEPLUGIN_VERSIONPLUGIN_AUTHOR);

    
cvar_knattdis_s register_cvar("amx_knattdis_s""-500");    // »´¤M¶ZÂ÷ (0=¤ŁĹÜ , Ąi§ď¤ń´¶łq CS ¤p¤M§óµuŞş¶ZÂ÷, -xĄiĄ´«á¤č)
    
cvar_knattdis_b register_cvar("amx_knattdis_b""500");    // *«¤M¶ZÂ÷ (0=¤ŁĹÜ , Ąi§ď¤ń´¶łq CS ¤p¤M§óµuŞş¶ZÂ÷, -xĄiĄ´«á¤č)

    
register_forward(FM_TraceLine"fw_TraceLine");
    
register_forward(FM_TraceHull"fw_TraceHull");
}

public 
fw_TraceLine(Float:vecStart[3], Float:vecEnd[3], conditionsidptr)
{
    if (!
is_user_alive(id)) return FMRES_IGNORED;

    static 
Float:flFractionwead_id;
    
wead_id get_user_weapon(id);

    if (
wead_id != CSW_KNIFE) return FMRES_IGNORED;

    static 
Float:vecAngles[3], Float:vecForward[3], attack_modFloat:Distance;
    
pev(idpev_v_anglevecAngles);
    
engfunc(EngFunc_MakeVectorsvecAngles);

    
global_get(glb_v_forwardvecForward);

    
attack_mod floatround((vecStart[0]-vecEnd[0])/vecForward[0]);

    if (
attack_mod == -48Distance get_pcvar_float(cvar_knattdis_s);
    else if (
attack_mod == -32Distance get_pcvar_float(cvar_knattdis_b);
    else
    {
        
g_knatt[id] = 0;
        return 
FMRES_IGNORED;
    }

    if (
Distance == 0) return FMRES_IGNORED;

    if ((
attack_mod == -48 && Distance 48.0) || (attack_mod == -32 && Distance 32.0))
        
g_knatt[id] = 2;
    else 
g_knatt[id] = 1;

    
get_tr2(ptrTR_flFractionflFraction);

    if ((
g_knatt[id] == && flFraction >= 1.0) || g_knatt[id] == 2)
    {
        
xs_vec_mul_scalar(vecForwardDistancevecForward);
        
xs_vec_add(vecStartvecForwardvecEnd);

        
engfunc(EngFunc_TraceLinevecStartvecEndconditionsidptr);
        return 
FMRES_SUPERCEDE;
    }
    else 
g_knatt[id] = 0;

    return 
FMRES_SUPERCEDE;
}

public 
fw_TraceHull(Float:vecStart[3], Float:vecEnd[3], conditionshullidptr)
{
    if (!
is_user_alive(id)) return FMRES_IGNORED;

    if (
g_knatt[id])
    {
        if (
g_knatt[id] == 1) return FMRES_IGNORED;
        else return 
FMRES_SUPERCEDE;
    }

    return 
FMRES_IGNORED;




All times are GMT -4. The time now is 10:59.

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