AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block IN_JUMP when player hold another button (https://forums.alliedmods.net/showthread.php?t=237266)

wicho 03-21-2014 01:30

Block IN_JUMP when player hold another button
 
Hi everybody, well im trying to block IN_JUMP button when a player hold right, left and forward button at the same time, but i want to activate the button IN_JUMP again when the player stop hold this buttons i mean left, right and forward button, i found a code of connor but i dunno how i can make to block jump button when the player hold the buttons that i mentioned, then when this stop hold button i want to enable the IN_JUMP button again, how i can make this? can someone help me.. thx in advance

another thing can u tell me if the code is fine?

code:

PHP Code:

#include <amxmodx> 
#include <fakemeta> 

#define m_afButtonLast 245 

public plugin_init() 

    
register_forward(FM_CmdStart"OnCmdStart"false


public 
OnCmdStart(idcmd

    static 
buttonsbuttonsChangedbuttonPressedbuttonReleased 
    buttons 
get_uc(cmdUC_Buttons

    
buttonsChanged get_pdata_int(idm_afButtonLast) ^ buttons 

    buttonPressed 
buttonsChanged buttons 
    buttonReleased 
buttonsChanged & ~buttons 

    
if(buttonPressed IN_FORWARD && buttonPressed IN_MOVERIGHT && buttonPressed IN_MOVELEFT
    { 
       
set_pevidpev_oldbuttonspevidpev_oldbuttons ) | IN_JUMP )
    } 
    else if(
buttonReleased  IN_FORWARD && buttonReleased  IN_MOVERIGHT && buttonReleased  IN_MOVELEFT
    { 
        
set_pevidpev_oldbuttonspevidpev_oldbuttons ) & ~IN_JUMP )
    } 



LukeyB 03-25-2014 18:17

Re: Block IN_JUMP when player hold another button
 
This should work:

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <orpheu>
#include <orpheu_advanced>
#include <orpheu_memory>
public plugin_init()
{
    
register_plugin"BlockJump""1.0""LukeyB" )
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"),"OnPM_Jump")
}
public 
OrpheuHookReturn:OnPM_Jump()
{
    new 
OrpheuStruct:ppmove get_ppmove()
    new 
id OrpheuGetStructMember(ppmove,"player_index") + 1
    
static button button pev(idpev_button)
    if(
is_user_alive(id) && (button IN_FORWARD || button IN_MOVELEFT || button IN_MOVERIGHT))
    {
        return 
OrpheuSupercede
    
}
    return 
OrpheuIgnored
}
OrpheuStruct:get_ppmove()
{        
    return 
OrpheuGetStructFromAddress(OrpheuStructPlayerMove,OrpheuMemoryGet("ppmove"))



nonserviam 03-26-2014 07:04

Re: Block IN_JUMP when player hold another button
 
INS, END, F8, F9 buttons applied for this?

WildCard65 03-26-2014 11:34

Re: Block IN_JUMP when player hold another button
 
Quote:

Originally Posted by nonserviam (Post 2116059)
INS, END, F8, F9 buttons applied for this?

If your asking if it checks the exact button press, then it's no, also as I read in other threads, you can only block the command sent to the server and not the actual key the command is bound to.

nonserviam 03-26-2014 11:54

Re: Block IN_JUMP when player hold another button
 
Your information useful. Thank you.


All times are GMT -4. The time now is 05:59.

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