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

(Request) Is still impossible to pick up more than 1 weapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 04-29-2022 , 06:46   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #11

Quote:
Originally Posted by Bugsy View Post
Some credit to Arkshine for his weapon from weaponbox to player code. Not thoroughly tested, and not sure off the top of my head what the slot maximums are. I tested only up to 3 in slots 1 and 2.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <engine>
#include <hamsandwich>

new const Version[] = "0.1";

const 
PrimaryWeapons = ( << CSW_SCOUT ) | ( << CSW_XM1014 ) | ( << CSW_MAC10 ) |( << CSW_AUG ) | 
            ( 
<< CSW_UMP45 ) | ( << CSW_SG550 ) | ( << CSW_GALIL ) | ( << CSW_FAMAS ) | 
            ( 
<< CSW_AWP ) | ( << CSW_MP5NAVY ) | ( << CSW_M249 ) | ( << CSW_M3 ) | 
            ( 
<< CSW_M4A1 ) | ( << CSW_TMP ) | ( << CSW_G3SG1 ) | ( << CSW_SG552 ) | 
            ( 
<< CSW_AK47 ) | ( << CSW_P90 );

const 
SecondaryWeapons =  ( << CSW_P228 ) | ( << CSW_ELITE ) | ( << CSW_FIVESEVEN ) | ( << CSW_USP ) | 
              ( 
<< CSW_GLOCK18 ) | ( << CSW_DEAGLE );

enum WeaponSlots
{
    
Slot1 1,
    
Slot2
}
new 
g_pMaxWeaponsWeaponSlots ];

public 
plugin_init() 
{
    
register_plugin"Multiple Weapons" Version "bugsy" );
   
    
register_touch"weaponbox" "player" "TouchWeaponbox" );
    
    
g_pMaxWeaponsSlot1 ] = register_cvar"mw_maxslot1" "2" );
    
g_pMaxWeaponsSlot2 ] = register_cvar"mw_maxslot2" "2" );
}

public 
TouchWeaponboxiEntity id )
{    
    if ( !( 
peviEntity pev_flags ) & FL_ONGROUND ) ) 
        return 
PLUGIN_CONTINUE;
        
    new 
iWeaponIndex WeaponSlots:iSlot iWeaponEntID;
    new const 
m_rgpPlayerItems] = { 34 35 , ... };
    
    for ( 
iSlot Slot1 iSlot <= Slot2 iSlot++ )
    {
        if ( ( 
iWeaponEntID get_pdata_cbaseiEntity m_rgpPlayerItems] + _:iSlot ) ) > )
        {
            break;
        }
    }

    if ( 
iWeaponEntID )
    {
        
iWeaponIndex cs_get_weapon_idiWeaponEntID );

        if ( ( 
CSW_P228 <= iWeaponIndex <= CSW_P90 ) && ( iWeaponIndex != CSW_C4 ) && !user_has_weaponid iWeaponIndex ) )
        {
            
iSlot SlotByIDiWeaponIndex );
            
            if ( 
iSlot && GetCountBySlotid iSlot ) < get_pcvar_numg_pMaxWeaponsiSlot ] ) )
            {
                if ( 
ExecuteHamHam_AddPlayerItem id iWeaponEntID ) )
                {
                    
ExecuteHamHam_Item_AttachToPlayer iWeaponEntID id );
                    
emit_soundid CHAN_ITEM "items/gunpickup2.wav" VOL_NORM ATTN_NORM PITCH_NORM );
                    
set_peviEntity pev_flagspeviEntity pev_flags ) | FL_KILLME );
                }
            }
            
            return 
PLUGIN_HANDLED;
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

WeaponSlots:SlotByIDiWeaponID )
{
    return ( 
PrimaryWeapons & ( << iWeaponID ) ) ? Slot1 : ( SecondaryWeapons & ( << iWeaponID ) ) ? Slot2 WeaponSlots:0;


GetCountBySlotid WeaponSlots:iSlot )
{    
    new 
iWeapons iEntity;
    new const 
m_rgpPlayerItems] = { 367 368 369 370 371 372 };
    const 
m_pNext 42;
    
    
iEntity get_pdata_cbaseid m_rgpPlayerItems_:iSlot ] );

    while ( 
iEntity )
    {
        
iWeapons++;
        
iEntity get_pdata_cbaseiEntity m_pNext );
    }
    
    return 
iWeapons;

everything running smoothly at least for now. thanks! this has been a great addition!
Ark_Procession is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 04-30-2022 , 10:21   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #12

Terrible, terrible bug or maybe engine limitation:

When you kill someone and he drops his weapon & you already have one primary equipped, then the one you pick up has no bullets, sometimes. Other time it has bullets on weapon but not on magazine.

Kinda defeats the purpose of using the plugin!

