Skip to content

Conversation

@bmgjet
Copy link
Contributor

@bmgjet bmgjet commented Sep 7, 2025

private object CanMannequinChangePose(Mannequin mannequin, BasePlayer player)

private object CanMannequinSwap(Mannequin mannequin, BasePlayer player)

private object CanMannequinChangePose(Mannequin mannequin, BasePlayer player)

private object CanMannequinSwap(Mannequin mannequin, BasePlayer player)
@ads102003 ads102003 merged commit 15132e1 into OxideMod:develop Sep 10, 2025
@IIIaKa
Copy link
Contributor

IIIaKa commented Oct 3, 2025

Why do you use Can for On object hooks? What's the point of creating rules for hooks if they are not followed?
Later you’ll end up confusing yourselves because of the incorrect names.

And it’s preferable to place verbs at the end of hook names, so that if necessary a hook can be added after execution.
CanMannequinChangePose -> OnMannequinPoseChange + OnMannequinPoseChanged
CanMannequinSwap -> OnMannequinSwap + OnMannequinSwapped

@bmgjet
Copy link
Contributor Author

bmgjet commented Oct 3, 2025

When I submitted the hooks I went off what it said on oxidemod docs. The purpose of the hooks is to block.
Can seemed the most appropriate for the use. It can be called a On hook if you want doesn't bother me since its a bit of a grey area but would require a few plugins to update now. You should of made your suggestion before it was approved.

Pre-Hooks
Pre-hooks provide plugin developers with the ability to intercept events before they are fully processed. There are two categories of pre-hooks: Can hooks and On hooks.

Can Hooks
Can hooks are executed before an event occurs and determine whether the event should proceed.
Purpose: Allow plugins to approve or prevent the execution of an event.
Return value: A object (null to allow, true or false to disallow).

On Hooks
On hooks are executed while an event is occurring and provide an opportunity to modify or extend the event’s behavior.
Purpose: Allow plugins to adjust event data or perform side effects during execution.
Return value: Varies by event; typically the modified event data.

@IIIaKa
Copy link
Contributor

IIIaKa commented Oct 4, 2025

Very strange. After all, they do write that Can hooks are used in places where a bool type is expected.

Here’s an example of correct Can hooks:

  • CanBypassQueue
  • CanLootPlayer
  • CanSwapToSeat
  • CanUpdateSign
    etc.

Here’s incorrect ones:

  • CanBuild
  • CanCreateWorldProjectile
  • CanChangeCode
  • CanSetBedPublic
    etc.

On hooks expect null to CONTINUE vanilla code, or ANY non-null value of ANY type to BLOCK vanilla code.
But Can hooks only expect a false (bool) value to BLOCK vanilla code, and ANY null or non-null value of ANY type, including true, allows vanilla code to CONTINUE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants