Not quite a plugin issue (afaik), but I got problems hooking CCSPlayer::RemoveAllItems(bool).
My code:
Code:
public void OnPluginStart()
{
[...]
// hooks
Handle hConfig = LoadGameConfigFile("noknife.games");
if(hConfig == null)
{
LogError("Unable to load gameconf: noknife.games");
return;
}
int iOffset = GameConfGetOffset(hConfig, "CCSPlayer::RemoveAllItems");
if(iOffset == -1)
{
CloseHandle(hConfig);
LogError("Unable to get offset for CCSPlayer::RemoveAllItems");
return;
}
CloseHandle(hConfig);
g_hHook = DHookCreate(iOffset, HookType_Entity, ReturnType_Void, ThisPointer_CBaseEntity, OnRemoveAllWeapons);
if(g_hHook == INVALID_HANDLE)
{
LogError("Unable to hook CCSPlayer::RemoveAllItems(bool)");
return;
}
DHookAddParam(g_hHook, HookParamType_Bool, 1, DHookPass_ByVal);
for(int i = 0; i < MaxClients; i++)
{
if(!IsValidClient(i)) continue;
DHookEntity(g_hHook, true, i);
}
[...]
public MRESReturn OnRemoveAllWeapons(int pThis, Handle hParams)
{
if(!IsValidClient(pThis)) return MRES_Ignored;
LogMessage("OnRemoveAllWeapons() called | pThis: %d (%N) | hParams[1]: %d", pThis, pThis, DHookGetParam(hParams, 1));
if(g_bHideKnife[pThis]) return MRES_Ignored;
LogMessage("Stopping call of RemoveAllWeapons() for %N (%d)", pThis, pThis);
return MRES_Supercede;
}
Hook is also activated in OnClientPutInServer.
Gamedata:
Code:
"Games"
{
"csgo"
{
"Offsets"
{
"CCSPlayer::RemoveAllItems"
{
"windows" "382"
"linux" "383"
"mac" "383"
}
}
}
}
It actually prints out this in the log:
Quote:
L 07/25/2015 - 14:04:09: [noknife.smx] OnRemoveAllWeapons() called | pThis: 29 (name1) | hParams[1]: 1
L 07/25/2015 - 14:04:28: [noknife.smx] OnRemoveAllWeapons() called | pThis: 18 (name2) | hParams[1]: 1
L 07/25/2015 - 14:04:28: [noknife.smx] Stopping call of RemoveAllWeapons() for name2(1
L 07/25/2015 - 14:04:29: [noknife.smx] OnRemoveAllWeapons() called | pThis: 4 (name3) | hParams[1]: 1
L 07/25/2015 - 14:04:29: [noknife.smx] Stopping call of RemoveAllWeapons() for name3 (4)
|
But knives/weapons are still missing. My aim is to have knives/pistols on every surf map, as some of them are stripping all your slots of.
Am I hooking the wrong function or something else wrong?
__________________
Stopped hosting servers as of November 2018, no longer active around here.