Raised This Month: $62 Target: $400
 15% 

Removing weapons from certains slots


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBumpyScrubby
New Member
Join Date: Jan 2019
Old 01-09-2019 , 13:57   Removing weapons from certains slots
Reply With Quote #1

I was searching this forums for a way to remove weapons from certain slots, for example remove only grenades, pistols, rifles, etc. And i found some old posts and decided to use this method:
https://forums.alliedmods.net/showpo...6&postcount=77

This is my code:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <cstrike>

#tryinclude <cstrike_pdatas> 

#if !defined _cbaseentity_included 
        #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \ 
                
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \ 
                
2. Put it into amxmodx/scripting/include/ folder   
                
3. Compile this plugin locallydetailswiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   
                
4. Install compiled plugindetailswiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing 
#endif 

enum _:hudHide ( <<= 

    
HUD_HIDE_CAL 1
    
HUD_HIDE_FLASH
    
HUD_HIDE_ALL
    
HUD_HIDE_RHA
    
HUD_HIDE_TIMER
    
HUD_HIDE_MONEY
    
HUD_HIDE_CROSS
    
HUD_DRAW_CROSS 


enum _:ammoIndexes 

    
ammo_none
    
ammo_338magnum 1// 30 
    
ammo_762nato// 90 
    
ammo_556natobox// 200 
    
ammo_556nato// 90 
    
ammo_buckshot// 32 
    
ammo_45acp// 100 
    
ammo_57mm// 100 
    
ammo_50ae// 35 
    
ammo_357sig// 52 
    
ammo_9mm// 120 
    
ammo_flashbang// 2 
    
ammo_hegrenade// 1 
    
ammo_smokegrenade// 1 
    
ammo_c4 // 1 



#define Plugin "Starting Weapons"
#define Version "0.1"
#define Author "me"

public plugin_init( ) {
    
register_pluginPluginVersionAuthor )
    
    
RegisterHamHam_Spawn"player""fw_PlayerSpawnPost")
}

public 
fw_PlayerSpawnPostid ) {
    if( 
is_user_aliveid ) ) {
        
RemovePlayerSlotsItemid)
        
RemovePlayerSlotsItemid)
        
RemovePlayerSlotsItemid)
        
        switch( 
cs_get_user_teamid ) ) {
            case 
CS_TEAM_T: {
                
give_itemid"weapon_ak47" )
                
cs_set_user_bpammoidCSW_AK4790 )
            }
            case 
CS_TEAM_CT: {
                
give_itemid"weapon_m4a1" )
                
cs_set_user_bpammoidCSW_M4A190 )
                
                
cs_set_user_defuseid)
            }
        }
        
        
give_itemid"weapon_deagle")
        
cs_set_user_bpammoidCSW_DEAGLE35 )
        
        
give_itemid"weapon_hegrenade" )
        
give_itemid"weapon_flashbang" )
        
cs_set_user_bpammoidCSW_FLASHBANG)
    }
}

