Raised This Month: $32 Target: $400
 8% 

strip weapon without disturb


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hitD
Junior Member
Join Date: May 2017
Location: Lithuania
Old 05-18-2018 , 08:23   strip weapon without disturb
Reply With Quote #1

Hello,
Im facing one problem,i want to give a player a gun and strip it immediately i have tryed to use ham strip weapon
HTML Code:
stock ham_strip_user_weapon(id, iCswId, iSlot = 0, bool:bSwitchIfActive = true)
{
    new iWeapon;
    if( !iSlot )
    {
        static const iWeaponsSlots[] = {
            -1,
            2, //CSW_P228
            -1,
            1, //CSW_SCOUT
            4, //CSW_HEGRENADE
            1, //CSW_XM1014
            5, //CSW_C4
            1, //CSW_MAC10
            1, //CSW_AUG
            4, //CSW_SMOKEGRENADE
            2, //CSW_ELITE
            2, //CSW_FIVESEVEN
            1, //CSW_UMP45
            1, //CSW_SG550
            1, //CSW_GALIL
            1, //CSW_FAMAS
            2, //CSW_USP
            2, //CSW_GLOCK18
            1, //CSW_AWP
            1, //CSW_MP5NAVY
            1, //CSW_M249
            1, //CSW_M3
            1, //CSW_M4A1
            1, //CSW_TMP
            1, //CSW_G3SG1
            4, //CSW_FLASHBANG
            2, //CSW_DEAGLE
            1, //CSW_SG552
            1, //CSW_AK47
            3, //CSW_KNIFE
            1 //CSW_P90
        }
        iSlot = iWeaponsSlots[iCswId];
        //user_has_weapon(id, iCswId, 0);
    }

    iWeapon = get_pdata_cbase(id, m_rgpPlayerItems_CBasePlayer[iSlot]);

    while( iWeapon > 0 )
    {
        if( get_pdata_int(iWeapon, m_iId, XO_CBASEPLAYERITEM) == iCswId )
        {
            break;
        }
        iWeapon = get_pdata_cbase(iWeapon, m_pNext, XO_CBASEPLAYERITEM);
        user_has_weapon(id, iCswId, 0);
    }
    
    if( iWeapon > 0 )
    {
    	
        if( bSwitchIfActive && get_pdata_cbase(id, m_pActiveItem) == iWeapon )
       {
       
            ExecuteHamB(Ham_Weapon_RetireWeapon, iWeapon);
        }
        
        if( ExecuteHamB(Ham_RemovePlayerItem, id, iWeapon) )
        {
            user_has_weapon(id, iCswId, 0);
            ExecuteHamB(Ham_Item_Kill, iWeapon);
            return 1;
        }
    }
 }
But the problem if a player holds a gun and shooting or doing something and when it would use retireweapon then it would switch to a better gun for example im shooting with pistol and it switch to m4a1 if without retire then it's empty and i thought about something with invlast with engclient. But maybe there is some more efficient way? Thanks.
hitD is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-19-2018 , 10:35   Re: strip weapon without disturb
Reply With Quote #2

Why would you give a weapon and then immediately strip it?

Regarding your second comment, are you trying to make it not switch to the next best weapon in the inventory? What do you want to happen when a weapon is stripped?
__________________
Bugsy is offline
hitD
Junior Member
Join Date: May 2017
Location: Lithuania
Old 05-19-2018 , 11:33   Re: strip weapon without disturb
Reply With Quote #3

Im doing this only for itempickup message for custom sprite when i get item and yes i dont want to switch to the next best weapon in inventory, what i want for example if im shooting with a secondary gun and i have a primary gun in inventory, if i get a random primary gun and strip it then it gonna choose the best gun it means it gonna be a primary gun but i was using a secondary, so i want it to stay to secondary not primary the same problem with knife.
hitD is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-19-2018 , 12:13   Re: strip weapon without disturb
Reply With Quote #4

Did you try removing this from the above?
PHP Code:
        if( bSwitchIfActive && get_pdata_cbase(idm_pActiveItem) == iWeapon )
       {
       
            
ExecuteHamB(Ham_Weapon_RetireWeaponiWeapon);
        } 
Code:
	/**
	 * Description:		There is no more ammo for this gun, so switch to the next best one.
	 * Forward params:	function(this)
	 * Return type:		None.
	 * ExecuteParams:	ExecuteHam(Ham_Weapon_RetireWeapon, this)
	 */
	Ham_Weapon_RetireWeapon,
__________________
Bugsy is offline
hitD
Junior Member
Join Date: May 2017
Location: Lithuania
Old 05-19-2018 , 12:20   Re: strip weapon without disturb
Reply With Quote #5

Yes if i remove this then it would be okay, but then for some reason i cant use then current gun.
hitD is offline
hitD
Junior Member
Join Date: May 2017
Location: Lithuania
Old 05-19-2018 , 16:51   Re: strip weapon without disturb
Reply With Quote #6

Anyway thanks for the help adjusted like i needed with cmd and few offsets. Solved
hitD is offline
Old 05-20-2018, 08:53
hitD
This message has been deleted by hitD. Reason: my bad
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 14:23.


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