Raised This Month: $51 Target: $400
 12% 

[REQ] Plugin with cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 02-07-2010 , 05:24   [REQ] Plugin with cvar
Reply With Quote #1

Hello, i got a plugin, it just disable's awp pickup from ground for not-admins. so i wish to make it with cvar like

amx_awppickup 0 - ENABLE'S PLUGIN
amx_awppickup 1 - DISABLE'S PLUGIN

here is my code:

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#define CanGetAwp(%1)    ( get_user_flags(%1) & ADMIN_LEVEL_H )

new const VERSION[] = "0.0.1"

const MAX_PLAYERS 32

new gmsgTextMsg

new g_iLastTouchedBox[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin("Only Admins AWP"VERSION"ConnorMcLeod")

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)

    
register_touch("weaponbox""player""WeaponBox_Touch")

    
register_menucmd(register_menuid("T_BuyRifle"1), (1<<4), "BuyRifle")
    
register_menucmd(register_menuid("CT_BuyRifle"1), (1<<5), "BuyRifle")

    
gmsgTextMsg get_user_msgid("TextMsg")
}

public 
Player_Spawn_Postid )
{
    
g_iLastTouchedBox[id] = 0
}

public 
WeaponBox_Touch(iWpnBxid)
{
    if( 
is_user_alive(id) && entity_get_int(iWpnBxEV_INT_flags) & FL_ONGROUND )
    {
        const 
XTRA_OFS_WEAPONBOX 4
        
const m_rgpPlayerItems_wpnbx_slot1 35

        
static iWeapon
        iWeapon 
get_pdata_cbase(iWpnBxm_rgpPlayerItems_wpnbx_slot1XTRA_OFS_WEAPONBOX)
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_AWP && !CanGetAwpid ) )
        {
            if( 
g_iLastTouchedBox[id] != iWpnBx )
            {
                if( !
user_has_weapon(idCSW_AWP) )
                {
                    
Message_No_Awp(id)
                }
                
g_iLastTouchedBox[id] = iWpnBx
            
}
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
BuyRifle(id)
{
    if( !
CanGetAwpid ) )
    {
        
Message_No_Awp(id)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_command(id)
{
    static 
szCommand[8]

    if( 
read_argv(0szCommandcharsmax(szCommand)) < && bCheckArgAwp(idszCommand) )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
CS_InternalCommand(id, const szCommand[])
{
    if( 
strlen(szCommand) < && bCheckArgAwp(idszCommand) )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

bool:bCheckArgAwp(id, const szCommand[])
{
    static const 
awp[] = "awp"
    
static const magnum[] = "magnum"

    
if(    !CanGetAwpid )
    &&    ( 
equali(szCommandawp) || equali(szCommandmagnum) )    )
    {
        
Message_No_Awp(id)
        return 
true
    
}
    return 
false
}

Message_No_Awp(id)
{
    const 
HUD_PRINTCENTER    =    4
    
static const szOnlyVIP[] = "AWP tik VIP Å½aidÄ—jams" 

    
message_begin(MSG_ONE_UNRELIABLEgmsgTextMsg, .player=id)
    
write_byteHUD_PRINTCENTER )
    
write_stringszOnlyVIP )
    
message_end()

reinert is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-07-2010 , 10:59   Re: [REQ] Plugin with cvar
Reply With Quote #2

Just pause it in amxmodmenu for now, I'll fix it for you when I get home.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 02-07-2010 , 13:33   Re: [REQ] Plugin with cvar
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#define CanGetAwp(%1)    ( get_user_flags(%1) & ADMIN_LEVEL_H )

new const VERSION[] = "0.0.1"

const MAX_PLAYERS 32

new pCvar_Enabled

new gmsgTextMsg

new g_iLastTouchedBox[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin("Only Admins AWP"VERSION"ConnorMcLeod")

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)
    
    
pCvar_Enabled register_cvar"ap_awppickup""1" )

    
register_touch("weaponbox""player""WeaponBox_Touch")

    
register_menucmd(register_menuid("T_BuyRifle"1), (1<<4), "BuyRifle")
    
register_menucmd(register_menuid("CT_BuyRifle"1), (1<<5), "BuyRifle")

    
gmsgTextMsg get_user_msgid("TextMsg")
}

public 
Player_Spawn_Postid )
{
    if( 
get_pcvar_numpCvar_Enabled == )
    {
        
g_iLastTouchedBox[id] = 0
    
}
}

public 
WeaponBox_Touch(iWpnBxid)
{
    if( 
is_user_alive(id) && entity_get_int(iWpnBxEV_INT_flags) & FL_ONGROUND && get_pcvar_numpCvar_Enabled == ) )
    {
        const 
XTRA_OFS_WEAPONBOX 4
        
const m_rgpPlayerItems_wpnbx_slot1 35

        
static iWeapon
        iWeapon 
get_pdata_cbase(iWpnBxm_rgpPlayerItems_wpnbx_slot1XTRA_OFS_WEAPONBOX)
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_AWP && !CanGetAwpid ) )
        {
            if( 
g_iLastTouchedBox[id] != iWpnBx )
            {
                if( !
user_has_weapon(idCSW_AWP) )
                {
                    
Message_No_Awp(id)
                }
                
g_iLastTouchedBox[id] = iWpnBx
            
}
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

public 
BuyRifle(id)
{
    if( !
CanGetAwpid ) && get_pcvar_numpCvar_Enabled == ) )
    {
        
Message_No_Awp(id)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
client_command(id)
{
    static 
szCommand[8]

    if( 
read_argv(0szCommandcharsmax(szCommand)) < && bCheckArgAwp(idszCommand) && get_pcvar_numpCvar_Enabled == ) )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

public 
CS_InternalCommand(id, const szCommand[])
{
    if( 
strlen(szCommand) < && bCheckArgAwp(idszCommand) && get_pcvar_numpCvar_Enabled == ) )
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

bool:bCheckArgAwp(id, const szCommand[])
{
    if( 
get_pcvar_numpCvar_Enabled == )
    {
        static const 
awp[] = "awp"
        
static const magnum[] = "magnum"

        
if(    !CanGetAwpid )
        &&    ( 
equali(szCommandawp) || equali(szCommandmagnum) )    )
        {
            
Message_No_Awp(id)
            return 
true
        
}
        return 
false
    
}
}

Message_No_Awp(id)
{
    const 
HUD_PRINTCENTER    =    4
    
static const szOnlyVIP[] = "AWP tik VIP Å½aidÄ—jams" 

    
message_begin(MSG_ONE_UNRELIABLEgmsgTextMsg, .player=id)
    
write_byteHUD_PRINTCENTER )
    
write_stringszOnlyVIP )
    
message_end()

__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ 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 08:42.


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