feat: add ReplicateConVar #751
Merged
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.
This PR is based on #563 but I have removed the client checks (as they are not necessary) which makes this easier to maintain.
I have tested and validated that everything works correctly on Linux, the core
ReplicateConVarcode is also identical to the implementation in CS2Fixes (https://github.com/Source2ZE/CS2Fixes/blob/e9dfd9a08b7158c313221019d34e8586a6396d5a/src/playermanager.cpp#L567-L580) and uses all the same features whichUserMessagealready relies on, no additional signatures or offsets.I have tested this with
sv_autobunnyhoppingandsv_enablebunnyhoppingusing the plugin below to enable bhop on a per player basis and I have not encountered any issues, I tested this with a friend to ensure it was properly setting per player.Here is a simple bhop example plugin https://gist.github.com/21Joakim/480f2bae588df54d2f34faba8b2861bc, simply use the
bhopconsole command to toggle bhop on and off for your player only.I did some additional tests to ensure it is safe to use
convarname(i.e. a convar which does not exist) does not cause any issuesconvarvalue(e.g. a string for a bool value) for the providedconvarnameconvar does not cause any issuesslot(i.e. a negative slot or a slot which does not have a player) does not cause any issuesconvarnameorconvarvaluedoes not cause any issuesUserMessagehook forSetConvarworks as expected, it sees the messages emitted byReplicateConVarand there are no issues with sending theUserMessagefrom within the hooknullvalue forconvarnameorconvarvaluewill cause a segfault, this happens for other native functions as well (e.g.player.ExecuteClientCommand(null)) so probably more of a systemic problem if anythingI have been waiting for the original PR to be merged for almost 5 months so I am hoping that by cutting the feature down to the core and testing it thoroughly we can have this new PR merged quickly!