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

GivePlayerItem and entity index?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-22-2011 , 16:39   GivePlayerItem and entity index?
Reply With Quote #1

I've been looking into how to temporarily remove a players weapon and then give it back in TF2.

Unfortunately, while GetPlayerWeaponSlot and RemovePlayerItem return and take entity indexes respectively, GivePlayerItem takes an item class name and subtype (which is important in TF2, as all miniguns are the same item class name, for instance).

Is there a version of GivePlayerItem that takes an entity index, or is there some way to turn that into a class name and subtype without having to store the CBaseWeapon entity index of every item in my plugin?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Pawn 3-pg
Senior Member
Join Date: Jul 2009
Old 06-22-2011 , 17:02   Re: GivePlayerItem and entity index?
Reply With Quote #2

EquipPlayerWeapon should work with the entity returned by GetPlayerWeaponSlot.
Pawn 3-pg is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 06-22-2011 , 17:06   Re: GivePlayerItem and entity index?
Reply With Quote #3

I think the issue lies in the fact that if you want to remove a weapon, you remove its entity. But if it's removed, ofcourse there won't be an entity to give back.

EquipPlayerWeapon just switches to an already created weapon, I believe.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.

Last edited by Monkeys; 06-22-2011 at 17:10.
Monkeys is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-22-2011 , 17:06   Re: GivePlayerItem and entity index?
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
GivePlayerItem takes an item class name and subtype (which is important in TF2, as all miniguns are the same item class name, for instance).
That's not what the subtype is used for, TF2 doesn't have weapon subtypes. You need to use the GiveNamedItem native in the TF2Items extension if you want to specify an item definition index.

As for your request, GiveNamedItem (GivePlayerItem) is what /creates/ the weapon entity, hence why it returns an entity index. As was said above, just equip it again (don't destroy the entity).
__________________
asherkin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 06-22-2011 , 18:19   Re: GivePlayerItem and entity index?
Reply With Quote #5

Quote:
Originally Posted by Pawn 3-pg View Post
EquipPlayerWeapon should work with the entity returned by GetPlayerWeaponSlot.
Oh, I was under the impression that force-changed the players current weapon to one they already had. Whoops.
__________________
Not currently working on SourceMod plugin development.
Powerlord 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 21:35.


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