AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Add Admin immunity here? (https://forums.alliedmods.net/showthread.php?t=228962)

wAyz 10-30-2013 06:33

Add Admin immunity here?
 
Hi,

I just want to add immunity to the following plugin (so that admins are not effected by blockattack). Tried several things with get_user_flags etc, but didn't succeed.

Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
        register_plugin("Block Attack", "1.0", "LeOnArD");
       
        /*Aqui poner el nombre de las armas que quieras Bloquear.
       
        Here you put the name of the weapons that you want the Block.*/
       
        RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_knife", "PrimaryAttack" );
        RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_knife", "SecondaryAttack" );
        RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_usp", "PrimaryAttack" );
        RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_usp", "SecondaryAttack" );
       
        /*Aqui estan las armas que le pueden Bloquear la Accion Secundaria.
       
        Here are the weapons that can Block the Secondary Action.*/
       
        RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_awp", "SecondaryAttack" );
        RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_scout", "SecondaryAttack" );
        RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_g3sg1", "SecondaryAttack" );
        RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_sg550", "SecondaryAttack" );
}

public PrimaryAttack( const entity )
{
        return HAM_SUPERCEDE;
}

public SecondaryAttack( const entity )
{
        return HAM_SUPERCEDE;
}


simanovich 10-30-2013 09:21

Re: Add Admin immunity here?
 
Because the passed entity index is the weapon entity index and not the player id.

PHP Code:

#include <amxmodx>
#include <hamsandwich>

const XO_CBASEPLAYERITEM 4;
const 
m_iId 43;

public 
plugin_init()
{
    
register_plugin("Block Attack""1.0""LeOnArD");
    
    
/*Aqui poner el nombre de las armas que quieras Bloquear.
    
    Here you put the name of the weapons that you want the Block.*/
    
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_knife""PrimaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_knife""SecondaryAttack" );
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_usp""PrimaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_usp""SecondaryAttack" );
    
    
/*Aqui estan las armas que le pueden Bloquear la Accion Secundaria.
    
    Here are the weapons that can Block the Secondary Action.*/
    
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_awp""SecondaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_scout""SecondaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_g3sg1""SecondaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_sg550""SecondaryAttack" );
}

public 
PrimaryAttack( const entity )
{
    static 
client;

    
client get_pdata_base(entitym_iIdXO_CBASEPLAYERITEM);

    if (!
is_user_alive(client))
        return 
HAM_IGNORED;

    if (
get_user_flags(client) & ADMIN_IMMUNITY)
        return 
HAM_IGNORED;

    return 
HAM_SUPERCEDE;
}

public 
SecondaryAttack( const entity )
{
    static 
client;

    
client get_pdata_base(entitym_iIdXO_CBASEPLAYERITEM);

    if (!
is_user_alive(client))
        return 
HAM_IGNORED;

    if (
get_user_flags(client) & ADMIN_IMMUNITY)
        return 
HAM_IGNORED;

    return 
HAM_SUPERCEDE;



wAyz 10-30-2013 11:39

Re: Add Admin immunity here?
 
Quote:

Originally Posted by simanovich (Post 2054599)
Because the passed entity index is the weapon entity index and not the player id.

PHP Code:

#include <amxmodx>
#include <hamsandwich>

const XO_CBASEPLAYERITEM 4;
const 
m_iId 43;

public 
plugin_init()
{
    
register_plugin("Block Attack""1.0""LeOnArD");
    
    
/*Aqui poner el nombre de las armas que quieras Bloquear.
    
    Here you put the name of the weapons that you want the Block.*/
    
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_knife""PrimaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_knife""SecondaryAttack" );
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_usp""PrimaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_usp""SecondaryAttack" );
    
    
/*Aqui estan las armas que le pueden Bloquear la Accion Secundaria.
    
    Here are the weapons that can Block the Secondary Action.*/
    
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_awp""SecondaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_scout""SecondaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_g3sg1""SecondaryAttack" );
    
RegisterHamHam_Weapon_SecondaryAttack"weapon_sg550""SecondaryAttack" );
}

public 
PrimaryAttack( const entity )
{
    static 
client;

    
client get_pdata_base(entitym_iIdXO_CBASEPLAYERITEM);

    if (!
is_user_alive(client))
        return 
HAM_IGNORED;

    if (
get_user_flags(client) & ADMIN_IMMUNITY)
        return 
HAM_IGNORED;

    return 
HAM_SUPERCEDE;
}

public 
SecondaryAttack( const entity )
{
    static 
client;

    
client get_pdata_base(entitym_iIdXO_CBASEPLAYERITEM);

    if (!
is_user_alive(client))
        return 
HAM_IGNORED;

    if (
get_user_flags(client) & ADMIN_IMMUNITY)
        return 
HAM_IGNORED;

    return 
HAM_SUPERCEDE;



I am getting an "undefined symbol" error: get_pdata_base

simanovich 10-30-2013 11:58

Re: Add Admin immunity here?
 
Quote:

Originally Posted by wAyz (Post 2054643)
I am getting an "undefined symbol" error: get_pdata_base

Whoops

PHP Code:

get_pdata_base 

---------->
PHP Code:

get_pdata_cbase 


wAyz 10-30-2013 12:21

Re: Add Admin immunity here?
 
Code:

L 10/30/2013 - 17:20:01: [HAMSANDWICH] Function SecondaryAttack not found.
L 10/30/2013 - 17:20:01: [AMXX] Run time error 10 (plugin "blockattack.amxx") (native "RegisterHam") - debug not enabled!
L 10/30/2013 - 17:20:01: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).


Black Rose 10-30-2013 14:11

Add Admin immunity here?
 
Quote:

Originally Posted by wAyz (Post 2054657)
Code:

L 10/30/2013 - 17:20:01: [HAMSANDWICH] Function SecondaryAttack not found.
L 10/30/2013 - 17:20:01: [AMXX] Run time error 10 (plugin "blockattack.amxx") (native "RegisterHam") - debug not enabled!
L 10/30/2013 - 17:20:01: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).


Did you make any changes?


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

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