AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to block player jump or duck? (https://forums.alliedmods.net/showthread.php?t=224295)

@.SizNeR 08-22-2013 12:01

How to block player jump or duck?
 
How can I block a player jump/duck?

red_bull2oo6 08-22-2013 14:01

Re: How to block player jump or duck?
 
you can hook player jump and duck with hamsandwich..
look in mousewheel forcer

@.SizNeR 08-22-2013 21:40

Re: How to block player jump or duck?
 
Quote:

Originally Posted by red_bull2oo6 (Post 2019533)
you can hook player jump and duck with hamsandwich..
look in mousewheel forcer

Yes but how i block player jump or duck?

red_bull2oo6 08-23-2013 05:21

Re: How to block player jump or duck?
 
well you can try this, but idk if it`s accurate.

you can't jump and you can't duck

PHP Code:

#include < amxmodx >
#include < engine >
#include < hamsandwich >

#pragma semicolon 1


#define PLUGIN "New Plugin"
#define VERSION "0.0.1"

new g_iCvarJump;
new 
g_iCvarDuck;

public 
plugin_init( )
{
    
// took the method from mwheel_force.
    
register_pluginPLUGINVERSION"Askhanar" );
    
g_iCvarJump register_cvar"amx_block_jump""1" );
    
g_iCvarDuck register_cvar"amx_block_duck""1" );
    
    
RegisterHamHam_Player_Jump"player""ham_PlayerJumpPre"true );
    
RegisterHamHam_Player_Duck"player""ham_PlayerDuckPre"true );
    
}

public 
ham_PlayerJumpPreid )
{
    if( !
get_pcvar_numg_iCvarJump ) )
        return;
        
    static 
iOldButtons;
    
iOldButtons entity_get_intidEV_INT_oldbuttons );
    
    if( !( 
iOldButtons IN_JUMP ) &&  entity_get_intidEV_INT_flags ) & FL_ONGROUND )
        
entity_set_intidEV_INT_oldbuttonsiOldButtons IN_JUMP );
            
            
}

public 
ham_PlayerDuckPreid )
{
    if( !
get_pcvar_numg_iCvarDuck ) )
        return;
        
    static 
iOldButtons;
    
iOldButtons entity_get_intidEV_INT_oldbuttons );
    
    if( !( 
iOldButtons IN_DUCK ) &&  entity_get_intidEV_INT_flags ) & FL_ONGROUND )
        
entity_set_intidEV_INT_oldbuttonsiOldButtons IN_DUCK );




Kz1.0 08-23-2013 06:57

Re: How to block player jump or duck?
 
Quote:

Originally Posted by LordOfNothing (Post 2019892)
PHP Code:

new pCvar;
new 
tCvar;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("+jump","hook_jump")
    
register_clcmd("+duck","hook_duck")
    
pCvar register_cvar("sv_blockjump","1")
    
tCvar register_cvar("sv_blockduck","1")
}

public 
hook_jump(id)
{
    if(
get_pcvar_numpCvar ))
    {
        return 
1;
    } 
    return 
0;
    
}
public 
hook_duck(id)
{
    if(
get_pcvar_numtCvar ))
    {
        return 
1;
    } 
    return 
0;
    
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1048\\ f0\\ fs16 \n\\ par }
*/ 


wow

pokemonmaster 08-23-2013 16:10

Re: How to block player jump or duck?
 
try
PHP Code:

#include <amxmodx>
#include <fakemeta>

new g_pAllowDuckg_pAllowJump

public plugin_init()
{
    
register_plugin("Block Something""0.001""ZomeGuY")

    
register_forward(FM_CmdStart"fw_CmdStart_Pre"0)

    
g_pAllowDuck register_cvar("amx_allow_duck""0")
    
g_pAllowJump register_cvar("amx_allow_jump""0")
}

public 
fw_CmdStart_Pre(iduc_handleseed)
{
    if(!
is_user_alive(id))
    {
        return;
    }

    new 
iButtons get_uc(uc_handleUC_Buttons)

    if(
iButtons IN_DUCK)
    {
        if(
get_pcvar_num(g_pAllowDuck))
        {
            return;
        }

        
set_uc(uc_handleUC_ButtonsiButtons & ~IN_DUCK)
        return;
    }

    if(
iButtons IN_JUMP)
    {
        if(
get_pcvar_num(g_pAllowJump))
        {
            return;
        }

        
set_uc(uc_handleUC_ButtonsiButtons & ~IN_JUMP)
    }



@.SizNeR 08-23-2013 16:30

Re: How to block player jump or duck?
 
Quote:

Originally Posted by pokemonmaster (Post 2020293)
try
PHP Code:

#include <amxmodx>
#include <fakemeta>

new g_pAllowDuckg_pAllowJump

public plugin_init()
{
    
register_plugin("Block Something""0.001""ZomeGuY")

    
register_forward(FM_CmdStart"fw_CmdStart_Pre"0)

    
g_pAllowDuck register_cvar("amx_allow_duck""0")
    
g_pAllowJump register_cvar("amx_allow_jump""0")
}

public 
fw_CmdStart_Pre(iduc_handleseed)
{
    if(!
is_user_alive(id))
    {
        return;
    }

    new 
iButtons get_uc(uc_handleUC_Buttons)

    if(
iButtons IN_DUCK)
    {
        if(
get_pcvar_num(g_pAllowDuck))
        {
            return;
        }

        
set_uc(uc_handleUC_ButtonsiButtons & ~IN_DUCK)
        return;
    }

    if(
iButtons IN_JUMP)
    {
        if(
get_pcvar_num(g_pAllowJump))
        {
            return;
        }

        
set_uc(uc_handleUC_ButtonsiButtons & ~IN_JUMP)
    }



Dont working...

simanovich 08-23-2013 16:37

Re: How to block player jump or duck?
 
Quote:

Originally Posted by red_bull2oo6 (Post 2019961)
well you can try this, but idk if it`s accurate.

you can't jump and you can't duck

PHP Code:

#include < amxmodx >
#include < engine >
#include < hamsandwich >

#pragma semicolon 1


#define PLUGIN "New Plugin"
#define VERSION "0.0.1"

new g_iCvarJump;
new 
g_iCvarDuck;

public 
plugin_init( )
{
    
// took the method from mwheel_force.
    
register_pluginPLUGINVERSION"Askhanar" );
    
g_iCvarJump register_cvar"amx_block_jump""1" );
    
