Raised This Month: $ Target: $400
 0% 

Angle Cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sn3amtz
Senior Member
Join Date: Jan 2015
Location: France
Old 01-31-2016 , 23:02   Angle Cvar
Reply With Quote #1

Hello guys... How can make a cver for angles

I tried
new BACKSTAB_ANGLE;
BACKSTAB_ANGLE = register_cvar("backstab_angle","93.0");


Code:
#define BACKSTAB_ANGLE 93.0

static Float:fMinAngle, Float:fMaxAngle;
fMinAngle = fViewAngles[1] - BACKSTAB_ANGLE;
fMaxAngle = fViewAngles[1] + BACKSTAB_ANGLE;

Last edited by Sn3amtz; 01-31-2016 at 23:07.
Sn3amtz is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-31-2016 , 23:05   Re: Angle Cvar
Reply With Quote #2

The same way that you make any other cvar and then use get_pcvar_float() to get the floating-point value from the cvar and assign that to the variable that you want. If you want to use BACKSTAB_ANGLE, you'll need change that to a variable first.

Code:
new Float:fMyAngle
// ... 
pCvarPointer = register_cvar() // In plugin_init()
// ...
fMyAngle = get_pcvar_float(pCvarPointer)
__________________

Last edited by fysiks; 01-31-2016 at 23:07.
fysiks is offline
Sn3amtz
Senior Member
Join Date: Jan 2015
Location: France
Old 01-31-2016 , 23:31   Re: Angle Cvar
Reply With Quote #3

something is wrong

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

#define PLUGIN "Anti Behind" 
#define VERSION "1.1" 
#define AUTHOR "Bobs" 

#define fm_get_user_team(%1) get_pdata_int(%1, FM_OFFSET_TEAM) 
#define FM_OFFSET_TEAM 114 

#define BACKSTAB_ANGLE 93.0     
#define BACKSTAB_MAX_DAMAGE 0.0 

new gMaxPlayers; 
new bool:gBackStabing[33]; 
new cvar_respawn; 
new pCvarAngleX;
new pCvarAngleY;

public plugin_init()   
{ 
    register_plugin(PLUGIN, VERSION, AUTHOR); 
     
    register_forward(FM_CmdStart, "Fwd_CmdStart"); 
     
    cvar_respawn = register_cvar("ab_respawn", "1"); 
    pCvarAngleX = register_cvar("ab_angle_min", "93.0");
    pCvarAngleY = register_cvar("ab_angle_max", "93.0");  


    RegisterHam(Ham_TakeDamage, "player", "Event_TakeDamage"); 
     
    gMaxPlayers = global_get(glb_maxClients); 
     
} 

public Fwd_CmdStart(id, uc_handle, uc_seed) 
{ 
    if(!is_user_alive(id)) 
        return FMRES_IGNORED; 
     
    static Float:fViewAngles[3], iButton, iTemp; 
    get_uc(uc_handle, UC_ViewAngles, fViewAngles); 
    iButton = get_uc(uc_handle, UC_Buttons); 
     
    if(((iButton & IN_ATTACK) || (iButton & IN_ATTACK2)) && get_user_weapon(id, iTemp, iTemp) == CSW_KNIFE) 
    { 
        static iEnt, Float:fOrigin[3]; 
        pev(id, pev_origin, fOrigin); 
         
        iEnt = fm_trace_target(id, fOrigin, 100); 
         
        if(!(1 <= iEnt <= gMaxPlayers)) 
            return FMRES_IGNORED; 
         
        static Float:fTViewAngles[3]; 
        pev(iEnt, pev_v_angle, fTViewAngles); 
         
        new Float:fMinAngle, Float:fMaxAngle; 
        fMinAngle = get_pcvar_float(pCvarAngleX), fViewAngles[1] - BACKSTAB_ANGLE; 
        fMaxAngle = get_pcvar_float(pCvarAngleY), fViewAngles[1] + BACKSTAB_ANGLE; 
         
        if(fMinAngle <= fTViewAngles[1] <= fMaxAngle) 
        { 
            gBackStabing[id] = true; 
        } 
        else 
        { 
            gBackStabing[id] = false; 
        } 
    } 
    return FMRES_IGNORED; 
} 

public Event_TakeDamage(this, inflictor, attacker, Float:damage, dmgbits) 
{ 
    if(inflictor == 0) 
        return HAM_IGNORED; 
     
    if(!is_user_alive(attacker) || !gBackStabing[attacker] || (fm_get_user_team(this) == fm_get_user_team(attacker))) 
        return HAM_IGNORED; 
     
    if(damage > BACKSTAB_MAX_DAMAGE) 
    { 
        SetHamParamFloat(4, BACKSTAB_MAX_DAMAGE); 
   
        if(get_pcvar_num(cvar_respawn)) 
        { 
        ExecuteHamB(Ham_CS_RoundRespawn, attacker)   
       } 
    } 
    return HAM_HANDLED; 
} 

stock fm_trace_target(ignoreent, const Float:start[3], distance) 
{ 
    new Float:fAim[3], Float:end[3]; 
    velocity_by_aim(ignoreent, distance, fAim); 
     
    end[0] = start[0] + fAim[0]; 
    end[1] = start[1] + fAim[1]; 
    end[2] = start[2] + fAim[2]; 
     
    engfunc(EngFunc_TraceLine, start, end, ignoreent == -1 ? 1 : 0, ignoreent, 0); 
     
    new ent = get_tr2(0, TR_pHit); 

    return pev_valid(ent) ? ent : 0; 
} 


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE 
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1030\\ f0\\ fs16 \n\\ par } 
*/

Last edited by Sn3amtz; 02-01-2016 at 00:25.
Sn3amtz is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 02-01-2016 , 17:15   Re: Angle Cvar
Reply With Quote #4

Delete #define BACKSTAB_ANGLE 93.0

Code:
new pcvar_angle;

pcvar_angle = register_cvar("ab_angle", "93.0");

static Float:fMinAngle, Float:fMaxAngle; 
fMinAngle = fViewAngles[1] - get_pcvar_float(pcvar_angle); 
fMaxAngle = fViewAngles[1] + get_pcvar_float(pcvar_angle);

Last edited by raizo11; 02-01-2016 at 17:16.
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
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 09:22.


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