Skip to content

Econ Module can work with offlines now#213

Merged
Bishbash777 merged 12 commits intoTorchAPI:masterfrom
LordTylus:master
Mar 14, 2024
Merged

Econ Module can work with offlines now#213
Bishbash777 merged 12 commits intoTorchAPI:masterfrom
LordTylus:master

Conversation

@LordTylus
Copy link
Copy Markdown
Contributor

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.

image
image

Also if you take X credits from all players it will properly handle that now
image
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.

LordTylus and others added 12 commits December 30, 2023 00:20
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.
@Bishbash777 Bishbash777 merged commit 3938f34 into TorchAPI:master Mar 14, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants