Econ Module can work with offlines now#213
Merged
Bishbash777 merged 12 commits intoTorchAPI:masterfrom Mar 14, 2024
Merged
Conversation
It apparently is possible to have 2 Players with Same Steam ID but different Serial ID. Cause unknown. For both of them the same Identity ID is looked up because that ignores the Serial ID. And therefore I can just replace the value. Could auso check with if(!containsKey) but since the result will be identical I didn't bother.
Players were able to duplicate money by paying themselves. If Player A has 10,000 credits And Pays Player A 1,000 credits He ended up with 11,000 credits. But there was a warning on server side that the client was out of sync. And if you do anything else, like for example !econ set !econ take or !econ reset it crashed said client.
I dont exactly know why that limitation of online only was in place. set, take, give, check should work for offlines too. Since the others are not important enough (for me at least) I am not doing that with this commit.
…fline These kind of commands should work with IMyIdentity instead of IMyPlayer especially since the "*" parameter would work for ALL Players (not NPCs) but since I have no intention to fix it at this point in time. The better message will have to do.
…to 0. And for transfers proper feedback is provided
Who would have guessed ChangeBalanceBroadcastClient does NOT broadcast to the client. ChangeBalance does that automatically. The other method is... probably what is called IN the client after receiving the event.
dorimanx
pushed a commit
to dorimanx/Essentials
that referenced
this pull request
Nov 7, 2024
* Fix: It possible KeyAlreadyExistException workarounded It apparently is possible to have 2 Players with Same Steam ID but different Serial ID. Cause unknown. For both of them the same Identity ID is looked up because that ignores the Serial ID. And therefore I can just replace the value. Could auso check with if(!containsKey) but since the result will be identical I didn't bother. * Fix: Credits are Number-Formatted in all eco commands * Fix: Players can nolonger pay themselves Players were able to duplicate money by paying themselves. If Player A has 10,000 credits And Pays Player A 1,000 credits He ended up with 11,000 credits. But there was a warning on server side that the client was out of sync. And if you do anything else, like for example !econ set !econ take or !econ reset it crashed said client. * Fix: Added missing .DisplayName when Paying player * Feat: !econ check can now also check offline players I dont exactly know why that limitation of online only was in place. set, take, give, check should work for offlines too. Since the others are not important enough (for me at least) I am not doing that with this commit. * Fix: Responses now inform about the possability that the player is offline These kind of commands should work with IMyIdentity instead of IMyPlayer especially since the "*" parameter would work for ALL Players (not NPCs) but since I have no intention to fix it at this point in time. The better message will have to do. * Feat: Econ Module can now also work with offline players * Fix: If more credits are taken than the account has, credits are set to 0. And for transfers proper feedback is provided * Fix: Wrong Sync Client Server fworks correctly now Who would have guessed ChangeBalanceBroadcastClient does NOT broadcast to the client. ChangeBalance does that automatically. The other method is... probably what is called IN the client after receiving the event. * Fix: added forgotten formatting * Fix: More Formatting
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.
The economy Module now works primarily with Identities instead of players, and is therefore able to work with online players, offline players and NPCs where the previous method could only work with online players.
The API is pretty much the same, though each method has 2 new optional parameters for filter to online players and excluding NPCs
excluding NPCs is default true (just like before)
only showing Online is default false (WARNING UNLIKE BEFORE)
So its probably good to announce this change to prevent people from doing bullshit, when they accidentally do stuff to everyone. If they want to do stuff to only onlines, they have to apply the respective parameter.
Also if you take X credits from all players it will properly handle that now

before, it just didn't do anything.
I did add a new change to the Pay method. This purposely still has the online/offline check in, because I think its important, that players do transactions that both see, to prevent arguments over "you havent paid yet"
There i check if the paid amount is available first before paying. But sadly I cannot test that on my own as I need a second player for that.
Ignore the Commits from December those are already merged, I just forgot to drop these commits when syncing my fork.