fix invalid client index crash in VIP_Tag on client connect - #21
Merged
Merged
Conversation
CS_GetClientClanTag was called from OnClientConnected, before the client entity actually exists, causing "Client index N is not valid" exceptions on connect. Move the lookup to OnClientPutInServer, where the entity is guaranteed to be valid.
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the SourceMod VIP_Tag plugin caused by calling CS_GetClientClanTag before the client entity exists by moving the initialization hook to a later lifecycle callback.
Changes:
- Bumped plugin version to
1.0.2. - Replaced
OnClientConnectedwithOnClientPutInServerfor capturing/storing the player’s original clan tag after the entity is created.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
OnClientConnectedfiredCS_GetClientClanTagbefore the cliententity existed, throwing
Client index N is not valid(see serverlog below). Switched the hook to
OnClientPutInServer, which onlyfires once the entity is created.
Log before fix
L 08/16/2026 - 13:01:19: [SM] Exception reported: Client index 12 is not valid
L 08/16/2026 - 13:01:19: [SM] Blaming: vip/VIP_Tag.smx
L 08/16/2026 - 13:01:19: [SM] [0] CS_GetClientClanTag
L 08/16/2026 - 13:01:19: [SM] [1] Line 44, VIP_Tag.sp::OnClientConnected