View Full Version : Only Allowing One weapon in each weapon slot
05-24-2007, 05:42 AM
Hey, i tried looking for the player weapon pickup event, but cant find it anywhere. Is there any way to only allow one weapon per slot (Like CSS where you have to drop your current one to pick it up). Just all the weapons i currently have look weird in the weapon slot list because there are usually huge gaps between one and the other.
05-24-2007, 06:28 AM
Just change the code so it doesn't have gaps between slots. Not on main comp atm but it isint hard to do.
I have also done what ya said above as well and its a bit more involved but still do-able.
05-24-2007, 07:11 AM
Lodle, you can edit your last post, and click Delete :P
Yeh, i will have another look when ive sorted out the error with Ironsights..
05-24-2007, 08:33 AM
Ah i was looking for that before. Thxs.
I have done it and all it takes is one or two code changes. The problem is finding where it does it in the mess of code for weapon selection.
05-24-2007, 10:38 AM
Hmm... Do you know roughly where it would be? I dont actually know where to start :S
05-24-2007, 04:07 PM
hud_weaponselection.cpp and i guess it would be in CHudWeaponSelection::Paint()
05-26-2007, 05:41 PM
I've looked in files for the weapon pickup event (Where it checks if the player already has one), but i lost the file, and i can't find it. Any ideas which file it's in? I've looked in all the weapon base classes (hl2mphlcombatweapon, etc), can't see it :S...
Also, how would i drop weapons? :D
Still wondering about the weapon pickup event and only 1 weapon per slot for specific slots -- Think Counter-Strike -- Nades go in 4, you have 3 types :P
Weapon dropping using the Weapon->Drop() function works, but then you switch to another weapon and it crashes in datacache.dll... i think maybe i need to create a new weapon entity instead? I dunno :(
CON_COMMAND(drop,"Drops your current weapon...")
CBaseCombatCharacter *pOwner = UTIL_GetCommandClient();
if( !pOwner->GetActiveWeapon() )
if( pOwner->GetActiveWeapon()->GetSlot() == 0 )
pOwner->SwitchToNextBestWeapon( pOwner->GetActiveWeapon() );
05-27-2007, 11:15 AM
Also, im still having problems with my PlayerClass saving between client/server (Check the thread , its in these forums : http://forums.steampowered.com/forums/showthread.php?t=562943) .. Once these changes are done, and my teams are working my mod should be brilliant for my clan :P
05-28-2007, 03:25 PM
Anyone know? :(
06-06-2007, 07:21 PM
BumpWeapon() in hl2mp_player.cpp is where it determines whether a player should pick up a weapon (if you're using the HL2MP SDK).
for ( int i = 0; i < WeaponCount(); i++ )
CBaseCombatWeapon *pSearch = GetWeapon( i );
if ( pSearch && pSearch->GetSlot() == pWeapon->GetSlot() )
That will prevent the player from picking a weapon up if he already has one that uses the same slot.
06-06-2007, 10:12 PM
Way 1: download the plan of attack source code and run a search for GetSlot
Way 2: if you want only certain groups of weapons to be used in a slot you could set them to the same bucket position.
06-06-2007, 10:14 PM
There is a very easy way to do this which I can't believe someone hasn't pointed out.
In HL2_Player.cpp a few lines below the Includes, there is
// This switches between the single primary weapon, and multiple weapons with buckets approach (jdw)
It requires a bit of tweaking to work properly, but if you set that define to 1 then most of the work is done for you. Then just look where it checks that def, and the associated code to add your own features
06-07-2007, 02:44 AM
I will check that out when i redo the code for my mod, my vgui isnt working any more (It crashes when i click a button)...
If it works... sweeeeet. Also, when i drop a weapon, the game will lockup when i select another weapon (Holster event on the old weapon)..... Thats also very annoying.
03-17-2010, 12:23 PM
Wow man whats the chance of this question: blog.jailbreaksource.com has a full tutorial in the programming section. I got it to work in my mod as of March 2010. So lemme know what errors and stuff you get if you got any. Even includes a new HUD element.
03-17-2010, 01:30 PM
Nice job digging up a 4 year old thread
03-17-2010, 01:32 PM
Lol Thanks I am suprised you havn't found it. You are in cahuts with JB right? I mean this is a useful site so I wanted to post some stuff uip here.
03-17-2010, 01:37 PM
Haven't found what.
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.