Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C_BaseCombatWeapon::GetCSWeaponData(...) returned nullptr. #94

Open
ghost opened this issue Nov 27, 2019 · 8 comments
Open

C_BaseCombatWeapon::GetCSWeaponData(...) returned nullptr. #94

ghost opened this issue Nov 27, 2019 · 8 comments

Comments

@ghost
Copy link

ghost commented Nov 27, 2019

I've been able to reproduce this crash with a fresh git clone of the repo.
Attempting to use IsGun, IsRifle, ... causes a crash due to GetCSWeaponData returning nullptr.

@InfernoLum
Copy link

Maybe you should check if the weapon you are calling GetCSWeaponData exists, in other words if it isn't a nullptr. For example if you want to call GetCSWeaponData on your current local player's weapon you would do it like this:
auto weapon = g_LocalPlayer->m_hActiveWeapon(); if(!weapon) return; // or you can also use if(weapon != nullptr) return; which is the same thing // call whatever you want after you checked the weapon for a nullptr.

@ghost
Copy link
Author

ghost commented Dec 10, 2019

I have a check, if (!weapon) return; and I am able to get the weapon's spread somewhere else in my code so I don't think my weapon is nullptr.

@InsDel2113
Copy link

I'm having the same issue, generally issues with weapon data just randomly crashing

@CodingTimeDEV
Copy link

I'm a bit late to the party, but I'll give it a shot: has anyone achieved a more or less ghetto fix?

@ZippoKs
Copy link

ZippoKs commented Apr 9, 2020

CCSWeaponInfo* GetCSWeaponData() { if (this != nullptr) return g_WeaponSystem->GetWpnData(this->m_iItemDefinitionIndex()); }
Not a great solution, but works.

@CodingTimeDEV
Copy link

Well it kinda works but not really. I mean it helps to prevent csgo from crashing but it still doesn't always return corrent WeaponData. For some weapons I don't get any Data, for some wrong and for some the correct

@BabaHassan2115
Copy link

BabaHassan2115 commented May 20, 2020

@CodingTimeDEV Have you been able to fix this issue?
[EDIT]
I found out that if I will join the Aim Botz - Training map and then go onto other maps it won't crash anymore. Possible that it's maybe just a command in-game that's causing it to crash?

@noxppw
Copy link

noxppw commented Sep 22, 2020

I'm kinda late but i found the issue.
In NETVAR(int32_t, m_iItemDefinitionIndex, "DT_BaseAttributableItem", "m_iItemDefinitionIndex"); (csgostructs.hpp) change int32_t to int16_t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@CodingTimeDEV @InfernoLum @ZippoKs @noxppw @InsDel2113 @BabaHassan2115 and others