I know this unbelieveable annoying limitation that cs 1.6 vanilla has:

if i have a weapon lets say an Ak-47 fully loaded but then i drop it an a teammate grabs it, the magazine stays with the original player and the weapon will have only 30 bullets and no magazine.

I think this is related

i am not asking to fix such annoying stuff, but at least if you can tell me if there is a workaround i could start looking for this.
Ark_Procession is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2022 , 10:30   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #13

This isn't a bug, it's how the game works... you are picking up someone else's gun that may be out of ammo. When the weapon is picked, you expect to get a full clip and backpack ammo?
__________________
Bugsy is online now
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 04-30-2022 , 13:50   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #14

Quote:
Originally Posted by Bugsy View Post
This isn't a bug, it's how the game works... you are picking up someone else's gun that may be out of ammo. When the weapon is picked, you expect to get a full clip and backpack ammo?
as i said, probably how the game works, no i don't expect bullets to magically appear.

the round starts, lets say in a vanilla situation a bot buys a weapon, and then he gets killed without shooting the gun at all, you expect to have a full weapon right? well you actually receive a fully loaded weapon with a full clip and backpack ammo.

But if i use this plugin, then if the same situation happens, the weapon the bot drops at death only has full clip but no backpack ammo.

Re reading your comment you are suggesting the bullets to appear as a workaround like a modification to the plugin? if the only solution is that then yes.. if the real ammo can't be tracked then i prefer that to nothing honestly.

But i thought there might be still hope since the original behaviour when an enemy drops the weapon is to get the current ammo and backpack ammo.

Last edited by Ark_Procession; 04-30-2022 at 14:01.
Ark_Procession is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2022 , 13:55   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #15

Ok, well that's an unspecified requirement, but easy to do. I'm making beer ATM, I'll add that later
__________________
Bugsy is online now
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 04-30-2022 , 15:36   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #16

Quote:
Originally Posted by Bugsy View Post
Ok, well that's an unspecified requirement, but easy to do. I'm making beer ATM, I'll add that later
lol great! thanks will come back later

PS: if you can force the game to make dropped weapons remember their backpack ammo, awesome.. otherwise the full amo for the dropped weapon.. but the risk that have is the exploit of using the weapon and then dropping it only to pick it up again and use it again... if that can be avoided then great!

Last edited by Ark_Procession; 04-30-2022 at 15:37.
Ark_Procession is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-30-2022 , 20:35   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #17

Above code is updated. It will remember the exact amount of backpack ammo from the player who dropped the weapon.
__________________
Bugsy is online now
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 05-01-2022 , 00:25   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #18

Quote:
Originally Posted by Bugsy View Post
Above code is updated. It will remember the exact amount of backpack ammo from the player who dropped the weapon.
thank you a million!

we are almost there!:

BUG 1:
Apparently bots are being able to carry a shield and a weapon, leading to a "hilarious" bug of them being invincible!, i dont like the idea of a player being able to do this.
How to recreate:
1) Be a CT
2) Buy a Shield
3) Buy a m4a1, see the shield drop, now go over it and you will pick it up, it will be invisible and you will be able to shoot your primary weapon, but not get shot.
Can this be fixed?

BUG 2:
When a player has two weapons and he gets killed, only a random weapon of the two gets dropped.
can you make it so it drops both primary and both secondary?
I know that if you have a secondary weapon, but you are currently using the primary, only the primary gets dropped when you die. so what i want is:

- If i am equipping a primary weapon, drop the two primary weapons i was carrying
- If i am equipping a secondary weapon, drop the two secondary weapons i was carrying
- If i can drop both secondary and primary, then that is best!

Bonus:
- Possibillity of not dropping the 2nd weapon you buy in a buyzone:
For eg: If you are just starting a map and have the money to buy an ak-47, and then a AWP, the awp gets automatically droppes instead of going to the 2nd primary slot.
(happens with bot primary and secondary weapons)

Last edited by Ark_Procession; 05-02-2022 at 00:45.
Ark_Procession is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 05-05-2022 , 13:27   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #19

Quote:
Originally Posted by Bugsy View Post
Above code is updated. It will remember the exact amount of backpack ammo from the player who dropped the weapon.
Let me know if the bugs i presented or the required changes are too much of a hassle or worth working on.
Ark_Procession is offline
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 05-11-2022 , 08:19   Re: (Request) Is still impossible to pick up more than 1 weapon?
Reply With Quote #20

Quote:
Originally Posted by Bugsy View Post
Some credit to Arkshine for his weapon from weaponbox to player code. Not thoroughly tested, and not sure off the top of my head what the slot maximums are. I tested only up to 3 in slots 1 and 2.

Edit: Dropped weapons now come equipped with backpack ammo from player who dropped weapon.
PHP Code:

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

new const Version[] = "0.2";

enum WeaponSlots
{
    
Slot1 1,
    
Slot2
}
new 
g_pMaxWeaponsWeaponSlots ];

public 
plugin_init() 
{
    
register_plugin"Multiple Weapons" Version "bugsy" );
   
    
register_touch"weaponbox" "player" "TouchWeaponbox" );
    
register_forwardFM_SetModel "SetModel" );
    
    
g_pMaxWeaponsSlot1 ] = register_cvar"mw_maxslot1" "2" );
    
g_pMaxWeaponsSlot2 ] = register_cvar"mw_maxslot2" "2" );
}

public 
SetModeliEntity , const szModel[] )
{
    new 
szClassname32 ] , iWeaponEntID;
    
    
peviEntity pev_classname szClassname charsmaxszClassname ) );
    
    if ( 
equal szClassname "weaponbox" ) )
    {
        if ( 
pev_valid( ( iWeaponEntID GetWeaponEntityFromWeaponboxiEntity ) ) ) )
        {
            
set_peviEntity pev_iuser2 cs_get_user_bpammopeviEntity pev_owner ) , cs_get_weapon_idiWeaponEntID ) ) );
        }
    }


public 
TouchWeaponboxiEntity id )
{    
    if ( !( 
peviEntity pev_flags ) & FL_ONGROUND ) ) 
        return 
PLUGIN_CONTINUE;
        
    new 
iWeaponIndex WeaponSlots:iSlot iWeaponEntID;

    if ( ( 
iWeaponEntID GetWeaponEntityFromWeaponboxiEntity ) ) > )
    {
        
iWeaponIndex cs_get_weapon_idiWeaponEntID );

        if ( ( 
CSW_P228 <= iWeaponIndex <= CSW_P90 ) && ( iWeaponIndex != CSW_C4 ) && !user_has_weaponid iWeaponIndex ) )
        {
            
iSlot WeaponSlots:ExecuteHamHam_Item_ItemSlot iWeaponEntID );

            if ( 
GetWeaponCountBySlotid iSlot ) < get_pcvar_numg_pMaxWeaponsiSlot ] ) )
            {
                if ( 
ExecuteHamHam_AddPlayerItem id iWeaponEntID ) )
                {
                    
ExecuteHamHam_Item_AttachToPlayer iWeaponEntID id );
                    
cs_set_user_bpammoid iWeaponIndex peviEntity pev_iuser2 ) );
                    
emit_soundid CHAN_ITEM "items/gunpickup2.wav" VOL_NORM ATTN_NORM PITCH_NORM );
                    
set_peviEntity pev_flagspeviEntity pev_flags ) | FL_KILLME );
                }
            }
            
            return 
PLUGIN_HANDLED;
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

GetWeaponCountBySlotid WeaponSlots:iSlot )
{    
    new 
iWeapons iEntity;
    new const 
m_rgpPlayerItems_Player] = { 367 368 369 370 371 372 };
    const 
m_pNext 42;
    
    
iEntity get_pdata_cbaseid m_rgpPlayerItems_Player_:iSlot ] );

    while ( 
iEntity )
    {
        
iWeapons++;
        
iEntity get_pdata_cbaseiEntity m_pNext );
    }
    
    return 
iWeapons;
}

GetWeaponEntityFromWeaponboxiWeaponBox )
{
    new const 
m_rgpPlayerItems_Weaponbox] = { 34 35 , ... };
    new 
iWeaponEntID;

    for ( new 
WeaponSlots:iSlot Slot1 iSlot <= Slot2 iSlot++ )
    {
        if ( ( 
iWeaponEntID get_pdata_cbaseiWeaponBox m_rgpPlayerItems_Weaponbox] + _:iSlot ) ) > )
            break;
    }    
    
    return ( 
iWeaponEntID ) ? iWeaponEntID 0;

Code:
//// Weap_Pickup.sma
//
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Weap_Pickup.sma(35) : error 017: undefined symbol "GetWeaponEntityFromWeaponbox"
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Weap_Pickup.sma(49) : error 017: undefined symbol "GetWeaponEntityFromWeaponbox"
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Weap_Pickup.sma(57) : error 017: undefined symbol "GetWeaponCountBySlot"
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Weap_Pickup.sma(69) : error 030: compound statement not closed at the end of file
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Weap_Pickup.sma(69) : error 030: compound statement not closed at the end of file
// C:\Program Files (x86)\Steam\steamapps\common\Half-Life\czero\addons\amxmodx\scripting\Weap_Pickup.sma(69) : warning 209: function "TouchWeaponbox" should return a value
//
// 5 Errors.
// Could not locate output file compiled\Weap_Pickup.amx (compile failed).
//
// Compilation Time: 0,75 sec
// ----------------------------------------
SoulWeaver16 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:33.


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