Fix CS_OnCSWeaponDrop after latest CSGO update (21/10/21) (#1602)

This commit is contained in:
GAMMACASE 2021-10-22 18:20:54 +03:00 committed by Your Name
parent 64b897822f
commit 8ae3be7185
3 changed files with 21 additions and 2 deletions

View File

@ -100,7 +100,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
g_pHandleBuyForward = forwards->CreateForward("CS_OnBuyCommand", ET_Event, 2, NULL, Param_Cell, Param_String);
g_pPriceForward = forwards->CreateForward("CS_OnGetWeaponPrice", ET_Event, 3, NULL, Param_Cell, Param_String, Param_CellByRef);
g_pTerminateRoundForward = forwards->CreateForward("CS_OnTerminateRound", ET_Event, 2, NULL, Param_FloatByRef, Param_CellByRef);
g_pCSWeaponDropForward = forwards->CreateForward("CS_OnCSWeaponDrop", ET_Event, 2, NULL, Param_Cell, Param_Cell);
g_pCSWeaponDropForward = forwards->CreateForward("CS_OnCSWeaponDrop", ET_Event, 3, NULL, Param_Cell, Param_Cell, Param_Cell);
m_TerminateRoundDetourEnabled = false;

View File

@ -216,12 +216,20 @@ DETOUR_DECL_MEMBER3(DetourTerminateRound, void, int, reason, int, unknown, int,
#endif
}
#if SOURCE_ENGINE == SE_CSGO
DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bThrowForward, bool, bDonated)
#else
DETOUR_DECL_MEMBER2(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bThrowForward)
#endif
{
if (g_pIgnoreCSWeaponDropDetour)
{
g_pIgnoreCSWeaponDropDetour = false;
#if SOURCE_ENGINE == SE_CSGO
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bThrowForward, bDonated);
#else
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bThrowForward);
#endif
return;
}
@ -231,12 +239,21 @@ DETOUR_DECL_MEMBER2(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bThro
cell_t result = Pl_Continue;
g_pCSWeaponDropForward->PushCell(client);
g_pCSWeaponDropForward->PushCell(weaponIndex);
#if SOURCE_ENGINE == SE_CSGO
g_pCSWeaponDropForward->PushCell(bDonated);
#else
g_pCSWeaponDropForward->PushCell(false);
#endif
g_pCSWeaponDropForward->Execute(&result);
if (result == Pl_Continue)
{
#if SOURCE_ENGINE == SE_CSGO
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bThrowForward, bDonated);
#else
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bThrowForward);
#endif
}
return;

View File

@ -196,8 +196,10 @@ forward Action CS_OnBuyCommand(int client, const char[] weapon);
*
* @param client Client index
* @param weaponIndex Weapon index
* @param donated Was weapon donated (Bought from a buy menu while ctrl was pressed)
* (Note: This param is for CS:GO only, will be false on other games)
*/
forward Action CS_OnCSWeaponDrop(int client, int weaponIndex);
forward Action CS_OnCSWeaponDrop(int client, int weaponIndex, bool donated);
/**
* Called when game retrieves a weapon's price for a player.