Skip to content

SDKHook_Use doesn't respect return Plugin_Handled. #1870

@nikita1824

Description

@nikita1824

Help us help you

  • I have checked that my issue doesn't exist yet. (not sure, i tried to find it but couldn't find it)
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Environment

  • Operating System version: Ubuntu 22.04.1
  • Game/AppID (with version if applicable): Left 4 Dead 2 v2.2.2.6 / 550
  • Current SourceMod version: 1.11.0.6919
  • Current SourceMod snapshot: 1.11.0.6919
  • Current Metamod: Source snapshot: 1.11.0-dev+1148

Description

When trying to prevent players to use entities with sdkhooks, SDKHook_Use doesn't prevent it when function return Plugin_Handled. But if we unload plugin and then load it again, plugin works fine (late load?).

Problematic Code (or Steps to Reproduce)

public void OnEntityCreated(int iEnt, const char[] szClsName) {
  if (strcmp(szClsName, "prop_minigun") == 0 || strcmp(szClsName, "prop_minigun_l4d1") == 0 || strcmp(szClsName, "prop_mounted_machine_gun") == 0)
      SDKHook(iEnt, SDKHook_Use, OnUseMinigun);
}

Action OnUseMinigun(int iEnt, int iActivator, int iCaller, UseType uType, float fValue) {
  if (iCaller <= 0)                return Plugin_Continue;
  if (iCaller > MaxClients)        return Plugin_Continue;
  if (!IsClientInGame(iCaller))    return Plugin_Continue;
  if (GetClientTeam(iCaller) != 2) return Plugin_Continue;
  if (uType != Use_Toggle)         return Plugin_Continue;
  ...
  return Plugin_Handled; << it works but anyway it allows players to use entity
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions