Block BHop/DD

Block BHop/DD 1.0.1

Нет прав для скачивания
Код:
////////////////////////////////    HEADER    ////////////////////////////////

#include <amxmodx>
#include <fakemeta>

#define PLUGIN_NAME     "Block BHop/DD"
#define PLUGIN_VERSION  "1.0.1"
#define PLUGIN_AUTHOR   "Albertio & Garey"

////////////////////////////////    CONSTANTS    ////////////////////////////////

// Comment to unlock the Bunny Hop
#define BLOCK_BHOP

// Comment to unlock the Double Duck
#define BLOCK_DD

#define is_client(%0) (1 <= %0 <= MaxClients)

#define is_entity_on_ground(%0) (pev(%0, pev_flags) & FL_ONGROUND)

////////////////////////////////    GLOBAL VARIABLES    ////////////////////////////////

enum CVARS {
    Float:GROUND_DELAY
};

new Cvars[CVARS];

new Float:TimeOnGround[MAX_PLAYERS + 1];

////////////////////////////////    CONFIGURATION    ////////////////////////////////

public plugin_init() {
    register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);

    CreateCvars();

    register_forward(FM_CmdStart, "CmdStart_Pre", false);   
}

public CreateCvars() {
    new cvar = create_cvar(
        "bbdd_ground_delay",
        "50.0",
        FCVAR_NONE,
        "The minimum amount of time(msec) that a player must stay on the ground",
        true,
        0.0
    );

    bind_pcvar_float(cvar, Cvars[GROUND_DELAY]);
}

////////////////////////////////    MAIN FUNCTIONS    ////////////////////////////////

public CmdStart_Pre(const playerId, const cmd) {
    if(!is_client(playerId))
        return;

    if(!is_entity_on_ground(playerId)) {
        TimeOnGround[playerId] = 0.0;
        return;
    }

    new Float:msec = float(get_uc(cmd, UC_Msec));
    TimeOnGround[playerId] += msec;

    if(TimeOnGround[playerId] < Cvars[GROUND_DELAY])
        BlockTricks(playerId, cmd);
}

////////////////////////////////    STOCK FUNCTIONS    ////////////////////////////////

stock BlockTricks(const playerId, const cmd) {
    new buttons = get_uc(cmd, UC_Buttons);
    new oldButtons = pev(playerId, pev_oldbuttons);
    
#if defined BLOCK_BHOP
    TricksHandler(buttons, oldButtons, IN_JUMP);
#endif

#if defined BLOCK_DD
    TricksHandler(buttons, oldButtons, IN_DUCK);
#endif

    set_uc(cmd, UC_Buttons, buttons);
    set_pev(playerId, pev_oldbuttons, oldButtons);
}

stock TricksHandler(&buttons, &oldButtons, const key) {
    new tryTrick = (buttons|oldButtons) & key;

    if(tryTrick) {
        buttons |= key;
        oldButtons |= key;
    }
}
Назад
Верх