RemovePlayerSlotsItem(idiSlot

    if( !(
<= iSlot <= 5) ) 
    { 
        return 

    


    new 
iActiveItem get_pdata_cbase(idm_pActiveItem

    if( 
iSlot == && get_pdata_bool(idm_bHasShield) ) 
    { 
        
RemoveUserShieldid 
        if( 
<= ExecuteHamB(Ham_Item_ItemSlotiActiveItem) <= 
        { 
            
ExecuteHamB(Ham_Item_DeployiActiveItem
        } 
        return 

    


    new 
iItemiWeapons pev(idpev_weapons
    while( ( 
iItem get_pdata_cbase(idm_rgpPlayerItems_CBasePlayer[iSlot]) ) > 
    { 
        if( 
iItem == iActiveItem 
        { 
            
ExecuteHamB(Ham_Weapon_RetireWeaponiItem// only to call GetNextBestWeapon so player still have a weapon in hands. 
        

        
iWeapons &= ~get_pdata_int(iItemm_iIdXO_CBASEPLAYERITEM
        
ExecuteHamB(Ham_RemovePlayerItemidiItem
        
ExecuteHamB(Ham_Item_KilliItem
    } 
    
set_pev(idpev_weaponsiWeapons

    if( 
iSlot == 
    { 
        
set_pdata_int(idm_fHasPrimary0
    } 
    else if( 
iSlot == 
    { 
        
set_pdata_int(idm_rgAmmo_CBasePlayer[ammo_flashbang], 0
        
set_pdata_int(idm_rgAmmo_CBasePlayer[ammo_hegrenade], 0
        
set_pdata_int(idm_rgAmmo_CBasePlayer[ammo_smokegrenade], 0
    } 
    return 



RemoveUserShieldid 

    if ( 
get_pdata_bool(idm_bHasShield) ) 
    { 
        
set_pdata_bool(idm_bHasShieldfalse
        
set_pdata_int(idm_fHasPrimary0
        
set_pdata_bool(idm_bUsesShieldfalse
        
set_pev(idpev_gamestate1
        new 
iHideHUD get_pdata_int(idm_iHideHUD
        if( 
iHideHUD HUD_HIDE_CROSS 
        { 
            
set_pdata_int(idm_iHideHUDiHideHUD & ~HUD_HIDE_CROSS
        } 
        return 

    

    return 


The problem is... if i have USP it does not removes it entirely. When i choose weapon slot 2, i have Deagle and... USP, but i cannot equip the USP if i drop the deagle. After i drop the deagle the slot looks empty, after i pick it up again i have two icons, one for the deagle and one for the USP.

Do you know a better and updated way to remove weapons from a certain slot?

I'm running AMXMODX 1.8.3 on my test server...
TheBumpyScrubby is offline
thEsp
Senior Member
Join Date: Aug 2017
Location: Gjilan, Albania
Old 01-11-2019 , 11:35   Re: Removing weapons from certains slots
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=308166
Use this example, store weapons in arraylist and strip user's weapons. Then check if arraylist contains x weapon, if yes then you should ignore that and continue with other weps.
__________________
Hobby: Gaming, Coding, Rap (TheBloodyAlboz, E7, Tram 11, P.I.N.T, Death Row, Bolesna Braca)
__________________
YouTube channel
GitHub
thEsp is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 01-11-2019 , 11:47   Re: Removing weapons from certains slots
Reply With Quote #3

For me it works changing
Quote:
set_pev(id, pev_weapons, iWeapons)
with
Quote:
user_has_weapon(id, weapon_csw, 0)
You need:
Quote:
weapon_csw = get_pdata_int(iItem, m_iId, XO_CBASEPLAYERITEM)
__________________
My English is A0
E1_531G is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-11-2019 , 13:36   Re: Removing weapons from certains slots
Reply With Quote #4

https://github.com/s1lentq/reapi/blo..._misc.cpp#L869
__________________
Accepting private $$$ plugins requests.

@Steam: crazy770
@Discord: CrazY.#5317

Website | Channel

CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-11-2019 , 18:37   Re: Removing weapons from certains slots
Reply With Quote #5

Change this
PHP Code:
iWeapons &= ~get_pdata_int(iItemm_iIdXO_CBASEPLAYERITEM
to this
PHP Code:
iWeapons &= ~( << get_pdata_int(iItemm_iIdXO_CBASEPLAYERITEM) ) 
and you should be good.

And use this for 1.9.0 support:
PHP Code:
#if AMXX_VERSION_NUM == 190
#include <cstrike_pdatas/cbaseplayer_offsets>
#include <cstrike_pdatas/cbaseentity_offsets>
#include <cstrike_pdatas/cbaseplayerweapon_offsets>
#else
#tryinclude <cstrike_pdatas> 

#if !defined _cbaseentity_included 
        #assert Cstrike Pdatas and Offsets library required! Read the below instructions:   \ 
                
1. Download it at forums.alliedmods.net/showpost.php?p=1712101#post1712101   \ 
                
2. Put it into amxmodx/scripting/include/ folder   
                
3. Compile this plugin locallydetailswiki.amxmodx.org/index.php/Compiling_Plugins_%28AMX_Mod_X%29   
                
4. Install compiled plugindetailswiki.amxmodx.org/index.php/Configuring_AMX_Mod_X#Installing 
#endif 
#endif 
__________________

Last edited by Bugsy; 01-11-2019 at 18:38.
Bugsy is offline
Reply


Thread Tools
Display Modes

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 06:43.


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