g_iCvarDuck register_cvar"amx_block_duck""1" );
    
    
RegisterHamHam_Player_Jump"player""ham_PlayerJumpPre"true );
    
RegisterHamHam_Player_Duck"player""ham_PlayerDuckPre"true );
    
}

public 
ham_PlayerJumpPreid )
{
    if( !
get_pcvar_numg_iCvarJump ) )
        return;
        
    static 
iOldButtons;
    
iOldButtons entity_get_intidEV_INT_oldbuttons );
    
    if( !( 
iOldButtons IN_JUMP ) &&  entity_get_intidEV_INT_flags ) & FL_ONGROUND )
        
entity_set_intidEV_INT_oldbuttonsiOldButtons IN_JUMP );
            
            
}

public 
ham_PlayerDuckPreid )
{
    if( !
get_pcvar_numg_iCvarDuck ) )
        return;
        
    static 
iOldButtons;
    
iOldButtons entity_get_intidEV_INT_oldbuttons );
    
    if( !( 
iOldButtons IN_DUCK ) &&  entity_get_intidEV_INT_flags ) & FL_ONGROUND )
        
entity_set_intidEV_INT_oldbuttonsiOldButtons IN_DUCK );




Why using post when you write pre?

red_bull2oo6 08-23-2013 18:17

Re: How to block player jump or duck?
 
from what i know Post = 0 or false ( that's what i understand from here ).

PHP Code:

/**
 * Hooks the virtual table for the specified entity class.
 * An example would be: RegisterHam(Ham_TakeDamage, "player", "player_hurt");
 * Look at the Ham enum for parameter lists.
 *
 * @param function        The function to hook.
 * @param EntityClass    The entity classname to hook.
 * @param callback        The forward to call.
 * @param post            Whether or not to forward this in post.
 * @return                 Returns a handle to the forward.  Use EnableHamForward/DisableHamForward to toggle the forward on or off.
 */
native HamHook:RegisterHam(Ham:function, const EntityClass[], const Callback[], Post=0); 


@.SizNeR 08-23-2013 18:32

Re: How to block player jump or duck?
 
I have another thing:
Code:
#include < amxmodx > #include < amxmisc > new g_szAdminsFile[ 64 ]; public plugin_init() {          // ...          get_configsdir( g_szAdminsFile, charsmax( g_szAdminsFile ) );          format( g_szAdminsFile, charsmax( g_szAdminsFile ), "%s/users.ini",  g_szAdminsFile ); } public MyPublic() {          // ...          new iFile = fopen( g_szAdminsFile, "rt" ); }

Error:
PHP Code:

ErrorInvalid symbol name "" on line 422
Error
Undefined symbol "iFile" on line 422 

Line 422:
PHP Code:

new iFile fopeng_szAdminsFile"rt" ); 

Help Please?


All times are GMT -4. The time now is 19:14.

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