AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   CEconItemView doesn't get initialised for custom weapons (https://forums.alliedmods.net/showthread.php?t=325045)

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:
Code:

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 22:27.

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