Skip to content

Extend WeaponSwitch/Use callbacks - #2535

Open
Kenzzer wants to merge 1 commit into
masterfrom
k/extend_sdkhooks
Open

Extend WeaponSwitch/Use callbacks#2535
Kenzzer wants to merge 1 commit into
masterfrom
k/extend_sdkhooks

Conversation

@Kenzzer

@Kenzzer Kenzzer commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fullfill feature request #2532

It is indeed odd for sdkhooks to expose the return value of one post callback (weaponreload) but not weaponswitch/use. Let's correct that.

@Kenzzer
Kenzzer requested a review from psychonic August 3, 2026 22:55
@Kenzzer Kenzzer changed the title k/extend_sdkhooks Extend WeaponSwitch/Use callbacks Aug 3, 2026
// WeaponSwitch
function Action (int client, int weapon);

// WeaponCanSwitchToPost

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation should be updated to nudge developers to use the improved version, so the three hooks can be removed form the signature?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like adding a short comment why using the callback definition below is preferrable ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I even thought it's ok to remove them from this one and only have them with the one with the bool success parameter.

But looking at how it was handled with other callbacks, specifically OnTakeDamage, before, we should keep it but add a comment that that parameter was an addition to sourcemod and add a proper feature provider so plugins can know whether that parameter is there or not at runtime for backwards compatibility.

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