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

Plugin small modification


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deviss
Member
Join Date: Feb 2011
Old 02-10-2016 , 08:56   Plugin small modification
Reply With Quote #1

Hello

I have the following plugin to restrict awp only (scout is not restricted) for access flag h members, however I would also like to add scout weapon too so it restricts both awp and scout weapons. Could anyone help me with the change?

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

#define VERSION "1.0.0" 

#define MAX_PLAYERS 32 

#define XO_WEAPONBOX    4 
#define m_rgpPlayerItems_wpnbx_slot1 35 

new g_iLastTouchedBox[MAX_PLAYERS+1

public 
plugin_init() 

    
register_plugin("Awp VIP"VERSION"ConnorMcLeod"

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1
    
RegisterHam(Ham_Touch"weaponbox""WeaponBox_Touch"

    
register_menucmd(register_menuid("T_BuyRifle"1), MENU_KEY_5"BuyAwp"
    
register_menucmd(register_menuid("CT_BuyRifle"1), MENU_KEY_6"BuyAwp"


public 
client_putinserver(id

    
g_iLastTouchedBox[id] = 


public 
Player_Spawn_Postid 

    
g_iLastTouchedBox[id] = 


public 
WeaponBox_Touch(iWpnBxid

    if( 
is_user_alive(id) && pev(iWpnBxpev_flags) & FL_ONGROUND 
    { 
        new 
iWeapon get_pdata_cbase(iWpnBxm_rgpPlayerItems_wpnbx_slot1XO_WEAPONBOX
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_AWP && !CanHaveAwpid ) ) 
        { 
            if( 
g_iLastTouchedBox[id] != iWpnBx 
            { 
                if( !
user_has_weapon(idCSW_SCOUT) ) 
                { 
                    
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
                } 
                
g_iLastTouchedBox[id] = iWpnBx 
            

            return 
HAM_SUPERCEDE 
        

    } 
    return 
HAM_IGNORED 


public 
BuyAwp(id

    if( !
CanHaveAwpid ) ) 
    { 
        
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
client_command(id

    static 
szCommand[8

    if( 
read_argv(0szCommandcharsmax(szCommand)) < 
    { 
        return 
CheckArgAwp(idszCommand
    } 
    return 
PLUGIN_CONTINUE 


public 
CS_InternalCommand(id, const szCommand[]) 

    return 
CheckArgAwp(idszCommand


CheckArgAwp(id, const szCommand[]) 

    static const 
awp[] = "awp" 
    
static const magnum[] = "magnum" 

    
if(    !CanHaveAwpid 
    &&    ( 
equali(szCommandawp) || equali(szCommandmagnum) )    ) 
    { 
        
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


bool:CanHaveAwpid 

    return !!(
get_user_flags(id) & ADMIN_LEVEL_H

Thanks in advance

Last edited by deviss; 02-10-2016 at 08:57.
deviss is offline
deviss
Member
Join Date: Feb 2011
Old 02-13-2016 , 13:06   Re: Plugin small modification
Reply With Quote #2

Anyone can help?
deviss is offline
JoaoVieira
Senior Member
Join Date: May 2013
Location: Portugal
Old 02-13-2016 , 14:57   Re: Plugin small modification
Reply With Quote #3

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

#define VERSION "1.0.0" 

#define MAX_PLAYERS 32 

#define XO_WEAPONBOX    4 
#define m_rgpPlayerItems_wpnbx_slot1 35 

new g_iLastTouchedBox[MAX_PLAYERS+1

public 
plugin_init() 

    
register_plugin("Awp VIP"VERSION"ConnorMcLeod"

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1
    
RegisterHam(Ham_Touch"weaponbox""WeaponBox_Touch"

    
register_menucmd(register_menuid("T_BuyRifle"1), MENU_KEY_5"BuyAwp"
    
register_menucmd(register_menuid("CT_BuyRifle"1), MENU_KEY_6"BuyAwp"


public 
client_putinserver(id

    
g_iLastTouchedBox[id] = 


public 
Player_Spawn_Postid 

    
g_iLastTouchedBox[id] = 


public 
WeaponBox_Touch(iWpnBxid

    if( 
is_user_alive(id) && pev(iWpnBxpev_flags) & FL_ONGROUND 
    { 
        new 
iWeapon get_pdata_cbase(iWpnBxm_rgpPlayerItems_wpnbx_slot1XO_WEAPONBOX
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_SCOUT,CSW_AWP && !CanHaveAwpid ) ) 
        { 
            if( 
g_iLastTouchedBox[id] != iWpnBx 
            { 
                if( !
user_has_weapon(idCSW_SCOUT) ) 
                { 
                    
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
                } 
                
g_iLastTouchedBox[id] = iWpnBx 
            

            return 
HAM_SUPERCEDE 
        

    } 
    return 
HAM_IGNORED 


public 
BuyAwp(id

    if( !
CanHaveAwpid ) ) 
    { 
        
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
client_command(id

    static 
szCommand[8

    if( 
read_argv(0szCommandcharsmax(szCommand)) < 
    { 
        return 
CheckArgAwp(idszCommand
    } 
    return 
PLUGIN_CONTINUE 


public 
CS_InternalCommand(id, const szCommand[]) 

    return 
CheckArgAwp(idszCommand


CheckArgAwp(id, const szCommand[]) 

    static const 
awp[] = "awp" 
    
static const magnum[] = "magnum" 

    
if(    !CanHaveAwpid 
    &&    ( 
equali(szCommandawp) || equali(szCommandmagnum) )    ) 
    { 
        
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


bool:CanHaveAwpid 

    return !!(
get_user_flags(id) & ADMIN_LEVEL_H

and dont bump soo fast.

Last edited by JoaoVieira; 02-13-2016 at 14:59.
JoaoVieira is offline
counter1strike6
Senior Member
Join Date: Sep 2014
Location: morocco
Old 02-13-2016 , 15:43   Re: Plugin small modification
Reply With Quote #4

you must check clients command

like this block awp + scout
PHP Code:

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

#define VERSION "1.0.0" 

#define MAX_PLAYERS 32 

#define XO_WEAPONBOX    4 
#define m_rgpPlayerItems_wpnbx_slot1 35 

new g_iLastTouchedBox[MAX_PLAYERS+1

public 
plugin_init() 

    
register_plugin("Awp VIP"VERSION"ConnorMcLeod"

    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1
    
RegisterHam(Ham_Touch"weaponbox""WeaponBox_Touch"

    
register_menucmd(register_menuid("T_BuyRifle"1), MENU_KEY_5"BuyAwp"
    
register_menucmd(register_menuid("CT_BuyRifle"1), MENU_KEY_6"BuyAwp"


public 
client_putinserver(id

    
g_iLastTouchedBox[id] = 


public 
Player_Spawn_Postid 

    
g_iLastTouchedBox[id] = 


public 
WeaponBox_Touch(iWpnBxid

    if( 
is_user_alive(id) && pev(iWpnBxpev_flags) & FL_ONGROUND 
    { 
        new 
iWeapon get_pdata_cbase(iWpnBxm_rgpPlayerItems_wpnbx_slot1XO_WEAPONBOX
        if( 
iWeapon && cs_get_weapon_id(iWeapon) == CSW_AWP || cs_get_weapon_id(iWeapon) == CSW_SCOUT && !CanHaveAwpid ) ) 
        { 
            if( 
g_iLastTouchedBox[id] != iWpnBx 
            { 
                
                    
client_print(idprint_center"you can not pick up this weapon"

                
g_iLastTouchedBox[id] = iWpnBx 
            

            return 
HAM_SUPERCEDE 
        

    
    } 
    return 
HAM_IGNORED 


public 
BuyAwp(id

    if( !
CanHaveAwpid ) ) 
    { 
        
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


public 
client_command(id

    static 
szCommand[8

    if( 
read_argv(0szCommandcharsmax(szCommand)) < 
    { 
        return 
CheckArgAwp(idszCommand
    } 
    return 
PLUGIN_CONTINUE 


public 
CS_InternalCommand(id, const szCommand[]) 

    return 
CheckArgAwp(idszCommand


CheckArgAwp(id, const szCommand[]) 

    static const 
scout[] = "scout" 
    
static const awp[] = "awp" 
    
static const magnum[] = "magnum" 

    
if(    !CanHaveAwpid 
    &&    ( 
equali(szCommandawp) || equali(szCommandmagnum)  || equali(szCommandscout)   ) ) 
    { 
        
client_print(idprint_center"#Cstrike_TitlesTXT_Cannot_Buy_This"
        return 
PLUGIN_HANDLED 
    

    return 
PLUGIN_CONTINUE 


bool:CanHaveAwpid 

    return !!(
get_user_flags(id) & ADMIN_LEVEL_H

counter1strike6 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 04:04.


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