Raised This Month: $ Target: $400
 0% 

Blocking weapon fire, cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
J4CK
Member
Join Date: Dec 2008
Location: India
Old 08-01-2011 , 16:10   Blocking weapon fire, cvar
Reply With Quote #1

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)

J4CK is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-01-2011 , 20:00   Re: Blocking weapon fire, cvar
Reply With Quote #2

Check the cvar in Weapons_Deploy(). If the cvar is 1 then do the functions, otherwise don't do the functions.
__________________
fysiks is offline
J4CK
Member
Join Date: Dec 2008
Location: India
Old 08-02-2011 , 08:59   Re: Blocking weapon fire, cvar
Reply With Quote #3

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
J4CK is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-02-2011 , 11:29   Re: Blocking weapon fire, cvar
Reply With Quote #4

Use commands instead of cvars so you know when the value is changed.
Or you can use Cvar Utitilies if you insist on cvars.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-02-2011 , 13:08   Re: Blocking weapon fire, cvar
Reply With Quote #5

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.
__________________
Hunter-Digital 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 03:27.


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