feat: add SBPP_BanPlayerBySteamId native for offline player bans#1511
Open
Sigibert wants to merge 3 commits into
Open
feat: add SBPP_BanPlayerBySteamId native for offline player bans#1511Sigibert wants to merge 3 commits into
Sigibert wants to merge 3 commits into
Conversation
SBPP_BanPlayer requires an in-game client index, making it impossible to ban players who disconnect before an automated ban fires. The new native accepts a SteamID string and player name directly, allowing plugins to record a ban in the SBPP database for players who are no longer connected. Implementation: - Checks for an existing active ban first (duplicate-prevention SELECT) - Inserts into sb_bans with length in seconds (iTime * 60) and the IFNULL admin-lookup subquery, matching the pattern used by CommandAddBan - Uses a server-lookup subquery when serverID == -1 (unregistered), or the cached serverID directly - Fires SBPP_OnBanPlayer with iTarget = -1 to signal an offline ban sourcebanspp.inc: - Declares the new native with full doc comment - Adds MarkNativeAsOptional in __pl_sourcebanspp_SetNTVOptional
rumblefrog
reviewed
Jun 27, 2026
| pack.WriteString(adminAuth); | ||
| pack.WriteString(adminIp); | ||
|
|
||
| char steamIdEscaped[MAX_AUTHID_LENGTH * 2 + 1]; |
Member
There was a problem hiding this comment.
Need to check for steamid type since enforcement is done with SteamID2
Contributor
Author
There was a problem hiding this comment.
I added a SteamID2 format check to the steamId provided by the native. Hope that fits ur concerns.
SBPP enforces bans on connect using AuthId_Steam2. If a caller passed a SteamID64 or SteamID3 the ban would be stored but never fire. Now throws a native error immediately if the steamId argument does not start with 'STEAM_'. Addresses review comment from rumblefrog on PR sbpp#1511.
rumblefrog
reviewed
Jul 9, 2026
|
|
||
| DB.Query(DB_OnBanBySteamIdSelect, query, pack, DBPrio_High); | ||
|
|
||
| Call_StartForward(g_hFwd_OnBanAdded); |
Member
There was a problem hiding this comment.
i don't know your use case, but nit if this should be checking the insertion result before firing, otherwe lgtm
Contributor
Author
There was a problem hiding this comment.
Fixed in 97ed2bf — the forward now fires from the INSERT callback (DB_OnBanBySteamIdInsert) only once results != null, instead of firing synchronously right after issuing the SELECT.
Addresses review nit on PR sbpp#1511 (rumblefrog): the forward was fired synchronously right after issuing the async duplicate-check SELECT, before the ban row was ever written. It now fires from DB_OnBanBySteamIdInsert only when the INSERT query succeeds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
SBPP_BanPlayerBySteamId— a new native for banning players who are no longer connected to the server.SBPP_BanPlayerrequires an in-game client index. This makes it impossible to ban players via automated systems (TK managers, anti-cheat, etc.) when the target disconnects before the ban fires. The new native accepts a SteamID string and player name directly, bypassing the need for an active client slot.API
iAdminsteamIdSTEAM_0:X:YformatnameiTimesReasonImplementation
CommandAddBan) -- skips the INSERT if an active ban for that SteamID already existssb_banswithlengthin seconds (iTime * 60) andends = UNIX_TIMESTAMP() + (iTime * 60)IFNULL((SELECT aid ...), '0')for the admin ID lookup, matching the existing patternsidwhenserverID == -1(server not yet registered in SBPP)SBPP_OnBanPlayerforward withiTarget = -1to signal an offline ban to any listening pluginssourcebanspp.inc changes
MarkNativeAsOptional("SBPP_BanPlayerBySteamId")in__pl_sourcebanspp_SetNTVOptionalso plugins that use this native can still load when running without SBPP