I copie some parts of codes and tried to made a plugin that give autobhop to players when they type /bhop. But it didn't worked.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#define PLUGIN "Bhop"
#define AUTHOR "AUTHOR"
#define VERSION "0.1"
#define MAX_PLAYERS 32
#define PLAYER_JUMP 6
#define PLAYER_MAX_SAFE_FALL_SPEED 580
#define MULTI 0
#define WALL 1
#define AUTOBHOP 2
#define LONGJUMP 3
#define NORMAL 5
#define CANCEL 9
#define KEYS ((1<<MULTI)|(1<<WALL)|(1<<AUTOBHOP)|(1<<LONGJUMP)|(1<<NORMAL)|(1<<CANCEL))
new g_pCvarAutoBhops
new g_iJumpType[MAX_PLAYERS+1]
new g_iJumps[MAX_PLAYERS+1]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Player_Jump, "player", "Player_Jump")
RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
register_clcmd("say /bhop", "ClientCommand_Jump")
g_pCvarAutoBhops = register_cvar("ja_autobhop_limit", "300")
}
public Player_Spawn(id)
{
if( !is_user_alive(id) )
{
g_iJumpType[id] = NORMAL
}
}
public ClientCommand_Jump(id)
{
if( !is_user_alive(id) )
{
g_iJumpType[id] = AUTOBHOP
}
}
public Player_Jump(id)
{
if( !is_user_alive(id)
|| pev(id, pev_waterlevel) >= 2 )
{
return
}
switch( g_iJumpType[id] )
{
case AUTOBHOP:AutoBhop(id)
}
}
AutoBhop(id)
{
static iFlags ; iFlags = pev(id, pev_flags)
if( !(iFlags & FL_ONGROUND) )
{
return
}
static iOldButtons ; iOldButtons = pev(id, pev_oldbuttons)
if( !(iOldButtons & IN_JUMP) )
{
g_iJumps[id] = 0
return
}
set_pev(id, pev_oldbuttons, iOldButtons | IN_JUMP)
static iLimit ; iLimit = get_pcvar_num(g_pCvarAutoBhops)
if( iLimit && g_iJumps[id]++ >= iLimit )
{
return
}
}
__________________