Quote:
Originally Posted by nosoop
*snip*
|
Thank you SO much! I believe this is the one.
Now I've run into another problem though. I'm using a Dynamic Detour to hook onto CanUpgradeWithAttrib(), and all I'm doing right now is trying to print out the attribute and target slot in the chat. However, anytime I purchase an upgrade, my server crashes, stating I should check my detour setup.
This is my current detour setup:
Code:
g_hDetourCanUpgradeWithAttrib = new DynamicDetour(Address_Null, CallConv_THISCALL, ReturnType_Bool, ThisPointer_Ignore);
DHookSetFromConf(g_hDetourCanUpgradeWithAttrib, hGameConf, SDKConf_Signature, "CTFGameRules::CanUpgradeWithAttrib");
DHookAddParam(g_hDetourCanUpgradeWithAttrib, HookParamType_CBaseEntity);
DHookAddParam(g_hDetourCanUpgradeWithAttrib, HookParamType_Int);
DHookAddParam(g_hDetourCanUpgradeWithAttrib, HookParamType_Int);
DHookEnableDetour(g_hDetourCanUpgradeWithAttrib, false, Detour_CTFGameRules_CanUpgradeWithAttrib); //pre hook, because we want to get params and change their returns,
//and possibly ignore the original function
...
MRESReturn Detour_CTFGameRules_CanUpgradeWithAttrib(Handle hReturn, Handle hParams)
{
int iClient = DHookGetParam(hParams, 0);
int iWeaponSlot = DHookGetParam(hParams, 1);
int iAttribIndex = DHookGetParam(hParams, 2);
PrintToChat(iClient, "Upgrade check! Slot: %i, Attribute Index: %i", iWeaponSlot, iAttribIndex);
DHookSetReturn(hReturn, false);
return MRES_Ignored;
}
I'm very sorry if the solution seems obvious, I've never used detours before.
__________________