Raised This Month: $ Target: $400
 0% 

Mouse wheel binds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
darksidebv
Junior Member
Join Date: Mar 2015
Old 05-15-2015 , 06:12   Mouse wheel binds
Reply With Quote #1

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:
Server tried to send invalid command:"bind mwheeldown +jump;bind mwheelup +duck"
The source of the plugin can be found below .
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
}
darksidebv is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-15-2015 , 06:47   Re: Mouse wheel binds
Reply With Quote #2

It's no longer possible (and no longer supported) to bind player keys. The best you can do is to inform them to change their bind.
__________________
fysiks is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 05-15-2015 , 06:59   Re: Mouse wheel binds
Reply With Quote #3

Try with console_cmd
FromTheFuture is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-15-2015 , 07:28   Re: Mouse wheel binds
Reply With Quote #4

Quote:
Originally Posted by FromTheFuture View Post
Try with console_cmd
Binds no longer work so that suggestion is pointless.
__________________

Last edited by fysiks; 05-15-2015 at 07:28.
fysiks is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 05-15-2015 , 08:09   Re: Mouse wheel binds
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
Binds no longer work so that suggestion is pointless.
what about stuff_cmd?
FromTheFuture is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-15-2015 , 08:54   Re: Mouse wheel binds
Reply With Quote #6

Quote:
Originally Posted by FromTheFuture View Post
what about stuff_cmd?
Man go learn rules, this is not the first time i see you suggesting to slowhack the client. You can't change client permissions without his own authorization, it doesnt matter if it can be done or not.
__________________
Jhob94 is offline
FromTheFuture
Senior Member
Join Date: Jan 2013
Old 05-15-2015 , 08:55   Re: Mouse wheel binds
Reply With Quote #7

Quote:
Originally Posted by Jhob94 View Post
this is not the first time i see you suggesting to slowhack the client
Where and when im trying to make slowhacking? Do not lie.
FromTheFuture is offline
Shiina.Mashiro
Senior Member
Join Date: Sep 2014
Location: Vietnam
Old 05-15-2015 , 09:57   Re: Mouse wheel binds
Reply With Quote #8

Quote:
Originally Posted by FromTheFuture View Post
Where and when im trying to make slowhacking? Do not lie.
Isn't that obvious? Btw you should inform your player to bind their key on their own, you can't force them to do that without their permissions.
__________________
Shiina.Mashiro is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-15-2015 , 09:58   Re: Mouse wheel binds
Reply With Quote #9

Quote:
Originally Posted by FromTheFuture View Post
Where and when im trying to make slowhacking? Do not lie.
In every post you made so far in this thread.
__________________
Black Rose is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-15-2015 , 10:05   Re: Mouse wheel binds
Reply With Quote #10

Quote:
Originally Posted by FromTheFuture View Post
Where and when im trying to make slowhacking? Do not lie.
You just told him to use console_cmd to force binding the client. That's is a slowhack, and a big slowhack, hated by every client and server owners too. About the other one i was wrong, you were the one asking for help and the other one was the one that suggested to slowhack, my bad.
__________________
Jhob94 is offline
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 10:34.


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