AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blocking weapon fire, cvar (https://forums.alliedmods.net/showthread.php?t=163639)

J4CK 08-01-2011 16:10

Blocking weapon fire, cvar
 
I found plugin by ConnorMcLeod (source: #47)
But i can't add cvar for enable/disable.
What's wrong ?

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

// weapons offsets
#define XO_WEAPONS 4
#define m_pPlayer 41
#define m_iId 43
#define m_flNextPrimaryAttack 46
#define m_flNextSecondaryAttack 47

// players offsets
#define XO_PLAYER 5
#define m_flNextAttack 83

public plugin_init()
{
    
register_cvar("amx_nodamage""0")

    new 
szWeaponName[20]
    for(new 
i=CSW_P228i<=CSW_P90i++)
    {
        if( 
get_weaponname(iszWeaponNamecharsmax(szWeaponName)) && get_cvar_num("amx_nodamage") == )
        {
            
RegisterHam(Ham_Item_DeployszWeaponName"Weapons_Deploy"true)
        }
    }
}

public 
Weapons_Deploy(iWeapon)
{

    new 
id get_pdata_cbase(iWeaponm_pPlayerXO_WEAPONS)
    new 
iId get_pdata_int(iWeaponm_iIdXO_WEAPONS)
    
set_pdata_float(iWeaponm_flNextPrimaryAttack99999.0XO_WEAPONS)
    
set_pdata_float(iWeaponm_flNextSecondaryAttack99999.0XO_WEAPONS)
    
set_pdata_float(idm_flNextAttack99999.0XO_PLAYER)



fysiks 08-01-2011 20:00

Re: Blocking weapon fire, cvar
 
Check the cvar in Weapons_Deploy(). If the cvar is 1 then do the functions, otherwise don't do the functions.

J4CK 08-02-2011 08:59

Re: Blocking weapon fire, cvar
 
thanks!
yeah, but it's works only if u change current weapon (if you do not change weapons you can still attack)

PHP Code:

public Weapons_Deploy(iWeapon

    if( 
get_cvar_num("amx_nodamage") == )
    {
    new 
id get_pdata_cbase(iWeaponm_pPlayerXO_WEAPONS
    new 
iId get_pdata_int(iWeaponm_iIdXO_WEAPONS
    
set_pdata_float(iWeaponm_flNextPrimaryAttack99999.0XO_WEAPONS
    
set_pdata_float(iWeaponm_flNextSecondaryAttack99999.0XO_WEAPONS
    
set_pdata_float(idm_flNextAttack99999.0XO_PLAYER)
    }


it's possible make, when amx_damage 1 (blocks attacks for all players) like this:
PHP Code:

set_pev(idpev_button, (pev(idpev_button) & ~IN_ATTACK) & ~IN_ATTACK2


Exolent[jNr] 08-02-2011 11:29

Re: Blocking weapon fire, cvar
 
Use commands instead of cvars so you know when the value is changed.
Or you can use Cvar Utitilies if you insist on cvars.

Hunter-Digital 08-02-2011 13:08

Re: Blocking weapon fire, cvar
 
Also, don't get cvars like that (get_cvar_num/float/string), use pcvars, you'll need to store the pointers of each cvar got from get_cvar_pointer() then you use that variable in get_pcvar_num/float/string.


All times are GMT -4. The time now is 03:27.

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