I'm trying to hook CanHavePlayerItem in CS:S, so CT can pick up C4.
Either I'm doing something wrong or then it isn't fired.
My code:
Code:
#include <sourcemod>
#include <dhooks>
#pragma semicolon 1
new Handle:g_hSetObserverMode;
public Plugin:myinfo =
{
name = "C4",
author = "KK",
description = "",
version = "1.0.0",
url = "http://steamcommunity.com/id/i_like_denmark/"
};
public OnPluginStart()
{
new Handle:temp = LoadGameConfigFile("c4-offsets.games");
if(temp == INVALID_HANDLE)
{
SetFailState("Why you no has gamedata?");
}
new offset = GameConfGetOffset(temp, "CanHavePlayerItem");
g_hSetObserverMode = DHookCreate(offset, HookType_GameRules, ReturnType_Bool, ThisPointer_CBaseEntity, CanHavePlayerItem);
DHookAddParam(g_hSetObserverMode, HookParamType_CBaseEntity);
DHookAddParam(g_hSetObserverMode, HookParamType_CBaseEntity);
CloseHandle(temp);
}
public MRESReturn:CanHavePlayerItem(this, Handle:hReturn, Handle:hParams)
{
PrintToChatAll("hi");
}
Offsets (found with
https://asherkin.github.io/vtable/)
Code:
"Games"
{
"cstrike"
{
"Offsets"
{
"CanHavePlayerItem"
{
"windows" "86"
"linux" "87"
}
}
}
}
Edit: stupid me, I totally forgot hooking it..
Edit2: So BumpWeapon is fired for C4, but CanHavePlayerItem isn't. So some check done in BumpWeapon is false before it get to CanHavePlayerItem.
CanHavePlayerItem is fired for all other weapons, also EquipWeapon doesn't work it just remove the weapon from the world.