Raised This Month: $319 Target: $400
 79%   Almost there!

CEconItemView doesn't get initialised for custom weapons

Post New Thread Reply   
Thread Tools Display Modes
Author Message
Veteran Member
Join Date: Nov 2012
Old 06-06-2020 , 11:07   CEconItemView doesn't get initialised for custom weapons
Reply With Quote #1

I'm trying to create a custom weapon entity based on weapon_sg556 in CSGO.
I hooked CreateEntityByName function and replace my custom classname "weapon_custom" to "weapon_sg556" in the function parameters.

After the weapon is spawned, players can't pick it up. I checked the sendprops and found that m_bInitialized is false, for normal weapon_sg556 that value false in postcreate and is true in prespawn hook.

I checked the source code and found that this function should be called before spawn to set some parameters and m_bInitialized to true:
void CEconItemView::Init( int iDefIndex, int iQuality, int iLevel, uint32 iAccountID )
but for my custom weapon it newer happens, whichever way I try to create it: via smx, give command or stripper.
The engine somehow knows that the original classname is another, not weapon_sg556 and prevents weapon initialisation.
Form the source code it's not clear where Init( is called from. My questions:

1) How CEconItemView gets initialised for ordinary weapons?
2) Can I somehow debug it, or does anobody know what could be the reason?
3) Can I somehow initialise CEconItemView?

Last edited by kadet.89; 06-06-2020 at 11:45.
kadet.89 is offline
Send a message via Skype™ to kadet.89
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-06-2020 , 14:24   Re: CEconItemView doesn't get initialised for custom weapons
Reply With Quote #2

You probably want to hook GiveNamedItem on the player instead.
asherkin is offline

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 01:23.

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