The server is using kz_mwheel.amxx to force the players to chose between the binds that can be applied on their mouse wheel . The problem is that everytime a player scrolls up or down to jump or duck , the console spams with
Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <nvault>
#define NVAULT_MAX_DAYS_SAVE 30
/*
Credit to Exolent for original (?) idea,
Fatalis for original plugin
*/
#define PLUGIN "Mwheel_Forcer"
#define AUTHOR "Fatalis/ConnorMcLeod"
#define VERSION "2.1.1"
#define MAX_PLAYERS 32
#define A_DAY_IN_SECONDS 86400 // 60 * 60 * 24
#define SetIdBits(%1,%2) %1 |= 1<<(%2 & 31)
#define ClearIdBits(%1,%2) %1 &= ~( 1<<(%2 & 31) )
#define GetIdBits(%1,%2) ( %1 & 1<<(%2 & 31) )
const g_iChooseKeys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4
const g_iAcceptKeys = MENU_KEY_1|MENU_KEY_2
enum Wheel_Settings
{
SETTING_NONE,
SETTING_JUMPDUCK,
SETTING_DUCKJUMP,
SETTING_JUMPJUMP
}
new const g_szForceBindsCmds[Wheel_Settings][] =
{
"",
";bind mwheeldown +jump;bind mwheelup +duck",
";bind mwheeldown +duck;bind mwheelup +jump",
";bind mwheeldown +jump;bind mwheelup +jump"
}
new g_iNvault
new g_iThinkingEnt
new g_iKickMe[MAX_PLAYERS+1]
new Wheel_Settings:g_iSetting[MAX_PLAYERS+1]
new g_bAccepted
new g_bChooseMenuShown
new g_bCommandRanOnce
new HamHook:g_hMagicThink
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_dictionary("mwheel.txt")
register_cvar(PLUGIN, VERSION, FCVAR_SERVER)
RegisterHam(Ham_Player_Jump, "player", "Player_Jump")
register_clcmd("say /mwheel", "ClientCommand_Binds")
register_menucmd(register_menuid("MwheelForcer"), g_iChooseKeys, "ChooseMenu_Action")
register_menucmd(register_menuid("MwheelAccept"), g_iAcceptKeys, "AcceptMenu_Action")
g_iNvault = nvault_open("mwheel")
nvault_prune( g_iNvault, 0, get_systime(-(A_DAY_IN_SECONDS * NVAULT_MAX_DAYS_SAVE)) )
g_iThinkingEnt = get_magic_think_ent_index()
g_hMagicThink = RegisterHamFromEntity(Ham_Think, g_iThinkingEnt, "ImGonnaKickYou", 1)
DisableHamForward( g_hMagicThink )
}
get_magic_think_ent_index()
{
new szClass[2], iMaxEnt = get_global_int(GL_maxEntities)
for(new iEnt = get_maxplayers() + 1; iEnt < iMaxEnt; iEnt++)
{
if( is_valid_ent( iEnt ) && !entity_get_string(iEnt, EV_SZ_classname, szClass, charsmax(szClass)) )
{
return iEnt
}
}
return 0
}
public plugin_end()
{
nvault_close(g_iNvault)
}
GetPlayerAuthid( id, bool:bSet = false )
{
static szAuthid[MAX_PLAYERS][32]
if( bSet )
{
get_user_authid(id, szAuthid[id-1], charsmax(szAuthid[]))
}
return szAuthid[id-1]
}
public client_authorized( id )
{
GetPlayerAuthid(id, true)
if( (g_iSetting[id] = Wheel_Settings:nvault_get(g_iNvault, GetPlayerAuthid(id))) )
{
SetIdBits(g_bAccepted, id)
SetIdBits(g_bChooseMenuShown, id)
}
else
{
ClearIdBits(g_bAccepted, id)
ClearIdBits(g_bChooseMenuShown, id)
}
ClearIdBits(g_bCommandRanOnce, id)
g_iKickMe[id] = -1
}
public client_disconnect( id )
{
g_iKickMe[id] = -1
CheckTaskRemove()
}
public Player_Jump( id )
{
if( !( entity_get_int(id, EV_INT_oldbuttons) & IN_JUMP )
&& entity_get_int(id, EV_INT_flags) & FL_ONGROUND )
{
if( GetIdBits(g_bAccepted, id) )
{
client_cmd( id, g_szForceBindsCmds[ g_iSetting[id] ] )
}
else
{
entity_set_int(id, EV_INT_oldbuttons, entity_get_int(id, EV_INT_oldbuttons) | IN_JUMP)
if( !GetIdBits(g_bChooseMenuShown, id) )
{
SetIdBits(g_bChooseMenuShown, id)
ShowChooseMenu(id)
g_iKickMe[id] = 90
EnableHamForward( g_hMagicThink )
}
}
}
}
public ClientCommand_Binds(id)
{
if( !GetIdBits(g_bCommandRanOnce, id) )
{
SetIdBits(g_bCommandRanOnce, id)
ClearIdBits(g_bAccepted, id)
nvault_set(g_iNvault, GetPlayerAuthid(id), "0")
g_iSetting[id] = SETTING_NONE
ShowChooseMenu(id)
g_iKickMe[id] = 90
EnableHamForward( g_hMagicThink )
}
else
{
client_print(id, print_chat, "%L", id, "KZMWHEEL_ONCEPERMAP")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
ShowChooseMenu(id)
{
new szMenu[512]
formatex(szMenu, charsmax(szMenu), "%L", id, "KZMWHEEL_CHOOSEMENU")
show_menu(id, g_iChooseKeys, szMenu, -1, "MwheelForcer")
}
public ImGonnaKickYou( iEnt )
{
if( iEnt == g_iThinkingEnt )
{
static iPlayers[MAX_PLAYERS], iNum, id, iKickMe
get_players(iPlayers, iNum)
for(--iNum; iNum>=0; iNum--)
{
id = iPlayers[iNum]
iKickMe = --g_iKickMe[id]
if( iKickMe == 0 )
{
OkKickMeThen(id)
}
else if( iKickMe > 0 )
{
client_print(id, print_center, "Kick in %d sec", iKickMe/3)
}
}
}
CheckTaskRemove()
}
CheckTaskRemove()
{
static iPlayers[MAX_PLAYERS], iNum
get_players(iPlayers, iNum, "ch")
for(--iNum; iNum>=0; iNum--)
{
if( g_iKickMe[ iPlayers[iNum] ] > 0 )
{
return
}
}
DisableHamForward( g_hMagicThink )
}
OkKickMeThen(id)
{
server_cmd("kick #%i %L", get_user_userid(id), id, "KZMWHEEL_NOTFASTENOUGH")
}
public ChooseMenu_Action(id, iKey)
{
switch( iKey )
{
case 0:
{
g_iSetting[id] = SETTING_JUMPDUCK
ShowAcceptMenu(id)
}
case 1:
{
g_iSetting[id] = SETTING_DUCKJUMP
ShowAcceptMenu(id)
}
case 2:
{
g_iSetting[id] = SETTING_JUMPJUMP
ShowAcceptMenu(id)
}
case 3:
{
client_print(id, print_chat, "%L", id, "KZMWHEEL_PREFERREDMETHOD")
ShowChooseMenu(id)
}
}
return PLUGIN_HANDLED
}
ShowAcceptMenu(id)
{
new szMenu[512]
formatex(szMenu, charsmax(szMenu), "%L", id, "KZMWHEEL_ACCEPT")
show_menu(id, g_iAcceptKeys, szMenu, -1, "MwheelAccept")
}
public AcceptMenu_Action(id, iKey)
{
switch( iKey )
{
case 0:
{
g_iKickMe[id] = -1
new szSetting[2]
szSetting[0] = '0' + _:g_iSetting[id]
nvault_set(g_iNvault, GetPlayerAuthid(id), szSetting)
SetIdBits(g_bAccepted, id)
}
case 1:
{
OkKickMeThen(id)
}
}
return PLUGIN_HANDLED
}