Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUGGESTION] Implement monetary transactions as a function #943

Open
LordChunk opened this issue Feb 9, 2023 · 2 comments
Open

[SUGGESTION] Implement monetary transactions as a function #943

LordChunk opened this issue Feb 9, 2023 · 2 comments
Assignees

Comments

@LordChunk
Copy link

LordChunk commented Feb 9, 2023

The problem

It is currently impossible to safely conduct transactions between players. The most common way is to use the AddMoney and RemoveMoney functions, but this causes several problems.

Firstly, it is not possible to see where money comes from. Yes, you do have a reason parameter, but this is optional.

You can't use SQL transactions to safely update players' balance, as the mutations are running separately.

Ideal solution

Store player balances separately from the player table in a dedicated table with support for different bank account types. Also have a table for tracking transactions between accounts and other bank account mutations. Also, have a dedicated function for transferring money between different accounts.

Alternative solutions

Implement a money transfer method. This would not require a dedicated table, which would lead to big migration overhead for existing servers. This transfer method would be able to transfer money of both cash and bank balances to different users, or be able to convert cash to bank balances and vice versa.

Additional context

No response

@LordChunk LordChunk added the enhancement New feature or request label Feb 9, 2023
@PatalJunior
Copy link

You can't use SQL transactions to safely update players' balance, as the mutations are running separately.

I'm confused by your wording here, since I'm not sure if you are speaking about SQL Transactions or just a transaction, the act of exchanging something, so I'll propose a implementation assuming you are speaking about a normal transaction.

Upon reading thru the oxmysql documentation, there is a method, called a transaction that only executes at the same time, and if a problem occurs a rollback occurs, so this would be the indicated method to use on said implementation of your idea.

@LordChunk
Copy link
Author

In your quoted line I'm talking about SQL transactions (not monetary transactions).

I am ware of oxmysql's support for SQL transactions, but you cannot use those if you wish to use the native QB-Core events as these do not allow you to pass a SQL transaction. Fruthermore, events to update a player's balance may also be triggered from the client in which case you can't create an SQL transaction outright.

@GhzGarage GhzGarage added suggestion and removed enhancement New feature or request labels Jun 1, 2023
@GhzGarage GhzGarage self-assigned this Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants