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

Removing weapons from certains slots


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 19:09.


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