Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding player:SetSharedVar("Flags", player:GetFlags()); to the end of both functions: function Clockwork:PlayerFlagsGiven(player, flags) & function Clockwork:PlayerFlagsTaken(player, flags) This fixes the issue of flags not updating. Originally, the character would have to be reloaded to see updated flags. This fixes that.
- Loading branch information
2b40cc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be done in the hook callback, though. It should really be done in the Clockwork.player.GiveFlags and Clockwork.player.TakeFlags methods, but actually SetCharacterData("Flags", ...) in those methods does automatically call SetSharedVar because it's called by SetCharacterData internally as "Flags" is already added with AddCharacterData in sh_boot.lua (and networked that way.)
So this will cause SetSharedVar to be called twice, the actual bug is that SetCharacterData doesn't appear to be calling SetSharedVar...
My other concern is that global flags (GivePlayerFlag) doesn't seem to get networked at all, so there's no way to know client-side what global flags you have?
Can I confirm that prior to this bug fix, you were using and connected to the latest CAX for CW 0.98 as that will contain the latest versions of the Clockwork.player.UpdateCharacterData method.
@sannysc @Nightmare-Night @xRJx
2b40cc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I was concerned at the time, and as I've explained before, the only issue I ran into was that the character data would only update upon reloading the character. (Switching my character then going back to the previous character) Whatever is the issue, or whatever is missing, it was causing it not to update in-real-time.
I edited as per each time either a character is given or gets a flag taken from them, it refreshes and grabs the flags for that player. After I added the two lines, I haven't had any issue of flags becoming corrupt, or any sort of loop, or the flags being carried over globally as I never checked plygiveflags function.
And I can confirm that prior to this bug fix, I was using the most recent CAX and have been connected. Basically, took whatever was available a few days before I made this pull request, and threw in this fix and it fixed the problem I was having with flags updating.
Bare with me if I misinterpreted anything you may of said, as this is my first pull request for clockwork.
@kurozael
2b40cc1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're able to move to these calls into the actual Clockwork.player.GiveFlags and Clockwork.player.TakeFlags methods instead of the hooks that'd be okay for now until I can investigate why UpdateCharacterData isn't automatically setting the shareds vars itself.
Another thing you could investigate is whether or not "Player Flags". which are the global equivalent of "Character Flags", are ever networked.
I can merge in any additional pull-requests when that's resolved. I'd simply go ahead and make the setting of the shared vars happen at the end of the GiveFlags/TakeFlags methods because the gamemode hooks may never be called if a plugin returns out a value before it reaches them.
@sannysc @Nightmare-Night @xRJx