AlliedModders (
-   Coding MM:S Plugins & SM Extensions (
-   -   CEconItemView doesn't get initialised for custom weapons (

kadet.89 06-06-2020 11:07

CEconItemView doesn't get initialised for custom weapons
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?

asherkin 06-06-2020 14:24

Re: CEconItemView doesn't get initialised for custom weapons
You probably want to hook GiveNamedItem on the player instead.

All times are GMT -4. The time now is 00:55.

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